Skip to content

Sprint 3 Main Character New Unlockable Attires and Functionality improvement

Prateek Kr. Gupta edited this page Oct 5, 2021 · 19 revisions

Contents

Automatic Item PickUp Implementation

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.

PlayerFactory.java

    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);
           }
        }
    }

Buff Debuffs Animation Integration

As the player Jason interacts progress in the game, it will experience buffs and debuffs from interacting with the obstacles and items.

Buffs And Debuffs Map

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;
        }
    }
  ...

Unlockable Attires

Texture Atlas

Buff/Debuff Atlas

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:

  1. Dizzy (facing right, animated)
  2. Hungry (facing right, animated)
  3. Poisoned (facing right, animated)
  4. Health Down (facing right, animated)
  5. Speed Down (facing right, animated)
  6. Thirsty (facing right, animated)
  7. Recovered (facing right, animated)
  8. Health UP (facing right, animated)
  9. Health Limit Up (facing right, animated)

Atlas Files

For OG Attire : mpcAnimation.atlas

For Gold_4 Attire : mpcAnimation_4.atlas

For Gold_6 Attire : mpcAnimation_6.atlas

Generated Texture pack

The bellow image file shows the atlas image for Gold_6 attire.

mpcAnimation.png mpcAnimation.png

Testing

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");
    }
}

UML Diagrams

Class Diagram

Sequence Diagrams

Relevant Files

PlayerFactory.java

PlayerAnimationController.java

PlayerAnimationRenderTest.java

ItemComponent.java

mpcAnimation.atlas

mpcAnimation_4.atlas

mpcAnimation_6.atlas

mpcAnimation.png

mpcAnimation_4.png

mpcAnimation_6.png

Gameplay

Home

Main Character

πŸ‘Ύ Obstacle/Enemy

Food & Water

Pickable Items

Game achievements

Game Design

Emotional Goals

Game Story

Influences

Style

Pixel Grid Resolution

Camera Angle and The Player's Perspective

Features Design

Achievements Screen

Achievements Trophies and Cards

Music Selection GUI

πŸ‘Ύ Obstacle/Enemy

 Monster Manual
 Obstacles/Enemies
  - Alien Plants
  - Variation thorns
  - Falling Meteorites
  - FaceHugger
  - AlienMonkey
 Spaceship & Map Entry
 Particle effect

Buffs

Debuffs

Buffs and Debuffs manual

Game Instruction

[code for debuff animations](code for debuff animations)

Infinite loop game system

Main Menu Screen

New Setting Screen

Hunger and Thirst

Goals and Objectives

HUD User Interface

Inventory System

Item Bar System

Scoring System

Props store

BGM design

Sound Effect design

Main game interface

Invisible ceiling

New terrain sprint 4

New game over screen sprint 4

Code Guidelines

Main Character Movement, Interactions and Animations - Code Guidelines

Item Pickup

ItemBar & Recycle system

Main Menu Button Code

Game Instructions Code

πŸ‘Ύ Obstacle/Enemy

 Obstacle/Enemy
 Monster Manual
 Spaceship Boss
 Particle effects
 Other Related Code
 UML & Sequence diagram of enemies/obstacles

Scoring System Implementation Explanation

Music Implementation

Buff and Debuff Implementation

Score History Display

code improvement explanation

Infinite generating terrains Implementation Explanation

Game Over Screen and functions explaination

Buffer timer before game start

Scrolling background

Multiple Maps

Invisible ceiling

Rocks and woods layout optimization

Magma and nails code implementation

Background Music Selection

Chooser GUI Implementation

Chooser GUI Logic Persistence

Guide: Adding Background music for a particular screen

Achievements Ecosystem - Code Guidelines

Achievements System

Achievements Screen

Adding Achievements (Guide)

Game Records

DateTimeUtils

History Scoreboard - Score Details

Listening for important events in the Achievements ecosystem

Food and Water System

Food System Water System

Hunger and Thirst icon code guidelines

Asset Creation

In Game Background Music

User Testing

Hunger and Thirst User Testing

Main Character Testing

Buffs and Debuffs Testing

Buff and Debuff Manual User Testing

Game Instruction User Testing

The Main Menu User Test

The New Button User Test in Setting Page

The Main Menu Buttons User Testing

Hunger and Thirst User Test

Infinite loop game and Terrain Testing

Item Bar System Testing

Randomised Item Drops

Recycle System Testing

Scoring System Testing

Music User test

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

Inventory system UI layout

Props store user testing

Achievements User Testing

Sprint 1

Sprint 2

Sprint 3

Sprint 4

Items testing

Player Status testing

Changeable background & Buffer time testing

Main game interface test

Invisible ceiling test

Game over screen test sprint 4

New terrain textures on bonus map test sprint 4

Buying Props User Testing

Testing

Hunger and Thirst Testing

Main Character Player

Achievements System, Game Records and Unlockable Chapters

DateTimeUtils Testing

Scoring System Testing Plan

Distance Display Testing Plan

Musics Implementation Testing plan

History Board Testing plan

Rocks and woods testing plan

Sprint 4 terrain tests

Items

Item Bar System Testing Plan

Recycle System Testing Plan

Game Engine

Game Engine Help

Getting Started

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