Skip to content

Commit

Permalink
Changed the astronaut NPC completely
Browse files Browse the repository at this point in the history
  • Loading branch information
neil-nb committed Oct 19, 2023
1 parent 5381eb8 commit ef46696
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 38 deletions.
7 changes: 7 additions & 0 deletions source/core/assets/images/npc/Astronaut.atlas
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,10 @@ Astro_Right
orig: 32, 32
offset: 0, 0
index: -1
Astro_Stand
rotate: false
xy: 256, 0
size: 32, 32
orig: 32, 32
offset: 0, 0
index: -1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"entities": [
{
"class": "com.csse3200.game.entities.configs.AstronautConfig",
"spritePath": "images/npc/astronaut_npc.atlas",
"spritePath": "images/npc/Astronaut.atlas",
"position" : {
"x": 15,
"y": 38
Expand Down
2 changes: 2 additions & 0 deletions source/core/assets/levels/cryoheim/main_area/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"map/heatzone.png",
"particle-effects/explosion/particle.png",
"images/npc/astronaut_npc.png",
"images/npc/Astronaut.png",
"images/space_navigation_planet_2.png","images/upgradetree/sword.png"
],
"textureAtlasPaths": [
Expand All @@ -35,6 +36,7 @@
"images/boss_enemy.atlas",
"images/botanist.atlas",
"images/weapons/wrench.atlas",
"images/npc/Astronaut.atlas",
"images/npc/astronaut_npc.atlas",
"images/botanist.atlas"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"entities": [
{
"class": "com.csse3200.game.entities.configs.AstronautConfig",
"spritePath": "images/npc/astronaut_npc.atlas",
"spritePath": "images/npc/Astronaut.atlas",
"position" : {
"x": 13,
"y": 40
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void create() {
animator = entity.getComponent(AnimationRenderComponent.class);

// Start with the default animation.
animator.startAnimation("row-1-column-1");
animator.startAnimation("Astro_Stand");
}

@Override
Expand All @@ -48,25 +48,11 @@ public void update() {

// Switch between animations.
switch (animator.getCurrentAnimation()) {
case "row-1-column-1" -> animator.startAnimation("row-1-column-2");
case "row-1-column-2" -> animator.startAnimation("row-1-column-3");
case "row-1-column-3" -> animator.startAnimation("row-1-column-4");
case "row-1-column-4" -> animator.startAnimation("row-2-column-1");
case "row-2-column-1" -> animator.startAnimation("row-2-column-2");
case "row-2-column-2" -> animator.startAnimation("row-2-column-3");
case "row-2-column-3" -> animator.startAnimation("row-2-column-4");
case "row-2-column-4" -> animator.startAnimation("row-3-column-1");
case "row-3-column-1" -> animator.startAnimation("row-3-column-2");
case "row-3-column-2" -> animator.startAnimation("row-3-column-3");
case "row-3-column-3" -> animator.startAnimation("row-3-column-4");
case "row-3-column-4" -> animator.startAnimation("row-4-column-1");
case "row-4-column-1" -> animator.startAnimation("row-4-column-2");
case "row-4-column-2" -> animator.startAnimation("row-4-column-3");
case "row-4-column-3" -> animator.startAnimation("row-4-column-4");
case "row-4-column-4" -> animator.startAnimation("row-1-column-1");
case "Astro_Left" -> animator.startAnimation("Astro_Left");
case "Astro_Right" -> animator.startAnimation("Astro_Right");
default ->
// Default to the bottom animation if not in any specific state.
animator.startAnimation("row-1-column-1");
animator.startAnimation("Astro_Stand");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,23 +235,10 @@ public static Entity createAstronaut(AstronautConfig astronautConfig) {
AnimationRenderComponent animator =
new AnimationRenderComponent(
ServiceLocator.getResourceService().getAsset(astronautConfig.spritePath, TextureAtlas.class));
animator.addAnimation("row-1-column-1", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-1-column-2", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-1-column-3", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-1-column-4", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-2-column-1", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-2-column-2", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-2-column-3", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-2-column-4", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-3-column-1", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-3-column-2", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-3-column-3", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-3-column-4", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-4-column-1", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-4-column-2", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-4-column-3", 0.01f, Animation.PlayMode.LOOP);
animator.addAnimation("row-4-column-4", 0.01f, Animation.PlayMode.LOOP);

animator.addAnimation("Astro_Stand", 1f, Animation.PlayMode.NORMAL);
animator.addAnimation("Astro_Down", 1f, Animation.PlayMode.LOOP);
animator.addAnimation("Astro_Left", 1f, Animation.PlayMode.LOOP);
animator.addAnimation("Astro_Right", 1f, Animation.PlayMode.LOOP);

Entity astronaut =
new Entity()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class AstronautAnimationControllerTest {
void setUp() {
MockitoAnnotations.openMocks(this);

when(assetManager.get("images/npc/astronaut_npc.atlas")).thenReturn(atlas);
// when(assetManager.get("images/npc/astronaut_npc.atlas")).thenReturn(atlas);
when(assetManager.get("images/npc/Astronaut.atlas")).thenReturn(atlas);

controller = new AstronautAnimationController();

Expand Down

0 comments on commit ef46696

Please sign in to comment.