Skip to content

Multiple Maps Explanation

EvansH1997 edited this page Oct 18, 2021 · 30 revisions

Overview

In sprint 3 we decided to add the multiple maps feature to the game to improve the game playability. We decided to add a portal after winning the spaceship in order to provide an entrance to the bonus map. In the bonus map, there will be no monsters and player are free to collect more and more gold before hitting the exit portal. Background image for the bonus map is here. BGM for the bonus map is here.

Code implementation

Rock road

Under the com/deco2800/game/areas/terrain/TerrainFactory.java file, we added a new terrainType ROCK_ROAD:

   case ROCK_ROAD:
     TextureRegion rockRoad =
         new TextureRegion(resourceService.getAsset("images/rock.jpg", Texture.class));
     return createRockRoadTerrain(1, rockRoad);

In order to create rock road terrain and tiles, two private functions have been created:

   private TerrainComponent createRockRoadTerrain(float tileWorldSize, TextureRegion road) {
    GridPoint2 tilePixelSize = new GridPoint2(road.getRegionWidth(), road.getRegionHeight());
    TiledMap tiledMap = createRockRoadTiles(tilePixelSize, road);
    TiledMapRenderer renderer = createRenderer(tiledMap, tileWorldSize / tilePixelSize.x);
    return new TerrainComponent(camera, tiledMap, renderer, orientation, tileWorldSize);
   }

   private TiledMap createRockRoadTiles(GridPoint2 tileSize, TextureRegion road) {
    TiledMap tiledMap = new TiledMap();
    TerrainTile grassTile = new TerrainTile(road);
    TiledMapTileLayer newLayer = new TiledMapTileLayer(MAP_SIZE.x, MAP_SIZE.y + 47, tileSize.x, tileSize.y);
    fillTiles(newLayer, MAP_SIZE, grassTile, 49);
    tiledMap.getLayers().add(newLayer);
    return tiledMap;
   }

