Skip to content

Current buff Display

Su LAN edited this page Sep 13, 2021 · 1 revision

Current buff Display

Use AssetManager to create a manager to manage the Texture. Assets are reference counted. This also means that if you load an asset several times, it will only take up memory once!

public static AssetManager manager =  new  AssetManager ();

Extracting information about the current player, and then you can track the player's position.

this.player = ((ForestGameArea) currentMap).getPlayer();

get the current buff of the player

Provides an interface that allows us to get the player's current buffs

     public Collection<BuffInformation> current_buff(){
        return this.timedBuffs.values();
    }

Iteration using for loops

Set the side length of the square image to 0.4f, each iteration will be the Texture in order to appear above the player.
Get the current buff through the interface provided by registerBuff.java

    Collection<BuffInformation> buffs = entity.getComponent(BuffManager.class).test();
    float i = 0f;
    for (BuffInformation buff:buffs) {
      if(Objects.equals(buff.getType().toString(), "BT_INVIN")){
        batch.draw(manager.get("images/ghostKing.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      if (Objects.equals(buff.getType().toString(), "DT_GIANT")){
        batch.draw(manager.get("images/winReplay.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      if (Objects.equals(buff.getType().toString(), "DT_NO_JUMP")){
        batch.draw(manager.get("images/box_boy.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      if (Objects.equals(buff.getType().toString(), "BT_INF_SPRINT")){
        batch.draw(manager.get("images/box_boy.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      if (Objects.equals(buff.getType().toString(), "DT_DOUBLE_DMG")){
        batch.draw(manager.get("images/pauseRestart.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      if (Objects.equals(buff.getType().toString(), "B_FULL_HEAL")){
        batch.draw(manager.get("images/heart.png", Texture.class),player.getPosition().x+1.2f-i, player.getPosition().y+1.7f,0.4f,0.4f);
      }
      i+=0.4f;
    }

Table of Contents

Home

Introduction

Main Menu

Main Game Screen

Gameplay

Player Movement

Character Animations

Enemy Monster Design and Animations

Game basic functionalities

User Testing

GitHub Wiki Tutorial

Game Engine

Getting Started

Documentation

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally