Skip to content

Commit

Permalink
Merge pull request #198 from UQcsse3200/team-2-ui-Alasdair
Browse files Browse the repository at this point in the history
Team 2 UI alasdair
  • Loading branch information
Mohamad11Dab authored Oct 1, 2023
2 parents 08c9633 + fc2cd97 commit 936452a
Show file tree
Hide file tree
Showing 18 changed files with 865 additions and 158 deletions.
7 changes: 7 additions & 0 deletions source/core/assets/configs/text.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"com.badlogic.gdx.graphics.g2d.BitmapFont": {
"default": {
"file": "images/ui/font.fnt"
}
}
}
Binary file added source/core/assets/images/ui/Button_Bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 99 additions & 0 deletions source/core/assets/images/ui/font.fnt
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
info face="Times New Roman" size=-32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=0 aa=1 padding=0,0,0,0 spacing=0,0 outline=0
common lineHeight=37 base=29 scaleW=256 scaleH=128 pages=1 packed=0 alphaChnl=0 redChnl=4 greenChnl=4 blueChnl=4
page id=0 file="font.png"
chars count=95
char id=32 x=0 y=0 width=0 height=0 xoffset=0 yoffset=0 xadvance=8 page=0 chnl=15
char id=33 x=251 y=20 width=4 height=23 xoffset=4 yoffset=6 xadvance=12 page=0 chnl=15
char id=34 x=47 y=96 width=9 height=10 xoffset=2 yoffset=6 xadvance=13 page=0 chnl=15
char id=35 x=151 y=15 width=15 height=23 xoffset=1 yoffset=6 xadvance=17 page=0 chnl=15
char id=36 x=169 y=77 width=13 height=26 xoffset=2 yoffset=5 xadvance=17 page=0 chnl=15
char id=37 x=0 y=82 width=25 height=24 xoffset=1 yoffset=6 xadvance=27 page=0 chnl=15
char id=38 x=21 y=53 width=23 height=24 xoffset=1 yoffset=6 xadvance=25 page=0 chnl=15
char id=39 x=61 y=96 width=3 height=10 xoffset=1 yoffset=6 xadvance=5 page=0 chnl=15
char id=40 x=218 y=37 width=9 height=30 xoffset=1 yoffset=6 xadvance=10 page=0 chnl=15
char id=41 x=225 y=67 width=9 height=30 xoffset=0 yoffset=6 xadvance=10 page=0 chnl=15
char id=42 x=232 y=0 width=11 height=13 xoffset=2 yoffset=6 xadvance=15 page=0 chnl=15
char id=43 x=155 y=105 width=17 height=18 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=44 x=56 y=96 width=5 height=9 xoffset=1 yoffset=25 xadvance=8 page=0 chnl=15
char id=45 x=52 y=24 width=8 height=3 xoffset=1 yoffset=20 xadvance=10 page=0 chnl=15
char id=46 x=38 y=77 width=3 height=4 xoffset=2 yoffset=25 xadvance=7 page=0 chnl=15
char id=47 x=198 y=100 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=48 x=166 y=15 width=14 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=49 x=206 y=15 width=10 height=22 xoffset=3 yoffset=7 xadvance=16 page=0 chnl=15
char id=50 x=141 y=82 width=15 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=51 x=156 y=82 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=52 x=160 y=38 width=14 height=22 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=15
char id=53 x=184 y=55 width=13 height=22 xoffset=2 yoffset=7 xadvance=16 page=0 chnl=15
char id=54 x=180 y=15 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=55 x=141 y=105 width=14 height=22 xoffset=1 yoffset=7 xadvance=16 page=0 chnl=15
char id=56 x=186 y=100 width=12 height=23 xoffset=2 yoffset=6 xadvance=16 page=0 chnl=15
char id=57 x=182 y=77 width=13 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=58 x=236 y=13 width=3 height=15 xoffset=3 yoffset=14 xadvance=9 page=0 chnl=15
char id=59 x=251 y=0 width=5 height=20 xoffset=2 yoffset=14 xadvance=9 page=0 chnl=15
char id=60 x=167 y=60 width=17 height=17 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=61 x=29 y=22 width=17 height=7 xoffset=1 yoffset=15 xadvance=19 page=0 chnl=15
char id=62 x=174 y=38 width=17 height=17 xoffset=1 yoffset=10 xadvance=19 page=0 chnl=15
char id=63 x=195 y=77 width=12 height=23 xoffset=1 yoffset=6 xadvance=14 page=0 chnl=15
char id=64 x=0 y=0 width=29 height=30 xoffset=1 yoffset=6 xadvance=30 page=0 chnl=15
char id=65 x=0 y=106 width=24 height=22 xoffset=-1 yoffset=7 xadvance=23 page=0 chnl=15
char id=66 x=71 y=95 width=20 height=22 xoffset=0 yoffset=7 xadvance=22 page=0 chnl=15
char id=67 x=70 y=71 width=20 height=24 xoffset=1 yoffset=6 xadvance=21 page=0 chnl=15
char id=68 x=47 y=74 width=23 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=69 x=90 y=71 width=20 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=70 x=111 y=44 width=17 height=22 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=15
char id=71 x=25 y=82 width=22 height=24 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=72 x=48 y=106 width=23 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=73 x=216 y=15 width=10 height=22 xoffset=0 yoffset=7 xadvance=11 page=0 chnl=15
char id=74 x=197 y=53 width=12 height=23 xoffset=0 yoffset=7 xadvance=12 page=0 chnl=15
char id=75 x=24 y=106 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=76 x=91 y=46 width=20 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=77 x=29 y=0 width=28 height=22 xoffset=0 yoffset=7 xadvance=29 page=0 chnl=15
char id=78 x=57 y=0 width=24 height=22 xoffset=-1 yoffset=7 xadvance=23 page=0 chnl=15
char id=79 x=78 y=22 width=21 height=24 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=80 x=118 y=22 width=17 height=22 xoffset=0 yoffset=7 xadvance=18 page=0 chnl=15
char id=81 x=0 y=53 width=21 height=29 xoffset=1 yoffset=6 xadvance=23 page=0 chnl=15
char id=82 x=81 y=0 width=22 height=22 xoffset=0 yoffset=7 xadvance=21 page=0 chnl=15
char id=83 x=172 y=103 width=14 height=24 xoffset=2 yoffset=6 xadvance=18 page=0 chnl=15
char id=84 x=103 y=0 width=18 height=22 xoffset=1 yoffset=7 xadvance=19 page=0 chnl=15
char id=85 x=30 y=29 width=24 height=23 xoffset=-1 yoffset=7 xadvance=22 page=0 chnl=15
char id=86 x=44 y=52 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=87 x=0 y=30 width=30 height=23 xoffset=0 yoffset=7 xadvance=30 page=0 chnl=15
char id=88 x=54 y=27 width=24 height=22 xoffset=0 yoffset=7 xadvance=24 page=0 chnl=15
char id=89 x=68 y=49 width=23 height=22 xoffset=0 yoffset=7 xadvance=23 page=0 chnl=15
char id=90 x=99 y=22 width=19 height=22 xoffset=0 yoffset=7 xadvance=20 page=0 chnl=15
char id=91 x=227 y=30 width=8 height=29 xoffset=3 yoffset=7 xadvance=12 page=0 chnl=15
char id=92 x=209 y=53 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=93 x=234 y=59 width=8 height=29 xoffset=1 yoffset=7 xadvance=12 page=0 chnl=15
char id=94 x=91 y=116 width=15 height=12 xoffset=0 yoffset=6 xadvance=15 page=0 chnl=15
char id=95 x=52 y=22 width=17 height=2 xoffset=0 yoffset=35 xadvance=17 page=0 chnl=15
char id=96 x=46 y=22 width=6 height=6 xoffset=1 yoffset=6 xadvance=11 page=0 chnl=15
char id=97 x=195 y=0 width=13 height=15 xoffset=1 yoffset=14 xadvance=15 page=0 chnl=15
char id=98 x=128 y=44 width=16 height=23 xoffset=-1 yoffset=6 xadvance=16 page=0 chnl=15
char id=99 x=208 y=0 width=12 height=15 xoffset=1 yoffset=14 xadvance=14 page=0 chnl=15
char id=100 x=135 y=15 width=16 height=23 xoffset=1 yoffset=6 xadvance=16 page=0 chnl=15
char id=101 x=220 y=0 width=12 height=15 xoffset=1 yoffset=14 xadvance=14 page=0 chnl=15
char id=102 x=193 y=15 width=13 height=23 xoffset=1 yoffset=6 xadvance=10 page=0 chnl=15
char id=103 x=152 y=60 width=15 height=22 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=104 x=91 y=93 width=17 height=23 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
char id=105 x=243 y=0 width=8 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=106 x=229 y=97 width=9 height=30 xoffset=-3 yoffset=6 xadvance=9 page=0 chnl=15
char id=107 x=108 y=93 width=17 height=23 xoffset=0 yoffset=6 xadvance=16 page=0 chnl=15
char id=108 x=235 y=30 width=9 height=23 xoffset=0 yoffset=6 xadvance=9 page=0 chnl=15
char id=109 x=110 y=68 width=25 height=15 xoffset=0 yoffset=14 xadvance=24 page=0 chnl=15
char id=110 x=145 y=0 width=17 height=15 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=111 x=191 y=38 width=14 height=15 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=112 x=125 y=83 width=16 height=22 xoffset=-1 yoffset=14 xadvance=16 page=0 chnl=15
char id=113 x=125 y=105 width=16 height=22 xoffset=1 yoffset=14 xadvance=16 page=0 chnl=15
char id=114 x=217 y=107 width=12 height=15 xoffset=0 yoffset=14 xadvance=11 page=0 chnl=15
char id=115 x=226 y=15 width=10 height=15 xoffset=2 yoffset=14 xadvance=13 page=0 chnl=15
char id=116 x=207 y=107 width=10 height=20 xoffset=0 yoffset=9 xadvance=10 page=0 chnl=15
char id=117 x=135 y=67 width=17 height=15 xoffset=-1 yoffset=14 xadvance=15 page=0 chnl=15
char id=118 x=162 y=0 width=17 height=15 xoffset=-1 yoffset=14 xadvance=16 page=0 chnl=15
char id=119 x=121 y=0 width=24 height=15 xoffset=0 yoffset=14 xadvance=23 page=0 chnl=15
char id=120 x=179 y=0 width=16 height=15 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=121 x=144 y=38 width=16 height=22 xoffset=0 yoffset=14 xadvance=16 page=0 chnl=15
char id=122 x=205 y=38 width=13 height=15 xoffset=1 yoffset=14 xadvance=15 page=0 chnl=15
char id=123 x=207 y=76 width=9 height=31 xoffset=4 yoffset=6 xadvance=15 page=0 chnl=15
char id=124 x=238 y=88 width=2 height=30 xoffset=2 yoffset=6 xadvance=7 page=0 chnl=15
char id=125 x=216 y=76 width=9 height=31 xoffset=3 yoffset=6 xadvance=16 page=0 chnl=15
char id=126 x=21 y=77 width=17 height=5 xoffset=1 yoffset=18 xadvance=18 page=0 chnl=15
Binary file added source/core/assets/images/ui/font.png
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/ui/mouse_effect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
147 changes: 15 additions & 132 deletions source/core/src/main/com/csse3200/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.csse3200.game.entities.Entity;
import com.csse3200.game.entities.factories.*;
import com.csse3200.game.physics.PhysicsLayer;
import com.csse3200.game.screens.AssetLoader;
import com.csse3200.game.utils.math.RandomUtils;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.GameEndService;
Expand All @@ -24,6 +25,7 @@


