-
Notifications
You must be signed in to change notification settings - Fork 4
Sprint 3 Main Character New Unlockable Attires and Functionality improvement
- Automatic Item PickUp Implementation
- Buff Debuffs Animation Integration
- Unlockable Attires
- Texture Atlas
- Testing
- UML Diagrams
- Relevant Files
When the main player - Jason collides with an item, Jason will automatically pick up the item. With this feature, the user has no need to press a key to initiate item pickup.
switch (attire) {
...
case "OG":
default:
mpcAnimator = createAnimationComponent("images/mpc/finalAtlas/OG/mpcAnimation.atlas");
mpcTexture = new TextureRenderComponent("images/mpc/finalAtlas/OG/mpc_right.png");
break;
}
...
mpcAnimator.addAnimation("main_player_pickup",0.125f,Animation.PlayMode.LOOP);
Automatic Item Pick Up animation is triggered from ItemComponent.java
After 1s the animation is stopped.
private void onCollisionStart(Fixture me, Fixture other){
if (PhysicsLayer.contains(PhysicsLayer.PLAYER, other.getFilterData().categoryBits)) {
// checking if the collision is done with the player
callback.accept(target);
target.getEvents().trigger("itemPickUp");
entity.getEvents().trigger("itemPickedUp");
...
try {
...
// after 1s stop the item pickUp animation
Timer timer=new Timer();
timer.scheduleTask(new Timer.Task() {
@Override
public void run() {
target.getEvents().trigger("stopPickUp");
timer.stop();
}
},1);
}
catch (Exception e){
System.out.print(e);
}
}
}
As the player Jason interacts progress in the game, it will experience buffs and debuffs from interacting with the obstacles and items.
Buff/ Debuff | Type |
---|---|
Hungry | Debuff |
Poisoned | Debuff |
Dizzy | Debuff |
Health Down | Debuff |
Health Limit UP | Debuff |
Speed Down | Debuff |
Thirsty | Debuff |
Recovered | Buff |
Health Up | Buff |
PlayerFactory.java adds the animation for those buffs and debuffs
These buffs/Debuffs are added for each movement animation.
...
mpcAnimator.addAnimation("main_player_run_dizzy", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_health-down", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_health-limit-up", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_health-up", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_hungry", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_poisoned", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_recovered", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_speed-down", 0.1f, Animation.PlayMode.LOOP);
mpcAnimator.addAnimation("main_player_run_thirsty", 0.1f, Animation.PlayMode.LOOP);
...
The listeners implemented here lookout for trigger events and run the corresponding functions in PlayerAnimationController.java. These functions are discussed in detail in the following sections of the wiki.
...
public void create() {
super.create();
animator = this.entity.getComponent(AnimationRenderComponent.class);
...
entity.getEvents().addListener("hungry", this::animateHungry);
entity.getEvents().addListener("poisoned", this::animatePoison);
entity.getEvents().addListener("healthDown", this::animateHealthDown);
entity.getEvents().addListener("dizzy", this::animateDizzy);
entity.getEvents().addListener("health_limit_up", this::animateHealthLimit);
entity.getEvents().addListener("healthUp", this::animateHealthUP);
entity.getEvents().addListener("recovered", this::animateRecovered);
entity.getEvents().addListener("speedDown", this::animateSpeedDown);
entity.getEvents().addListener("thirsty", this::animateThirsty);
entity.getEvents().addListener("stopBuffDebuff", this::animateWalk);
}
...
Each time an animation event is triggered, a function is used to start the animation for the buff/debuff while taking into account the previous animation that was running and runs an animation for buff/debuff corresponding to that animation.
...
/**
* Activate the hungry animation debuff
*/
private void animateHungry() {
animationName = animator.getCurrentAnimation();
preAnimationCleanUp();
switch (animationName) {
case "main_player_run":
animator.startAnimation("main_player_run_hungry");
break;
case "main_player_pickup":
animator.startAnimation("main_player_pickup_hungry");
break;
case "main_player_jump":
animator.startAnimation("main_player_jump_hungry");
break;
case "main_player_attack":
animator.startAnimation("main_player_attack_hungry");
break;
case "main_player_crouch":
animator.startAnimation("main_player_crouch_hungry");
break;
case "main_player_right":
animator.startAnimation("main_player_right_hungry");
break;
case "main_player_walk":
default:
animator.startAnimation("main_player_walk_hungry");
break;
}
}
...
A new screen for selecting unlocked attires was created and the Select Unlocked Attires Button was included in the game main menu.
Number of Gold Achievements | Attire Unlocked |
---|---|
0 | Original |
2 | gold_2 |
4 | gold_4 |
6 | gold_6 |
For the different attires, we have the same atlas in terms of creating buffs/ debuffs animation and was generated using a texture packer. The atlas has player buff representations for all the movements (explained in Sprint 2 Documentation )in the following states:
- Dizzy (facing right, animated)
- Hungry (facing right, animated)
- Poisoned (facing right, animated)
- Health Down (facing right, animated)
- Speed Down (facing right, animated)
- Thirsty (facing right, animated)
- Recovered (facing right, animated)
- Health UP (facing right, animated)
- Health Limit Up (facing right, animated)
For OG Attire : mpcAnimation.atlas
For Gold_4 Attire : mpcAnimation_4.atlas
For Gold_6 Attire : mpcAnimation_6.atlas
The bellow image file shows the atlas image for Gold_6 attire.
Considering it is hard to test whether an animation plays because of its visual nature, unit tests were written to verify and validate that when an animation event is triggered the corresponding movement animation is triggered. The tests check that all the expected animations actually are rendered when their respective events are triggered.
PlayerAnimationRenderTest.java
@ExtendWith(GameExtension.class)
class PlayerAnimationRenderTest {
private Entity player;
private AnimationRenderComponent animator;
@BeforeEach
void beforeEach() {
ServiceLocator.registerPhysicsService(new PhysicsService());
player = new Entity()
.addComponent(new PhysicsComponent())
.addComponent(new PlayerAnimationController());
animator = mock(AnimationRenderComponent.class);
player.addComponent(animator);
PlayerAnimationController animationController =
player.getComponent(PlayerAnimationController.class);
animationController.setTexturePresent(false);
player.create();
}
@Test
void shouldTriggerRightMovement() {
player.getEvents().trigger("walkRight");
verify(animator).startAnimation("main_player_run");
}
@Test
void shouldTriggerWalkMovement() {
player.getEvents().trigger("startMPCAnimation");
verify(animator).startAnimation("main_player_walk");
}
@Test
void shouldTriggerJumpMovement() {
player.getEvents().trigger("jump");
verify(animator).startAnimation("main_player_jump");
}
@Test
void shouldTriggerCrouchMovement() {
player.getEvents().trigger("crouch");
verify(animator).startAnimation("main_player_crouch");
}
@Test
void shouldTriggerItemPickUpMovement() {
player.getEvents().trigger("itemPickUp");
verify(animator).startAnimation("main_player_pickup");
}
@Test
void shouldTriggerAttackMovement() {
player.getEvents().trigger("attack");
verify(animator).startAnimation("main_player_attack");
}
}
UnlockedAttiresDisplay
UnlockedAttiresScreen
PlayerAnimationController
AnimatorComponent
ItemComponent
MPCConfig
UnlockedAttiresScreen_createUI()
renderZeroUnlockedAttiresTable()
renderUnlockedAttires()
renderOriginalAttire()
UnlockedAttiresDisplay
lessThanFour()
lessThanSix()
moreThanSix()
confirmSelection()
MPCConfig_updateValues()
ItemComponent_onCollisionStart()
PlayerAnimationController.java
Camera Angle and The Player's Perspective
Achievements Trophies and Cards
πΎ Obstacle/Enemy
βMonster Manual
βObstacles/Enemies
ββ- Alien Plants
ββ- Variation thorns
ββ- Falling Meteorites
ββ- FaceHugger
ββ- AlienMonkey
βSpaceship & Map Entry
βParticle effect
[code for debuff animations](code for debuff animations)
Main Character Movement, Interactions and Animations - Code Guidelines
ItemBar & Recycle system
πΎ Obstacle/Enemy
βObstacle/Enemy
βMonster Manual
βSpaceship Boss
βParticle effects
βOther Related Code
βUML & Sequence diagram of enemies/obstacles
Scoring System Implementation Explanation
Buff and Debuff Implementation
Infinite generating terrains Implementation Explanation
Game Over Screen and functions explaination
Buffer timer before game start
Rocks and woods layout optimization
Magma and nails code implementation
Guide: Adding Background music for a particular screen
History Scoreboard - Score Details
Listening for important events in the Achievements ecosystem
Hunger and Thirst icon code guidelines
Hunger and Thirst User Testing
Buff and Debuff Manual User Testing
The New Button User Test in Setting Page
The Main Menu Buttons User Testing
Infinite loop game and Terrain Testing
https://github.com/UQdeco2800/2021-ext-studio-2.wiki.git
πΎ Obstacle/Enemy
βObstacle testing
ββ- Alien Plants & Variation Thorns
ββ- Falling Meteorites
βEnemy testing
ββ- Alien Monkeys & Facehugger
ββ- Spaceship Boss
βMonster Manual
βParticle-effect
βPlayer attack testing
ββ- Player Attack
Sprint 1
Sprint 2
Sprint 3
Sprint 4
Changeable background & Buffer time testing
Game over screen test sprint 4
New terrain textures on bonus map test sprint 4
Achievements System, Game Records and Unlockable Chapters
Musics Implementation Testing plan