Magma and nails code implementation - UQdeco2800/2021-ext-studio-2 GitHub Wiki

Overview

New terrains contain Magma and nails which base attack are 10 and 5 respectively. The magma and nails will only appear on the bonus level.

Code implementation

Create line of 5 Nail in the sky

 Create the game "nail" obstacle
 A row of 5 nails in a straight line suspended in the air
 The spawnNailsone 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 nail, from there using nail.png and will scale the size of the rock horizontally and vertically.

Same goes with spawnNailstwo, spawnNailsthree,spawnNailsfour,..

public void spawnNailsone(int xValue) {

        for (int i = 0; i < 5; i++) {
            GridPoint2 pos = new GridPoint2(xValue +i, 60);
            Entity nail = ObstacleFactory.createNail(player);
            spawnEntityAt(nail, pos, true, false);
        }
    }

Create line of 5 Magma in the sky

 Create the game "Magma" obstacle
 A row of 5 Magmas in a straight line suspended in the air
 The spawnFireRocksone 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 Magma, from there using firerock.png and will scale the size of the rock horizontally and vertically.

Same goes with spawnFireRockstwo

public void spawnMagmaOne(int xValue) {

        for (int i = 0; i < 5; i++) {
            GridPoint2 pos = new GridPoint2(xValue + -4 +i, 50);
            Entity frock = ObstacleFactory.createMagma(player);
            spawnEntityAt(frock, pos, true, false);

        }
    }

Create large Magma pyramid

 Create the game "Magma" 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 magmas will be on the ground
 The x coordinate will depend on the location of the Magmas.
 The spawnFireRockstwofunction 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 magmas, from there using rock.png and will scale the size of the rock horizontally and vertically.
  public void spawnMagmaTwo(int xValue) {

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


    }

UML sequence diagram

  • ObstacleFactory.java_createNail

createNail

  • ForestGameArea.java_spawnMagmaOne

spawnMagmaone