Skip to content

Commit

Permalink
mixed ferge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
The-AhmadAA committed Oct 15, 2023
2 parents fade9b8 + 6f0c14b commit 04b86aa
Showing 5 changed files with 55 additions and 0 deletions.
Binary file added source/core/assets/images/skeleton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/skeleton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.csse3200.game.components.maingame;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.ui.ProgressBar;
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;

public class LevelProgressBar extends ProgressBar {

/**
* @param width of the health bar
* @param height of the health bar
*/
public LevelProgressBar(int width, int height) {
super(0f, 100f, 0.01f, false, new ProgressBarStyle());
getStyle().background = getColoredDrawable(width, height, Color.RED);
// getStyle().knob = getColoredDrawable(0, height, Color.GREEN);
getStyle().knob = new TextureRegionDrawable(new TextureRegion(new Texture("images/skeleton.png")));
getStyle().knobBefore = getColoredDrawable(width, height, Color.GREEN);

setWidth(width);
setHeight(height);

setAnimateDuration(0.0f);
setValue(1f);

setAnimateDuration(0.25f);
}

public static Drawable getColoredDrawable(int width, int height, Color color) {
Pixmap pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
pixmap.setColor(color);
pixmap.fill();

TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap)));

pixmap.dispose();

return drawable;
}
}
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ public class UIElementsDisplay extends UIComponent {
private final Table buttonTable = new Table();
private TextButton remainingMobsButton;
private TextButton timerButton;
private LevelProgressBar progressbar;
private final int timer = 110;

@Override
@@ -58,9 +59,17 @@ private void addActors() {

stage.addActor(buttonTable);

progressbar = new LevelProgressBar(500, 10);
progressbar.setPosition(500, Gdx.graphics.getHeight() - 200);
stage.addActor(progressbar);

createTimerButton();
}

public void updateLevelProgressBar() {
float totalSecs = (ServiceLocator.getTimeSource().getTime() / 1000);
progressbar.setValue(totalSecs);
}

/**
* This method updates the mob count button as mobs die in the game
@@ -144,5 +153,6 @@ public float getZIndex() {
public void dispose() {
super.dispose();
buttonTable.clear();
progressbar.clear();
}
}
Original file line number Diff line number Diff line change
@@ -215,6 +215,7 @@ public void render(float delta) {

ServiceLocator.getWaveService().getDisplay().updateTimerButton();
ServiceLocator.getWaveService().getDisplay().updateMobCount();
ServiceLocator.getWaveService().getDisplay().updateLevelProgressBar();
renderer.render();

// Check if the game has ended

0 comments on commit 04b86aa

Please sign in to comment.