After that, we added one parameter int vertical into fillTiles() function, so that the tiles can be filled in the given vertical height. Based on the above code, some public functions have been created in order to be called under com/deco2800/game/screens/MainGameScreen.java to realize the scrolling terrain:

   switch (newMapStatus) {
     case Off:
         ...
     case On:
         // Render terrains on new map
         if (screenVector.x > (2 * counter + 1) * 10) {
             counter += 1;
             forestGameArea.spawnTerrainRandomly((int) (screenVector.x + 2), TerrainFactory.TerrainType.ROCK_ROAD);
         }

Background image

In order to draw image on certain vertical height. We added an global variable private float vertical = 0; into com/deco2800/game/rendering/BackgroundRenderComponent.java, and created a public function to manually adjust the height of background:

    /**
     * Set the vertical start point for the background texture
     * @param y vertical value
     */
    public void setVertical(float y) {
        vertical = y;
    }
   
    @Override
    public void draw(SpriteBatch batch) {
        batch.draw(texture, -30, 0, 30, 15);
        batch.draw(texture, horizontal, 0, 30, 15);
        batch.draw(texture, -30, vertical, 30, 15);
        batch.draw(texture, horizontal, vertical, 30, 15);
    }

After that, under com/deco2800/game/areas/ForestGameArea.java, we created the following function to show new map scrolling background image on given height:

    public void showNewMapScrollingBackground(int counter, float vertical) {
        Entity gameBg = new Entity();
        BackgroundRenderComponent newBg = new BackgroundRenderComponent("images/background_2.png");
        newBg.setHorizontal(30f * counter);
        newBg.setVertical(vertical);
        gameBg.addComponent(newBg);
        spawnEntity(gameBg);
    }

Last but not least, call showNewMapScrollingBackground and set its vertical parameter according to the player current position under com/deco2800/game/screens/MainGameScreen.java.

Switch BGM

Under com/deco2800/game/areas/ForestGameArea.java, created four public functions, which can be called to play or stop corresponding BGM from other class.

    public void playMusic() {
        Music music = ServiceLocator.getResourceService().getAsset(BACKGROUNDMUSIC, Music.class);
        music.setLooping(true);
        music.setVolume(0.3f);
        music.play();
    }

    public void playNewMapMusic() {
        Music newMusic = ServiceLocator.getResourceService().getAsset(NEWMAP_BACKGROUNDMUSIC, Music.class);
        newMusic.setLooping(true);
        newMusic.setVolume(0.3f);
        newMusic.play();
    }

    public void stopMusic() {
        ServiceLocator.getResourceService().getAsset(BACKGROUNDMUSIC, Music.class).stop();
    }

    public void stopNewMapMusic() {
        ServiceLocator.getResourceService().getAsset(NEWMAP_BACKGROUNDMUSIC, Music.class).stop();
    }

After creating above functions, we can call these functions under com/deco2800/game/screens/MainGameScreen.java to realize switching BGM between regular map and bonus map.

        switch (newMapStatus) {
            case Off:
                forestGameArea.stopNewMapMusic();
                forestGameArea.playMusic();
                ...
            case On:
                forestGameArea.stopMusic();
                forestGameArea.playNewMapMusic();
                ...

Rocks and woods piling up

Overview

In "sprint 3" we decided to arrange various shapes of obstacles such as pyramids, lines, columns, etc. Here are examples of obstacles:

rock pyramid type 1

rock column

Code implementation

Line of rock flying in the air

 Create the game "rock" obstacle
 A row of 5 rocks in a straight line suspended in the air
 At coordinates y= 50, the rocks will be on the ground, so at position y=55, the rocks will appear in the air and become an obstacle when the character moves.
 Create a loop to create x-coordinates for 5 consecutive stones standing next to each other.
 The spawnRocksone function will be called at MainGameScreen.java and will appear when switching to a new map.
 "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
   public void spawnRocksone(int xValue) {

    for (int i = 0; i < 5; i++) {

        GridPoint2 pos = new GridPoint2(xValue + 2 +i, 55);
        Entity rock = ObstacleFactory.createRock();
        spawnEntityAt(rock, pos, true, false);

Create rock pyramid type 1

 Create the game "rock" obstacle
 Form a rocks pyramid with six rocks stacked on top of each other, a total of 6 rocks needed
 Since the pyramid consists of three floors from the ground, the y coordinate of the rocks will be from 50 to 52, since y=50 the co-ordinate of the rocks will be on the ground
 The x coordinate will depend on the location of the rocks.
 The spawnRockstwo function will be called at MainGameScreen.java and will appear when switching to a new map.
 "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
public void spawnRockstwo(int xValue) {


        GridPoint2 Pos = new GridPoint2 ( xValue + 10, 50);
        Entity rock = ObstacleFactory.createRock();
        spawnEntityAt(rock, Pos, true, false);
        GridPoint2 PosTwo = new GridPoint2 ( xValue + 11, 51);
        Entity rockTwo = ObstacleFactory.createRock();
        spawnEntityAt(rockTwo, PosTwo, true, false);
        GridPoint2 PosThree = new GridPoint2 ( xValue + 12, 52);
        Entity rockThree = ObstacleFactory.createRock();
        spawnEntityAt(rockThree, PosThree, true, false);
        GridPoint2 PosFour = new GridPoint2 ( xValue + 12, 51);
        Entity rockFour = ObstacleFactory.createRock();
        spawnEntityAt(rockFour, PosFour, true, false);
        GridPoint2 PosFive = new GridPoint2 ( xValue + 12, 50);
        Entity rockFive = ObstacleFactory.createRock();
        spawnEntityAt(rockFive, PosFive, true, false);
        GridPoint2 PosSix = new GridPoint2 ( xValue + 11, 50);
        Entity rockSix = ObstacleFactory.createRock();
        spawnEntityAt(rockSix, PosSix, true, false);


}

Create rock pyramid type 2

 Create the game "rock" obstacle
 Form a rocks pyramid with six rocks stacked on top of each other, a total of 6 rocks needed
 Since the pyramid consists of three floors from the ground, the y coordinate of the rocks will be from 50 to 52, since y=50 the co-ordinate of the rocks will be on the ground
 The x coordinate will depend on the location of the rocks.
 The spawnRocksthree function will be called at MainGameScreen.java and will appear when switching to a new map.
 "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
public void spawnRocksthree(int xValue) {


        GridPoint2 Pos = new GridPoint2 ( xValue + 14, 52);
        Entity rock = ObstacleFactory.createRock();
        spawnEntityAt(rock, Pos, true, false);
        GridPoint2 PosTwo = new GridPoint2 ( xValue + 14, 51);
        Entity rockTwo = ObstacleFactory.createRock();
        spawnEntityAt(rockTwo, PosTwo, true, false);
        GridPoint2 PosThree = new GridPoint2 ( xValue + 14, 50);
        Entity rockThree = ObstacleFactory.createRock();
        spawnEntityAt(rockThree, PosThree, true, false);
        GridPoint2 PosFour = new GridPoint2 ( xValue + 15, 51);
        Entity rockFour = ObstacleFactory.createRock();
        spawnEntityAt(rockFour, PosFour, true, false);
        GridPoint2 PosFive = new GridPoint2 ( xValue + 15, 50);
        Entity rockFive = ObstacleFactory.createRock();
        spawnEntityAt(rockFive, PosFive, true, false);
        GridPoint2 PosSix = new GridPoint2 ( xValue + 16, 50);
        Entity rockSix = ObstacleFactory.createRock();
        spawnEntityAt(rockSix, PosSix, true, false);


    }

Create rock rocks collum from the ground up

   Arow of 5 rocks in a straight line suspended in the air
   Since it is a column, the x coordinate will stay the same, so we set x=18
   Loop the y coordinate to form 5 rock stacked on top of each other forming a straight column, with y= 50 rock will be on the ground facing up
   The spawnRocksfour function will be called at MainGameScreen.java and will appear when switching to a new map.
   "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
public void spawnRocksfour(int xValue) {

        for (int i = 0; i < 5; i++) {

            GridPoint2 pos = new GridPoint2(xValue + 18, 50+i);
            Entity rock = ObstacleFactory.createRock();
            spawnEntityAt(rock, pos, true, false);

        }
    }

Create rocks collum from the sky down

 Create the game "rock" obstacle
 A row of 5 rocks in a straight line suspended in the air
 Since it is a column, the x coordinate will stay the same, so we set x=20
 Loop the y coordinate to form 5 rock stacked on top of each other forming a straight column, with y start from 57
 The spawnRocksfive function will be called at MainGameScreen.java and will appear when switching to a new map.
 "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
public void spawnRocksfive(int xValue) {

        for (int i = 0; i < 4; i++) {

            GridPoint2 pos = new GridPoint2(xValue + 20, 57+i);
            Entity rock = ObstacleFactory.createRock();
            spawnEntityAt(rock, pos, true, false);

        }
    }

Create large rock pyramid

 Create the game "rock" obstacle
 Form a rocks larger pyramid with ten rocks stacked on top of each other, a total of 6 rocks needed
 Since the pyramid consists of four floors from the ground, the y coordinate of the rocks will be from 50 to 53, since y=50 the co-ordinate of the rocks will be on the ground
 The x coordinate will depend on the location of the rocks.
 The spawnRocksssixfunction will be called at MainGameScreen.java and will appear when switching to a new map.
 "spawnEntityAt" function helps us choose the coordinate position of the center of the rock, from there using rock.png and will scale the size of the rock horizontally and vertically.
  public void spawnRockssix(int xValue) {

        GridPoint2 Pos = new GridPoint2 ( xValue + 22, 53);
        Entity rock = ObstacleFactory.createRock();
        spawnEntityAt(rock, Pos, true, false);
        GridPoint2 PosTwo = new GridPoint2 ( xValue + 22, 52);
        Entity rockTwo = ObstacleFactory.createRock();
        spawnEntityAt(rockTwo, PosTwo, true, false);
        GridPoint2 PosThree = new GridPoint2 ( xValue + 22, 51);
        Entity rockThree = ObstacleFactory.createRock();
        spawnEntityAt(rockThree, PosThree, true, false);
        GridPoint2 PosFour = new GridPoint2 ( xValue + 22, 50);
        Entity rockFour = ObstacleFactory.createRock();
        spawnEntityAt(rockFour, PosFour, true, false);
        GridPoint2 PosFive = new GridPoint2 ( xValue + 23, 52);
        Entity rockFive = ObstacleFactory.createRock();
        spawnEntityAt(rockFive, PosFive, true, false);
        GridPoint2 PosSix = new GridPoint2 ( xValue + 23, 51);
        Entity rockSix = ObstacleFactory.createRock();
        spawnEntityAt(rockSix, PosSix, true, false);
        GridPoint2 PosSeven = new GridPoint2 ( xValue + 23, 50);
        Entity rockSeven = ObstacleFactory.createRock();
        spawnEntityAt(rockSeven, PosSeven, true, false);
        GridPoint2 PosEight = new GridPoint2 ( xValue + 24, 51);
        Entity rockEight = ObstacleFactory.createRock();
        spawnEntityAt(rockEight, PosEight, true, false);
        GridPoint2 PosNine = new GridPoint2 ( xValue + 24, 50);
        Entity rockNine = ObstacleFactory.createRock();
        spawnEntityAt(rockNine, PosNine, true, false);
        GridPoint2 PosTen = new GridPoint2 ( xValue + 25, 50);
        Entity rockTen = ObstacleFactory.createRock();
        spawnEntityAt(rockTen, PosTen, true, false);


    }

UML diagram

Overview

Overview image

BackgroundRenderComponent & MainGameScreen

MainGameScreen

ForestGameArea

ForestGameArea

Sequence diagram

ForestGameArea_spawnWoods()

ForestGameArea_spawnWoods()

ForestGameArea_spawnRocksone (Generate line 5 rocks in the new map)

ForestGameArea_spawnRocksone

ForestGameArea_showNewMapBackground

ForestGameArea_showNewMapBackground

ForestGameArea_spawnInvisibleCeiling

ForestGameArea_spawnInvisibleCeiling

ForestGameArea_spawnGoldNewMap

ForestGameArea_spawnGoldNewMap

ForestGameArea_playNewMapMusic

ForestGameArea_playNewMapMusic

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