import static com.csse3200.game.entities.factories.NPCFactory.createGhost;
import static com.csse3200.game.screens.AssetLoader.loadAllAssets;

import java.util.ArrayList;
import java.util.TimerTask;
Expand All @@ -35,7 +37,7 @@ public class ForestGameArea extends GameArea {
private static final int NUM_GHOSTS = 0;
private static final int NUM_GRUNTS = 5;
private static final int NUM_BOSS = 4;

private AssetLoader assetLoader;

private static final int NUM_BOSSKING2=3;
private static final int NUM_BOSSKING1=1;
Expand All @@ -49,118 +51,8 @@ public class ForestGameArea extends GameArea {
private static final GridPoint2 PLAYER_SPAWN = new GridPoint2(0, 0);
// Temporary spawn point for testing
private static final float WALL_WIDTH = 0.1f;

// Required to load assets before using them
private static final String[] forestTextures = {
"images/desert_bg.png",
"images/ice_bg.png",
"images/lava_bg.png",
"images/projectiles/projectile.png",
"images/ingamebg.png",
"images/box_boy_leaf.png",
"images/background/building1.png",
"images/ghost_1.png",
"images/grass_2.png",
"images/grass_3.png",
"images/hex_grass_1.png",
"images/background/mountain.png",
"images/ghost_king.png",
"images/ghost_1.png",
"images/terrain 2 normal.png",
"images/terrain 2 hex.png",
"images/hex_grass_2.png",
"images/hex_grass_3.png",
"images/iso_grass_1.png",
"images/iso_grass_2.png",
"images/iso_grass_3.png",
"images/towers/turret.png",
"images/towers/turret01.png",
"images/towers/turret_deployed.png",
"images/towers/fire_tower_atlas.png",
"images/towers/stun_tower.png",
"images/background/building2.png",
"images/mobs/robot.png",
"images/mobs/boss2.png",
"images/mobs/Attack_1.png",
"images/mobs/Attack_2.png",
"images/mobs/Charge_1.png",
"images/mobs/Charge_2.png",
"images/mobs/Dead.png",
"images/mobs/Enabling-5.png",
"images/mobs/satyr.png",
"images/mobs/Hurt.png",
"images/mobs/Idle.png",
"images/mobs/rangeBossRight.png",
"images/towers/wallTower.png",
"images/background/building2.png",
"images/iso_grass_3.png",
"images/terrain_use.png",
"images/Dusty_MoonBG.png",
"images/economy/scrap.png",
"images/economy/crystal.png",
"images/economy/econ-tower.png",
"images/projectiles/bossProjectile.png",
"images/towers/mine_tower.png",
"images/towers/TNTTower.png",
"images/towers/DroidTower.png",
"images/projectiles/basic_projectile.png",
"images/projectiles/mobProjectile.png",
"images/projectiles/engineer_projectile.png",
"images/projectiles/mobKing_projectile.png",
"images/projectiles/snow_ball.png",
"images/projectiles/burn_effect.png",
"images/projectiles/stun_effect.png",
"images/projectiles/firework_anim.png",
"images/projectiles/pierce_anim.png",
"images/projectiles/snow_ball.png"
};
private static final String[] forestTextureAtlases = {
"images/economy/econ-tower.atlas",
"images/terrain_iso_grass.atlas",
"images/ghost.atlas",
"images/mobs/boss2.atlas",
"images/ghostKing.atlas",
"images/towers/turret.atlas",
"images/towers/turret01.atlas",
"images/mobs/xenoGrunt.atlas",
"images/towers/fire_tower_atlas.atlas",
"images/towers/stun_tower.atlas",
"images/mobs/xenoGruntRunning.atlas",
"images/xenoGrunt.atlas",
"images/mobs/robot.atlas",
"images/mobs/rangeBossRight.atlas",
"images/towers/DroidTower.atlas",
"images/mobs/robot.atlas",
"images/mobs/rangeBossRight.atlas",
"images/towers/TNTTower.atlas",
"images/projectiles/basic_projectile.atlas",
"images/projectiles/bossProjectile.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/engineer_projectile.atlas",
"images/projectiles/mobKing_projectile.atlas",
"images/projectiles/snow_ball.atlas",
"images/projectiles/pierce_anim.atlas",
"images/projectiles/burn_effect.atlas",
"images/projectiles/firework_anim.atlas",
"images/projectiles/mobProjectile.atlas",
"images/projectiles/stun_effect.atlas"
};
private static final String[] forestSounds = {
"sounds/Impact4.ogg",
"sounds/economy/click.wav",
"sounds/economy/click_1.wav",
"sounds/towers/gun_shot_trimmed.mp3",
"sounds/towers/deploy.mp3",
"sounds/towers/stow.mp3",
"sounds/engineers/firing_auto.mp3",
"sounds/engineers/firing_single.mp3",
"sounds/projectiles/on_collision.mp3",
"sounds/projectiles/explosion.mp3"
};
private static final String backgroundMusic = "sounds/background/Sci-Fi1.ogg";
private static final String[] forestMusic = {backgroundMusic};


private final TerrainFactory terrainFactory;

private Entity player;
Expand All @@ -181,6 +73,9 @@ public ForestGameArea(TerrainFactory terrainFactory) {
super();
this.terrainFactory = terrainFactory;
}
public void setAssetLoader(AssetLoader assetLoader) {
this.assetLoader = assetLoader;
}

// Add this method to start the wave spawning timer when the game starts.
private void startWaveTimer() {
Expand Down Expand Up @@ -227,7 +122,7 @@ private void spawnWave() {
@Override
public void create() {
// Load game assets
loadAssets();
loadAllAssets();
displayUI();
spawnTerrain();

Expand Down Expand Up @@ -654,27 +549,15 @@ private void playMusic() {
music.play();
}

private void loadAssets() {
logger.debug("Loading assets");
ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.loadTextures(forestTextures);
resourceService.loadTextureAtlases(forestTextureAtlases);
resourceService.loadSounds(forestSounds);
resourceService.loadMusic(forestMusic);

while (!resourceService.loadForMillis(10)) {
// This could be upgraded to a loading screen
logger.info("Loading... {}%", resourceService.getProgress());
}
}



private void unloadAssets() {
logger.debug("Unloading assets");
ResourceService resourceService = ServiceLocator.getResourceService();
resourceService.unloadAssets(forestTextures);
resourceService.unloadAssets(forestTextureAtlases);
resourceService.unloadAssets(forestSounds);
resourceService.unloadAssets(forestMusic);
if (assetLoader != null) {
AssetLoader.unloadAllAssets(); // Use the AssetLoader to unload assets if it's not null
} else {
logger.error("AssetLoader is not set. Cannot unload assets.");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void create() {
for (int i = 0; i < 2; i++) {
// Use "building1" for the first tower and "building2" for the second tower
skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("building1", new Texture("images/towers/WallTower.png"));
skin.add("building1", new Texture("images/towers/wallTower.png"));
// Load textures for building1 and building2
towers1[i] = new Image(skin, "building1");
towers1[i].setBounds(Gdx.graphics.getWidth() * 40f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
Expand Down Expand Up @@ -142,7 +142,7 @@ public void touchUp(InputEvent event, float x, float y, int pointer, int button)
for (int i = 0; i < 2; i++) {
// Use "building1" for the first tower and "building2" for the second tower
skin.add("default", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
skin.add("building2", new Texture("images/towers/WallTower.png"));
skin.add("building2", new Texture("images/towers/wallTower.png"));
towers2[i] = new Image(skin, "building2");
towers2[i].setBounds(Gdx.graphics.getWidth() * 50f / 100f, Gdx.graphics.getHeight() * 80f / 100f, 100, 100);
stage.addActor(towers2[i]);
Expand Down
Loading

0 comments on commit 936452a

Please sign in to comment.