Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team 6 new obstacle #403

Merged
merged 3 commits into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added source/core/assets/images/firerock.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/firerock.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/nail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/core/assets/images/nail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 119 additions & 9 deletions source/core/src/main/com/deco2800/game/areas/ForestGameArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,113 @@ public class ForestGameArea extends GameArea {
// }
// }

// nail

//public void spawnNailsRandomly(int xValue) {
// for (int i = 0; i < 5; i++) {
// GridPoint2 pos = new GridPoint2(xValue + 2 +i, 53);
// Entity rock = ObstacleFactory.createNail();
// spawnEntityAt(rock, pos, true, false);
// }
//}

private void spawnNails() {
GridPoint2 minPos = new GridPoint2(0, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(2, 2);

for (int i = 0; i < 5; i++) {
GridPoint2 randomPos = RandomUtils.randomX(52, minPos, maxPos);
Entity nail = ObstacleFactory.createNail();
spawnEntityAt(nail, randomPos, true, false);
GridPoint2 randomPosTwo = RandomUtils.randomX(54, minPos, maxPos);
Entity nailTwo = ObstacleFactory.createWood();
spawnEntityAt(nailTwo, randomPosTwo, true, false);
}
}
public void spawnNailsone(int xValue) {

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

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

public void spawnNailsthree(int xValue) {

for (int i = 0; i < 4; i++) {
GridPoint2 pos = new GridPoint2(xValue -3 +i, 58);
Entity nail = ObstacleFactory.createNail();
spawnEntityAt(nail, pos, true, false);
}
}
public void spawnNailsfour(int xValue) {

for (int i = 0; i < 3; i++) {
GridPoint2 pos = new GridPoint2(xValue +3 +i, 58);
Entity nail = ObstacleFactory.createNail();
spawnEntityAt(nail, pos, true, false);
}
}
public void spawnWoodsone(int xValue) {

for (int i = 0; i < 5; i++) {
GridPoint2 pos = new GridPoint2(xValue +i, 55);
Entity wood = ObstacleFactory.createWood();
spawnEntityAt(wood, pos, true, false);
}
}
public void spawnWoodstwo(int xValue) {

for (int i = 0; i < 3; i++) {
GridPoint2 pos = new GridPoint2(xValue -5 +i, 55);
Entity wood = ObstacleFactory.createWood();
spawnEntityAt(wood, pos, true, false);
}
}
public void spawnWoodsthree(int xValue) {

for (int i = 0; i < 2; i++) {
GridPoint2 pos = new GridPoint2(xValue +6 +i, 53);
Entity wood = ObstacleFactory.createWood();
spawnEntityAt(wood, pos, true, false);
}
}
public void spawnWoodsfour(int xValue) {

for (int i = 0; i < 2; i++) {
GridPoint2 pos = new GridPoint2(xValue +9 +i, 54);
Entity wood = ObstacleFactory.createWood();
spawnEntityAt(wood, pos, true, false);
}
}
public void spawnWoodsfive(int xValue) {

for (int i = 0; i < 2; i++) {
GridPoint2 pos = new GridPoint2(xValue +12 +i, 56);
Entity wood = ObstacleFactory.createWood();
spawnEntityAt(wood, pos, true, false);
}
}

/**
* Generate line 5 rocks in the new map
* @param xValue horizontal start point
*/
public void spawnRocksone(int xValue) {
*/
public void spawnFireRocksone(int xValue) {

for (int i = 0; i < 5; i++) {
GridPoint2 pos = new GridPoint2(xValue + 2 +i, 50);
Entity rock = ObstacleFactory.createRock();
spawnEntityAt(rock, pos, true, false);
GridPoint2 pos = new GridPoint2(xValue + -4 +i, 50);
Entity frock = ObstacleFactory.createFirerock();
spawnEntityAt(frock, pos, true, false);
}
}

Expand Down Expand Up @@ -92,6 +189,8 @@ public void spawnRockstwo(int xValue) {
* NNN
* @param xValue horizontal start point
*/

/*
public void spawnRocksthree(int xValue) {


Expand All @@ -114,13 +213,15 @@ public void spawnRocksthree(int xValue) {
Entity rockSix = ObstacleFactory.createRock();
spawnEntityAt(rockSix, PosSix, true, false);


}

*/

/**
* Generate 5 rocks column from the ground up
* @param xValue horizontal start point
*/
/*
public void spawnRocksfour(int xValue) {

for (int i = 0; i < 5; i++) {
Expand All @@ -131,12 +232,14 @@ public void spawnRocksfour(int xValue) {

}
}
*/


/**
* Generate 5 rocks column from the sky down
* @param xValue horizontal start point
*/

/*
public void spawnRocksfive(int xValue) {

for (int i = 0; i < 4; i++) {
Expand All @@ -147,7 +250,7 @@ public void spawnRocksfive(int xValue) {

}
}

*/
/**
* Genrate large rock pyramid
* N
Expand All @@ -156,6 +259,8 @@ public void spawnRocksfive(int xValue) {
* NNNN
* @param xValue horizontal start point
*/

/*
public void spawnRockssix(int xValue) {

GridPoint2 Pos = new GridPoint2(xValue + 22, 53);
Expand Down Expand Up @@ -191,6 +296,7 @@ public void spawnRockssix(int xValue) {


}
*/

/**
* Gennerate 5 wood randomly in the 52f and 54f height
Expand Down Expand Up @@ -236,6 +342,8 @@ public void spawnWoodsRandomly(int xValue) {
private static final float WALL_WIDTH = 0.1f;
private ItemBar itembar;
private static final String[] forestTextures = {
"images/firerock.jpg",
"images/nail.jpg",
"images/box_boy_leaf.png",
"images/images.jpg",
"images/ghost_king.png",
Expand Down Expand Up @@ -392,7 +500,9 @@ public void create() {
spawnTerrain(TerrainType.ROCK_ROAD);

// spawnRocks();
spawnWoods();
// spawnWoods();
// spawnNails();


MPCConfig.updateValues();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,44 @@ public static Entity createRock() {
return rock;
}



/**
* Creates a firerock.
*
* @return Firrerock entity
*/
public static Entity createFirerock() {
Entity firerock = new Entity();

firerock.addComponent(new TextureRenderComponent("images/firerock.jpg"))
.addComponent(new PhysicsComponent())
.addComponent(new ColliderComponent().setLayer(PhysicsLayer.OBSTACLE));
firerock.getComponent(PhysicsComponent.class).setBodyType(BodyType.StaticBody);
firerock.getComponent(TextureRenderComponent.class).scaleEntity();


return firerock;
}

/**
* Creates a nail.
*
* @return nail entity
*/
public static Entity createNail() {
Entity nail = new Entity();

nail.addComponent(new TextureRenderComponent("images/nail.jpg"))
.addComponent(new PhysicsComponent())
.addComponent(new ColliderComponent().setLayer(PhysicsLayer.OBSTACLE));
nail.getComponent(PhysicsComponent.class).setBodyType(BodyType.StaticBody);
nail.getComponent(TextureRenderComponent.class).scaleEntity();


return nail;
}

/**
* Creates a wood.
*
Expand Down
42 changes: 30 additions & 12 deletions source/core/src/main/com/deco2800/game/screens/MainGameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,22 @@ public void render(float delta) {
forestGameArea.spawnTerrainRandomly((int) (screenVector.x + 2), TerrainFactory.TerrainType.MUD_ROAD);
forestGameArea.spawnTerrainRandomly((int) (screenVector.x + 2), TerrainFactory.TerrainType.ROCK_ROAD);
// forestGameArea.spawnRocksRandomly((int) (screenVector.x+2));
forestGameArea.spawnWoodsRandomly((int) (screenVector.x + 2));
forestGameArea.spawnRocksone((int) (screenVector.x + 2));
forestGameArea.spawnWoodsone((int) (screenVector.x + 2));
forestGameArea.spawnWoodstwo((int) (screenVector.x + 2));
forestGameArea.spawnWoodsthree((int) (screenVector.x + 2));
forestGameArea.spawnWoodsfour((int) (screenVector.x + 2));
forestGameArea.spawnWoodsfive((int) (screenVector.x + 2));

forestGameArea.spawnFireRocksone((int) (screenVector.x + 2));
forestGameArea.spawnRockstwo((int) (screenVector.x + 2));
forestGameArea.spawnRocksthree((int) (screenVector.x + 2));
forestGameArea.spawnRocksfour((int) (screenVector.x + 2));
forestGameArea.spawnRocksfive((int) (screenVector.x + 2));
forestGameArea.spawnRockssix((int) (screenVector.x + 2));
// forestGameArea.spawnRocksthree((int) (screenVector.x + 2));
// forestGameArea.spawnRocksfour((int) (screenVector.x + 2));
// forestGameArea.spawnRocksfive((int) (screenVector.x + 2));
// forestGameArea.spawnRockssix((int) (screenVector.x + 2));
forestGameArea.spawnNailsone((int)(screenVector.x + 2));
forestGameArea.spawnNailstwo((int) (screenVector.x + 2));
forestGameArea.spawnNailsthree((int) (screenVector.x + 2));
forestGameArea.spawnNailsfour((int) (screenVector.x + 2));
generateObstaclesEnemiesByMapRefresh(counter);
}

Expand All @@ -350,13 +359,22 @@ public void render(float delta) {
// forestGameArea.showNewMapScrollingBackground(counter, 47);
forestGameArea.spawnTerrainRandomly((int) (screenVector.x + 2), TerrainFactory.TerrainType.ROCK_ROAD);
// forestGameArea.spawnRocksRandomly((int) (screenVector.x+2));
forestGameArea.spawnWoodsRandomly((int) (screenVector.x + 2));
forestGameArea.spawnRocksone((int) (screenVector.x + 2));
forestGameArea.spawnWoodsone((int) (screenVector.x + 2));
forestGameArea.spawnWoodstwo((int) (screenVector.x + 2));
forestGameArea.spawnWoodsthree((int) (screenVector.x + 2));
forestGameArea.spawnWoodsfour((int) (screenVector.x + 2));
forestGameArea.spawnWoodsfive((int) (screenVector.x + 2));

forestGameArea.spawnFireRocksone((int) (screenVector.x + 2));
forestGameArea.spawnRockstwo((int) (screenVector.x + 2));
forestGameArea.spawnRocksthree((int) (screenVector.x + 2));
forestGameArea.spawnRocksfour((int) (screenVector.x + 2));
forestGameArea.spawnRocksfive((int) (screenVector.x + 2));
forestGameArea.spawnRockssix((int) (screenVector.x + 2));
// forestGameArea.spawnRocksthree((int) (screenVector.x + 2));
// forestGameArea.spawnRocksfour((int) (screenVector.x + 2));
// forestGameArea.spawnRocksfive((int) (screenVector.x + 2));
// forestGameArea.spawnRockssix((int) (screenVector.x + 2));
forestGameArea.spawnNailsone((int) (screenVector.x + 2));
forestGameArea.spawnNailstwo((int) (screenVector.x + 2));
forestGameArea.spawnNailsthree((int) (screenVector.x + 2));
forestGameArea.spawnNailsfour((int) (screenVector.x + 2));
forestGameArea.spawnGoldNewMapRandomly((int) (screenVector.x + 2));
}
}
Expand Down