Updated to 1.3 version of DodgeGame (2 player support)
This commit is contained in:
parent
389f93c0fc
commit
3c7e3be1eb
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -3,14 +3,16 @@
|
|||||||
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
|
<!--DO NOT EDIT THIS FILE! - Used by the Gradle plugin of NetBeans.-->
|
||||||
<auxiliary>
|
<auxiliary>
|
||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
|
||||||
<group/>
|
|
||||||
</open-files>
|
|
||||||
<editor-bookmarks lastBookmarkId="0" xmlns="http://www.netbeans.org/ns/editor-bookmarks/2"/>
|
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group>
|
<group>
|
||||||
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/desktop/src/com/jalenwinslow/game/desktop/DesktopLauncher.java</file>
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/states/GameState.java</file>
|
||||||
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/utils/Players.java</file>
|
||||||
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/gameobjects/Player.java</file>
|
||||||
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/Main.java</file>
|
||||||
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/states/MenuState.java</file>
|
||||||
|
<file>file:/C:/Users/jalen/Programming/Netbeans%20Workspace/Summer%202017/DodgeGame/core/src/com/jalenwinslow/game/states/GameOverState.java</file>
|
||||||
</group>
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
|
<editor-bookmarks lastBookmarkId="0" xmlns="http://www.netbeans.org/ns/editor-bookmarks/2"/>
|
||||||
</auxiliary>
|
</auxiliary>
|
||||||
</gradle-project-properties>
|
</gradle-project-properties>
|
||||||
|
11
HELP.txt
11
HELP.txt
@ -5,11 +5,20 @@ wood walls to help you survive longer.
|
|||||||
|
|
||||||
Controls
|
Controls
|
||||||
--------
|
--------
|
||||||
|
1st Player Controls.
|
||||||
W, A, S, D = Up, Left, Down, Right
|
W, A, S, D = Up, Left, Down, Right
|
||||||
E -> Hold down to destroy wood or build walls. (In menu, you use it to select choices.)
|
E -> Hold down to destroy wood or build walls. (In menu, you use it to select choices.)
|
||||||
Space -> When you have 7 pieces of wood you can create a wall.
|
Space -> When you have 7 pieces of wood you can create a wall.
|
||||||
|
Q -> Give wood to other player if standing near them.
|
||||||
|
2nd Player Controls.
|
||||||
|
Up, Down, Left, Right Arrow Keys = Up, Down, Left, Right
|
||||||
|
Right Control(ctrl) = hold down to destroy wood or build walls. (In menu, you use it to select choices.)
|
||||||
|
Right Shift = When you have 7 pieces of wood you can create a wall
|
||||||
|
End (button) = Give wood to other player if standing near them.
|
||||||
|
|
||||||
|
Press the num 2 in main menu to add TWO players.
|
||||||
--------
|
--------
|
||||||
|
|
||||||
There is an executable in "/built_game". Latest build DodgeGame_1.2.jar.
|
There is an executable in "/built_game". Latest build DodgeGame_1.3.jar.
|
||||||
|
|
||||||
Created using libgdx.
|
Created using libgdx.
|
Binary file not shown.
11
built_game/scores.txt
Normal file
11
built_game/scores.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
29
|
||||||
|
192
|
||||||
|
273
|
||||||
|
11
|
||||||
|
8
|
||||||
|
3
|
||||||
|
6
|
||||||
|
2
|
||||||
|
2
|
||||||
|
0
|
||||||
|
4
|
Binary file not shown.
Before Width: | Height: | Size: 531 B |
BIN
core/assets/b&w_DodgeGame_font1 - Copy.fnt
Normal file
BIN
core/assets/b&w_DodgeGame_font1 - Copy.fnt
Normal file
Binary file not shown.
After Width: | Height: | Size: 704 B |
BIN
core/assets/b&w_DodgeGame_healer.png
Normal file
BIN
core/assets/b&w_DodgeGame_healer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 168 B |
Binary file not shown.
Before Width: | Height: | Size: 1008 B After Width: | Height: | Size: 1.3 KiB |
BIN
core/assets/b&w_DodgeGame_woman1.png
Normal file
BIN
core/assets/b&w_DodgeGame_woman1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -1,11 +1,11 @@
|
|||||||
19
|
128
|
||||||
209
|
460
|
||||||
314
|
1372
|
||||||
|
20
|
||||||
|
22
|
||||||
11
|
11
|
||||||
8
|
13
|
||||||
3
|
|
||||||
6
|
|
||||||
2
|
|
||||||
2
|
|
||||||
0
|
|
||||||
4
|
4
|
||||||
|
5
|
||||||
|
0
|
||||||
|
10
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
|||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.jalenwinslow.game.gameobjects.GameObjectHandler;
|
import com.jalenwinslow.game.gameobjects.GameObjectHandler;
|
||||||
import com.jalenwinslow.game.states.*;
|
import com.jalenwinslow.game.states.*;
|
||||||
|
import com.jalenwinslow.game.utils.Players;
|
||||||
import com.jalenwinslow.game.utils.Score;
|
import com.jalenwinslow.game.utils.Score;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -18,6 +19,7 @@ public class Handler {
|
|||||||
|
|
||||||
private State menuState, gameState, gameOverState, pauseState, exitState;
|
private State menuState, gameState, gameOverState, pauseState, exitState;
|
||||||
private GameObjectHandler gameObjectHandler;
|
private GameObjectHandler gameObjectHandler;
|
||||||
|
private Players players;
|
||||||
|
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
private String message = "";
|
private String message = "";
|
||||||
@ -39,6 +41,7 @@ public class Handler {
|
|||||||
exitState = new ExitState(this);
|
exitState = new ExitState(this);
|
||||||
|
|
||||||
gameObjectHandler = new GameObjectHandler(this);
|
gameObjectHandler = new GameObjectHandler(this);
|
||||||
|
players = new Players(this);
|
||||||
|
|
||||||
font = new BitmapFont();
|
font = new BitmapFont();
|
||||||
font.setColor(Color.RED);
|
font.setColor(Color.RED);
|
||||||
@ -104,6 +107,7 @@ public class Handler {
|
|||||||
public PauseState getPauseState() {return (PauseState)pauseState;}
|
public PauseState getPauseState() {return (PauseState)pauseState;}
|
||||||
public ExitState getExitState() {return (ExitState)exitState;}
|
public ExitState getExitState() {return (ExitState)exitState;}
|
||||||
public GameObjectHandler getGameObjectHandler() {return gameObjectHandler;}
|
public GameObjectHandler getGameObjectHandler() {return gameObjectHandler;}
|
||||||
|
public Players getPlayers() {return players;}
|
||||||
public FileHandle getScoreFile() {return scoreFile;}
|
public FileHandle getScoreFile() {return scoreFile;}
|
||||||
public Score getScore() {return score;}
|
public Score getScore() {return score;}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ public class Arrow extends GameObject {
|
|||||||
public static final double MIN_SPEED = 2.5; //normal -> maxSpeed: 4 && minSpeed: 2.5
|
public static final double MIN_SPEED = 2.5; //normal -> maxSpeed: 4 && minSpeed: 2.5
|
||||||
|
|
||||||
private int dir;
|
private int dir;
|
||||||
|
private int damage;
|
||||||
private double speed;
|
private double speed;
|
||||||
private double vecX, vecY;
|
private double vecX, vecY;
|
||||||
//private static Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
//private static Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
||||||
@ -23,6 +24,7 @@ public class Arrow extends GameObject {
|
|||||||
public Arrow(Handler handler, double x, double y, TextureRegion image, int dir) {
|
public Arrow(Handler handler, double x, double y, TextureRegion image, int dir) {
|
||||||
super(handler, x, y, image);
|
super(handler, x, y, image);
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
|
this.damage = handler.getGameState().getArrowGen().getArrowDamage();
|
||||||
speed = MIN_SPEED;
|
speed = MIN_SPEED;
|
||||||
vecX = 0;
|
vecX = 0;
|
||||||
vecY = 0;
|
vecY = 0;
|
||||||
@ -82,18 +84,21 @@ public class Arrow extends GameObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkCollision() {
|
private void checkCollision() {
|
||||||
if (bounds.overlaps(handler.getGameState().getPlayer().getBounds())) {
|
|
||||||
handler.getGameState().getTimer().stop();
|
for (int i = 1; i <= handler.getPlayers().getPlayers().size; i++) {
|
||||||
State.setCurrenState(handler.getGameOverState());
|
if (bounds.overlaps(handler.getPlayers().getPlayer(i).getBounds())) {
|
||||||
State.getCurrentState().init();
|
if (!handler.getPlayers().getPlayer(i).isDead()) {
|
||||||
handler.getGameObjectHandler().dispose();
|
handler.getGameState().getArrowGen().getArrows().removeValue(this, false);
|
||||||
handler.getGameState().dispose();
|
handler.getPlayers().getPlayer(i).setHitPoints(0);
|
||||||
|
}
|
||||||
|
handler.getPlayers().getPlayer(i).setDead(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) {
|
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) {
|
||||||
TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
||||||
if (bounds.overlaps(wall.getNoArrowBounds())) {
|
if (bounds.overlaps(wall.getNoArrowBounds())) {
|
||||||
wall.setHitPoints(wall.getHitPoints() - 6);
|
wall.setHitPoints(wall.getHitPoints() - damage);
|
||||||
handler.getGameState().getArrowGen().getArrows().removeValue(this, false);
|
handler.getGameState().getArrowGen().getArrows().removeValue(this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ public class ArrowGenerator extends GameObject {
|
|||||||
private double currentDeployTime;
|
private double currentDeployTime;
|
||||||
private int highestAmountOfArrowsAtOnce;
|
private int highestAmountOfArrowsAtOnce;
|
||||||
private int amountOfArrowsCreated;
|
private int amountOfArrowsCreated;
|
||||||
|
private int arrowDamage;
|
||||||
|
|
||||||
private Random rand;
|
private Random rand;
|
||||||
private TextureRegion[][] arrowTextures;
|
private TextureRegion[][] arrowTextures;
|
||||||
@ -34,6 +35,7 @@ public class ArrowGenerator extends GameObject {
|
|||||||
currentDeployTime = ARROW_DEPLOY_START_TIME;
|
currentDeployTime = ARROW_DEPLOY_START_TIME;
|
||||||
highestAmountOfArrowsAtOnce = 0;
|
highestAmountOfArrowsAtOnce = 0;
|
||||||
amountOfArrowsCreated = 0;
|
amountOfArrowsCreated = 0;
|
||||||
|
arrowDamage = 6;
|
||||||
|
|
||||||
rand = new Random();
|
rand = new Random();
|
||||||
arrowTextures = image.split(16, 16);
|
arrowTextures = image.split(16, 16);
|
||||||
@ -81,6 +83,8 @@ public class ArrowGenerator extends GameObject {
|
|||||||
currentDeployTime -= 0.1;
|
currentDeployTime -= 0.1;
|
||||||
if (currentDeployTime < ARROW_DEPLOY_END_TIME) currentDeployTime = ARROW_DEPLOY_END_TIME;
|
if (currentDeployTime < ARROW_DEPLOY_END_TIME) currentDeployTime = ARROW_DEPLOY_END_TIME;
|
||||||
}
|
}
|
||||||
|
int modifier2 = (handler.getGameState().getTimer().getTime() - 400) / 60;
|
||||||
|
arrowDamage = 6 + modifier2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addArrow() {
|
private void addArrow() {
|
||||||
@ -116,5 +120,6 @@ public class ArrowGenerator extends GameObject {
|
|||||||
public Array<Arrow> getArrows() {return arrows;}
|
public Array<Arrow> getArrows() {return arrows;}
|
||||||
public int getAmountOfArrowsCreated() {return amountOfArrowsCreated;}
|
public int getAmountOfArrowsCreated() {return amountOfArrowsCreated;}
|
||||||
public int getHighestAmountOfArrowsAtOnce() {return highestAmountOfArrowsAtOnce;}
|
public int getHighestAmountOfArrowsAtOnce() {return highestAmountOfArrowsAtOnce;}
|
||||||
|
public int getArrowDamage() {return arrowDamage;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@ import com.jalenwinslow.game.states.State;
|
|||||||
public class Button extends GameObject {
|
public class Button extends GameObject {
|
||||||
|
|
||||||
//--- Propreties
|
//--- Propreties
|
||||||
private TextureRegion[][] images;
|
protected TextureRegion[][] images;
|
||||||
private BitmapFont font;
|
protected BitmapFont font;
|
||||||
private String message;
|
protected String message;
|
||||||
private int imageIndex;
|
protected int imageIndex;
|
||||||
private boolean drawHealth;
|
protected boolean drawHealth;
|
||||||
private HealthBar health;
|
protected HealthBar health;
|
||||||
private int hitPoints;
|
protected int hitPoints;
|
||||||
|
|
||||||
//--- Constructor
|
//--- Constructor
|
||||||
public Button(Handler handler, double x, double y, TextureRegion image, String message, int scale) {
|
public Button(Handler handler, double x, double y, TextureRegion image, String message, int scale) {
|
||||||
@ -43,12 +43,12 @@ public class Button extends GameObject {
|
|||||||
//--- Methods
|
//--- Methods
|
||||||
@Override
|
@Override
|
||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
//checkIfMouseWithin();
|
if (toString().equals("Button")) checkPlayerCollision();
|
||||||
checkPlayerCollision();
|
|
||||||
if (hitPoints < 0) {hitPoints = 0;}
|
if (hitPoints < 0) {hitPoints = 0;}
|
||||||
health.setHealth(hitPoints);
|
health.setHealth(hitPoints);
|
||||||
if (hitPoints >= 60) {
|
if (hitPoints >= 60) {
|
||||||
buttonAction();
|
buttonAction();
|
||||||
|
hitPoints = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,32 +72,60 @@ public class Button extends GameObject {
|
|||||||
State.setCurrenState(handler.getGameState());
|
State.setCurrenState(handler.getGameState());
|
||||||
handler.getGameObjectHandler().dispose();
|
handler.getGameObjectHandler().dispose();
|
||||||
handler.getGameState().init();
|
handler.getGameState().init();
|
||||||
|
handler.getPlayers().resetPlayers();
|
||||||
handler.getMenuState().dispose();
|
handler.getMenuState().dispose();
|
||||||
} else if (message.equalsIgnoreCase("Stats")) {
|
} else if (message.equalsIgnoreCase("Stats")) {
|
||||||
handler.getMenuState().setSubState(1);
|
handler.getMenuState().setSubState(1);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
} else if (message.equalsIgnoreCase("Exit")) {
|
} else if (message.equalsIgnoreCase("Exit")) {
|
||||||
State.setCurrenState(handler.getExitState());
|
State.setCurrenState(handler.getExitState());
|
||||||
handler.getGameObjectHandler().dispose();
|
handler.getGameObjectHandler().dispose();
|
||||||
State.getCurrentState().init();
|
State.getCurrentState().init();
|
||||||
handler.getMenuState().dispose();
|
handler.getMenuState().dispose();
|
||||||
|
} else if (message.equalsIgnoreCase("multi-\nplayer")) {
|
||||||
|
handler.getMenuState().setSubState(2);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
} else if (message.equalsIgnoreCase("back")) {
|
} else if (message.equalsIgnoreCase("back")) {
|
||||||
|
int subState = handler.getMenuState().getSubState();
|
||||||
|
if (subState == 1 || subState == 2)
|
||||||
handler.getMenuState().setSubState(0);
|
handler.getMenuState().setSubState(0);
|
||||||
|
else if (subState == 3) {
|
||||||
|
handler.getMenuState().setSubState(2);
|
||||||
|
}
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
|
} else if (message.equalsIgnoreCase("Player 1")) { //Player 1 controls
|
||||||
|
handler.getMenuState().setSubState(3);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
|
} else if (message.equalsIgnoreCase("Player 2")) { //Player 2 controls
|
||||||
|
handler.getMenuState().setSubState(3);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
|
} else if (message.equalsIgnoreCase("Player 3")) { //Player 3 controls
|
||||||
|
handler.getMenuState().setSubState(3);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
|
} else if (message.equalsIgnoreCase("Player 4")) { //Player 4 controls
|
||||||
|
handler.getMenuState().setSubState(3);
|
||||||
|
handler.getPlayers().centerPlayers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPlayerCollision() {
|
protected void checkPlayerCollision() {
|
||||||
if (bounds.overlaps(handler.getMenuState().getPlayer().getBounds())) {
|
|
||||||
drawHealth = true;
|
|
||||||
imageIndex = 1;
|
|
||||||
if (Gdx.input.isKeyPressed(Keys.E)) {
|
|
||||||
hitPoints++;
|
|
||||||
} else {hitPoints--;}
|
|
||||||
} else {
|
|
||||||
drawHealth = false;
|
drawHealth = false;
|
||||||
imageIndex = 0;
|
imageIndex = 0;
|
||||||
hitPoints--;
|
int addHitPoints = 0;
|
||||||
|
for (int i = 0; i < handler.getPlayers().getNumOfPlayers(); i++) {
|
||||||
|
if (handler.getPlayers().getPlayer(i+1) == null) continue;
|
||||||
|
if (bounds.overlaps(handler.getPlayers().getPlayer(i+1).getBounds())) {
|
||||||
|
drawHealth = true;
|
||||||
|
imageIndex = 1;
|
||||||
|
if (handler.getPlayers().getPlayer(i+1).getActionPressed()) {
|
||||||
|
addHitPoints += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (addHitPoints != 0) {
|
||||||
|
hitPoints += addHitPoints;
|
||||||
|
} else hitPoints--;
|
||||||
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
|
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.jalenwinslow.game.gameobjects;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.jalenwinslow.game.Handler;
|
||||||
|
|
||||||
|
public class ControllerButton extends Button {
|
||||||
|
|
||||||
|
//--- Propreties
|
||||||
|
private boolean visible;
|
||||||
|
private int playerNum;
|
||||||
|
|
||||||
|
private float alpha;
|
||||||
|
|
||||||
|
//--- Constructor
|
||||||
|
public ControllerButton(Handler handler, double x, double y, TextureRegion image, String message, int scale, int playerNum) {
|
||||||
|
super(handler, x, y, image, message, scale);
|
||||||
|
visible = false;
|
||||||
|
this.playerNum = playerNum;
|
||||||
|
|
||||||
|
this.alpha = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--- Methods
|
||||||
|
@Override
|
||||||
|
public void update(float dt) {
|
||||||
|
checkPlayerCollision();
|
||||||
|
if (visible && bounds.overlaps(handler.getPlayers().getPlayer(playerNum).getBounds()))
|
||||||
|
super.update(dt);//fix this area, so only players can change their own controls.
|
||||||
|
displayButton();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(SpriteBatch batch) {
|
||||||
|
if (visible) {
|
||||||
|
batch.setColor(1, 1, 1, alpha);
|
||||||
|
super.render(batch);
|
||||||
|
batch.setColor(1, 1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayButton() {
|
||||||
|
if (handler.getPlayers().getNumOfPlayers() >= playerNum)
|
||||||
|
visible = handler.getPlayers().getPlayer(playerNum) != null;
|
||||||
|
if (visible && bounds.overlaps(handler.getPlayers().getPlayer(playerNum).getBounds())) {
|
||||||
|
alpha = 1;
|
||||||
|
} else alpha = 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {return "ControllerButton";}
|
||||||
|
|
||||||
|
//--- Getters and Setters
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -44,5 +44,11 @@ public abstract class GameObject {
|
|||||||
public int getDepth() {return depth;}
|
public int getDepth() {return depth;}
|
||||||
public Rectangle getBounds() {return bounds;}
|
public Rectangle getBounds() {return bounds;}
|
||||||
|
|
||||||
|
public void setX(double x) {this.x = x;}
|
||||||
|
public void setY(double y) {this.y = y;}
|
||||||
|
public void setPosition(double x, double y) {this.x = x; this.y = y;}
|
||||||
|
public void setDepth(int depth) {this.depth = depth;}
|
||||||
|
public void setBounds(Rectangle bounds) {this.bounds = bounds;}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class GameObjectHandler {
|
|||||||
|
|
||||||
public void sort() {
|
public void sort() {
|
||||||
for (int i = 0; i < gameObjects.size - 1; i++) {
|
for (int i = 0; i < gameObjects.size - 1; i++) {
|
||||||
if (gameObjects.get(i).depth <= gameObjects.get(i+1).depth) {
|
if (gameObjects.get(i).depth < gameObjects.get(i+1).depth) {
|
||||||
gameObjects.swap(i, i+1);
|
gameObjects.swap(i, i+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
145
core/src/com/jalenwinslow/game/gameobjects/Healer.java
Normal file
145
core/src/com/jalenwinslow/game/gameobjects/Healer.java
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
package com.jalenwinslow.game.gameobjects;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Animation;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.math.Rectangle;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.jalenwinslow.game.Handler;
|
||||||
|
import com.jalenwinslow.game.Main;
|
||||||
|
|
||||||
|
public class Healer extends GameObject {
|
||||||
|
|
||||||
|
//--- Propreties
|
||||||
|
enum HealerStates {
|
||||||
|
creation,
|
||||||
|
normal
|
||||||
|
}
|
||||||
|
private HealerStates state;
|
||||||
|
|
||||||
|
private Animation<TextureRegion> anim;
|
||||||
|
private TextureRegion texture;
|
||||||
|
|
||||||
|
private float elapsedTime;
|
||||||
|
private float tick;
|
||||||
|
private int timerCountDown;
|
||||||
|
|
||||||
|
private float alpha;
|
||||||
|
|
||||||
|
private Rectangle boundsHeal;
|
||||||
|
private Rectangle boundsNoPlayer;
|
||||||
|
|
||||||
|
//private TextureRegion boundsTexture = new TextureRegion(new Texture("DodgeGame_boundsMask.png"));
|
||||||
|
|
||||||
|
//--- Constructor
|
||||||
|
public Healer(Handler handler, double x, double y, TextureRegion image) {
|
||||||
|
super(handler, x, y, image);
|
||||||
|
bounds = new Rectangle();
|
||||||
|
boundsNoPlayer = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
||||||
|
boundsHeal = new Rectangle();//bounds.x - Main.WIDTH/10, bounds.y-Main.HEIGHT/10, bounds.width+Main.WIDTH/10, bounds.height+Main.HEIGHT/10);
|
||||||
|
|
||||||
|
depth = (int) y + (Main.HEIGHT/20) + (Main.HEIGHT/40);
|
||||||
|
|
||||||
|
elapsedTime = 0;
|
||||||
|
tick = 0;
|
||||||
|
timerCountDown = 10;
|
||||||
|
//createAnimation();
|
||||||
|
|
||||||
|
alpha = 0.5f;
|
||||||
|
|
||||||
|
state = HealerStates.creation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--- Methods
|
||||||
|
@Override
|
||||||
|
public void update(float dt) {
|
||||||
|
switch (state) {
|
||||||
|
case creation:
|
||||||
|
elapsedTime += dt;
|
||||||
|
if (bounds.area() != boundsNoPlayer.area()) {
|
||||||
|
boolean check = true;
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (player.getBoundsFeet().overlaps(boundsNoPlayer)) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (check) {
|
||||||
|
alpha = 1;
|
||||||
|
bounds = new Rectangle(boundsNoPlayer);
|
||||||
|
boundsHeal = new Rectangle(bounds.x - Main.WIDTH/10, bounds.y-Main.HEIGHT/10, bounds.width+Main.WIDTH/5, bounds.height+Main.HEIGHT/5);
|
||||||
|
state = HealerStates.normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case normal:
|
||||||
|
elapsedTime += dt;
|
||||||
|
if (elapsedTime >= 10) {
|
||||||
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
|
if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) {
|
||||||
|
handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight()));
|
||||||
|
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handleCollision();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(SpriteBatch batch) {
|
||||||
|
switch (state) {
|
||||||
|
case creation:
|
||||||
|
batch.setColor(1, 1, 1, alpha);
|
||||||
|
batch.draw(image, boundsNoPlayer.x, boundsNoPlayer.y ,boundsNoPlayer.width ,boundsNoPlayer.height + (Main.WIDTH/40));
|
||||||
|
batch.setColor(1, 1, 1, 1);
|
||||||
|
break;
|
||||||
|
case normal:
|
||||||
|
batch.draw(image, bounds.x, bounds.y, bounds.width, bounds.height+(Main.HEIGHT/40));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//batch.draw(boundsTexture, boundsHeal.x, boundsHeal.y, boundsHeal.width, boundsHeal.height);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
//boundsTexture.getTexture().dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {return "Healer";}
|
||||||
|
|
||||||
|
public void createAnimation() {
|
||||||
|
TextureRegion[][] splitTexture = image.split(16, 20);
|
||||||
|
Array<TextureRegion> array = new Array(splitTexture.length * splitTexture[0].length);
|
||||||
|
for (int i = 0; i < splitTexture[0].length; i++) {
|
||||||
|
array.add(splitTexture[0][i]);
|
||||||
|
}
|
||||||
|
anim = new Animation(0.5f, array, PlayMode.LOOP);
|
||||||
|
array.clear();
|
||||||
|
texture = anim.getKeyFrame(elapsedTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleCollision() {
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (!player.isDead()) continue;
|
||||||
|
if (player.getBoundsFeet().overlaps(boundsHeal)) {
|
||||||
|
player.setHitPoints(player.getHitPoints()+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- Getters and Setters
|
||||||
|
public Rectangle getBoundsHeal() {return boundsHeal;}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,96 @@
|
|||||||
|
package com.jalenwinslow.game.gameobjects;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.jalenwinslow.game.Handler;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class HealerGenerator extends GameObject {
|
||||||
|
|
||||||
|
public static int BASE_COUNT_DOWN = 30;
|
||||||
|
|
||||||
|
private Random rand;
|
||||||
|
|
||||||
|
//--- Propreties
|
||||||
|
private float elapsedTime;
|
||||||
|
private int tick;
|
||||||
|
private int timerCountDown;
|
||||||
|
|
||||||
|
//--- Constructor
|
||||||
|
public HealerGenerator(Handler handler, double x, double y, TextureRegion image) {
|
||||||
|
super(handler, x, y, image);
|
||||||
|
|
||||||
|
rand = new Random();
|
||||||
|
|
||||||
|
elapsedTime = 0;
|
||||||
|
tick = 0;
|
||||||
|
timerCountDown = BASE_COUNT_DOWN + (rand.nextInt(11)-5);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--- Methods
|
||||||
|
@Override
|
||||||
|
public void update(float dt) {
|
||||||
|
elapsedTime += dt;
|
||||||
|
if (elapsedTime >= 1) {
|
||||||
|
tick++;
|
||||||
|
elapsedTime--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tick >= timerCountDown) {
|
||||||
|
int probability = 80;
|
||||||
|
if (rand.nextInt(100)+1 <= probability) {
|
||||||
|
addHealer();
|
||||||
|
}
|
||||||
|
timerCountDown = BASE_COUNT_DOWN + (rand.nextInt(11) - 5);
|
||||||
|
tick = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(SpriteBatch batch) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addHealer() {
|
||||||
|
int arrayX = rand.nextInt(8)+1;
|
||||||
|
int arrayY = rand.nextInt(8)+1;
|
||||||
|
while (true) {
|
||||||
|
if (handler.getGameState().getGrid().isFree()[arrayY][arrayX] == true) {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (arrayX < 8) arrayX++;
|
||||||
|
else {
|
||||||
|
if (arrayY < 8) {
|
||||||
|
arrayY++;
|
||||||
|
arrayX = 1;
|
||||||
|
} else {
|
||||||
|
arrayY = 1;
|
||||||
|
arrayX = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handler.getGameState().getGrid().setFree(false, arrayX, arrayY);
|
||||||
|
|
||||||
|
int xx = handler.getGameState().getGrid().getAreaWidth() * (arrayX);
|
||||||
|
int yy = handler.getGameState().getGrid().getAreaHeight() * (arrayY);
|
||||||
|
|
||||||
|
handler.getGameObjectHandler().add(new Healer(handler, xx, yy, image));
|
||||||
|
//System.out.println("Created a healer at" + arrayX + ", " + arrayY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {return "HealerGenerator";}
|
||||||
|
|
||||||
|
//--- Getters and Setters
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -51,6 +51,7 @@ public class HealthBar extends GameObject {
|
|||||||
public float getHealth() {return health;}
|
public float getHealth() {return health;}
|
||||||
public float getTotalHealth() {return totalHealth;}
|
public float getTotalHealth() {return totalHealth;}
|
||||||
|
|
||||||
|
|
||||||
public void setHealth(float health) {this.health = health;}
|
public void setHealth(float health) {this.health = health;}
|
||||||
public void setTotalHealth(float totalHealth) {this.totalHealth = totalHealth;}
|
public void setTotalHealth(float totalHealth) {this.totalHealth = totalHealth;}
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.jalenwinslow.game.Handler;
|
import com.jalenwinslow.game.Handler;
|
||||||
import com.jalenwinslow.game.Main;
|
import com.jalenwinslow.game.Main;
|
||||||
import com.jalenwinslow.game.gameobjects.TallWall.TallWallStates;
|
import com.jalenwinslow.game.gameobjects.TallWall.TallWallStates;
|
||||||
|
import com.jalenwinslow.game.states.State;
|
||||||
|
import com.jalenwinslow.game.utils.Players;
|
||||||
|
|
||||||
public class Player extends GameObject {
|
public class Player extends GameObject {
|
||||||
|
|
||||||
@ -24,8 +26,20 @@ public class Player extends GameObject {
|
|||||||
private int highestNumberOfTallWallsCreated;
|
private int highestNumberOfTallWallsCreated;
|
||||||
private int highestNumberOfTallWallsDestroyed;
|
private int highestNumberOfTallWallsDestroyed;
|
||||||
private int numberOfWoodPickedUp;
|
private int numberOfWoodPickedUp;
|
||||||
|
private int playerid;
|
||||||
|
private boolean dead;
|
||||||
|
|
||||||
private Animation<TextureRegion> animDown, animUp, animRight;
|
private boolean actionPressed;
|
||||||
|
private boolean giveWood;
|
||||||
|
private Controls playerControl;
|
||||||
|
|
||||||
|
private int hitPoints;
|
||||||
|
private int totalHitPoints;
|
||||||
|
private HealthBar reviveHealth;
|
||||||
|
private boolean drawHealth;
|
||||||
|
private int counterToIncreaseHealth;
|
||||||
|
|
||||||
|
private Animation<TextureRegion> animDown, animUp, animRight, animLeft;
|
||||||
private TextureRegion texture;
|
private TextureRegion texture;
|
||||||
private float elapsedTime = 0;
|
private float elapsedTime = 0;
|
||||||
private Rectangle boundsFeet;
|
private Rectangle boundsFeet;
|
||||||
@ -33,8 +47,19 @@ public class Player extends GameObject {
|
|||||||
//private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
//private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
||||||
|
|
||||||
//--- Constructor
|
//--- Constructor
|
||||||
public Player(Handler handler, double x, double y, TextureRegion image) {
|
public Player(Handler handler, double x, double y, TextureRegion image, int playerid) {
|
||||||
super(handler, x, y, image);
|
super(handler, x, y, image);
|
||||||
|
this.playerid = playerid;
|
||||||
|
this.dead = false;
|
||||||
|
|
||||||
|
actionPressed = false;
|
||||||
|
giveWood = false;
|
||||||
|
playerControl = new Controls(handler, playerid);
|
||||||
|
|
||||||
|
hitPoints = 0;
|
||||||
|
totalHitPoints = 450;
|
||||||
|
reviveHealth = new HealthBar(handler, x, y, new TextureRegion(Players.playerHealthTexture), totalHitPoints);
|
||||||
|
counterToIncreaseHealth = 0;
|
||||||
|
|
||||||
dir = 3;
|
dir = 3;
|
||||||
vecX = 0;
|
vecX = 0;
|
||||||
@ -62,11 +87,27 @@ public class Player extends GameObject {
|
|||||||
bounds.setPosition((float)x + 20, (float)y + 8);
|
bounds.setPosition((float)x + 20, (float)y + 8);
|
||||||
boundsFeet.setPosition((float)x + 20, (float)y);
|
boundsFeet.setPosition((float)x + 20, (float)y);
|
||||||
checks();
|
checks();
|
||||||
|
if (dead) {
|
||||||
|
reviveHealth.setHealth(hitPoints);
|
||||||
|
reviveHealth.getBounds().setPosition((float)x, (float)y + 64);
|
||||||
|
if (hitPoints >= totalHitPoints) {
|
||||||
|
dead = false;
|
||||||
|
drawHealth = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
|
if (!dead)
|
||||||
batch.draw(texture, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
batch.draw(texture, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
||||||
|
else {
|
||||||
|
batch.setColor(1, 1, 1, 0.5f);
|
||||||
|
batch.draw(texture, (int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
||||||
|
batch.setColor(1, 1, 1, 1);
|
||||||
|
if (drawHealth) reviveHealth.render(batch);
|
||||||
|
}
|
||||||
|
|
||||||
//batch.draw(boundsTexture, bounds.x, bounds.y, bounds.width, bounds.height);
|
//batch.draw(boundsTexture, bounds.x, bounds.y, bounds.width, bounds.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,6 +117,10 @@ public class Player extends GameObject {
|
|||||||
//boundsTexture.dispose();
|
//boundsTexture.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean returnPausePressed() {
|
||||||
|
return playerControl.pauseGame;
|
||||||
|
}
|
||||||
|
|
||||||
private void createAnimation() {
|
private void createAnimation() {
|
||||||
TextureRegion[][] splitTexture = image.split(16, 16);
|
TextureRegion[][] splitTexture = image.split(16, 16);
|
||||||
Array<TextureRegion> array = new Array(splitTexture.length * splitTexture[0].length);
|
Array<TextureRegion> array = new Array(splitTexture.length * splitTexture[0].length);
|
||||||
@ -96,33 +141,38 @@ public class Player extends GameObject {
|
|||||||
}
|
}
|
||||||
animRight = new Animation(0.1f, array, PlayMode.LOOP);
|
animRight = new Animation(0.1f, array, PlayMode.LOOP);
|
||||||
array.clear();
|
array.clear();
|
||||||
|
|
||||||
|
for (TextureRegion t : splitTexture[3]) {
|
||||||
|
array.add(t);
|
||||||
|
}
|
||||||
|
animLeft = new Animation(0.1f, array, PlayMode.LOOP);
|
||||||
|
array.clear();
|
||||||
texture = animDown.getKeyFrame(elapsedTime);
|
texture = animDown.getKeyFrame(elapsedTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleInput() {
|
private void handleInput() {
|
||||||
if ( (Gdx.input.isKeyPressed(Keys.W) && Gdx.input.isKeyPressed(Keys.S)) ||
|
playerControl.update();
|
||||||
(!Gdx.input.isKeyPressed(Keys.W) && !Gdx.input.isKeyPressed(Keys.S)) ) {
|
if ( (playerControl.up && playerControl.down) || (!playerControl.up && !playerControl.down) ) {
|
||||||
vecY = 0;
|
vecY = 0;
|
||||||
} else if (Gdx.input.isKeyPressed(Keys.W)) {
|
} else if (playerControl.up) {
|
||||||
vecY = SPEED;
|
vecY = SPEED;
|
||||||
dir = 1;
|
dir = 1;
|
||||||
} else if (Gdx.input.isKeyPressed(Keys.S)) {
|
} else if (playerControl.down) {
|
||||||
vecY = -SPEED;
|
vecY = -SPEED;
|
||||||
dir = 3;
|
dir = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (Gdx.input.isKeyPressed(Keys.A) && Gdx.input.isKeyPressed(Keys.D)) ||
|
if ( (playerControl.left && playerControl.right) || (!playerControl.left && !playerControl.right) ) {
|
||||||
(!Gdx.input.isKeyPressed(Keys.A) && !Gdx.input.isKeyPressed(Keys.D)) ) {
|
|
||||||
vecX = 0;
|
vecX = 0;
|
||||||
} else if (Gdx.input.isKeyPressed(Keys.A)) {
|
} else if (playerControl.left) {
|
||||||
vecX = -SPEED;
|
vecX = -SPEED;
|
||||||
dir = 2;
|
dir = 2;
|
||||||
} else if (Gdx.input.isKeyPressed(Keys.D)) {
|
} else if (playerControl.right) {
|
||||||
vecX = SPEED;
|
vecX = SPEED;
|
||||||
dir = 0;
|
dir = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (Gdx.input.isKeyJustPressed(Keys.SPACE)) && wood >= 7) {
|
if (playerControl.placeWall && wood >= 7 && !dead) {
|
||||||
int arrayX = ((int)(boundsFeet.x + (boundsFeet.width/2))/64);
|
int arrayX = ((int)(boundsFeet.x + (boundsFeet.width/2))/64);
|
||||||
int arrayY = ((int)(boundsFeet.y + (boundsFeet.height/2))/64);
|
int arrayY = ((int)(boundsFeet.y + (boundsFeet.height/2))/64);
|
||||||
handler.getGameState().getGrid().setFree(false, arrayX, arrayY);
|
handler.getGameState().getGrid().setFree(false, arrayX, arrayY);
|
||||||
@ -130,6 +180,12 @@ public class Player extends GameObject {
|
|||||||
wood -= 7;
|
wood -= 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actionPressed = playerControl.actionPressed;
|
||||||
|
giveWood = playerControl.giveWood;
|
||||||
|
|
||||||
|
if (State.getCurrentState() == handler.getGameState() && playerControl.pauseGame) {
|
||||||
|
handler.getGameState().setPause(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleCollision() {
|
private void handleCollision() {
|
||||||
@ -138,7 +194,43 @@ public class Player extends GameObject {
|
|||||||
if (boundsFeet.y + boundsFeet.height + vecY >= Main.HEIGHT-64) vecY = 0;
|
if (boundsFeet.y + boundsFeet.height + vecY >= Main.HEIGHT-64) vecY = 0;
|
||||||
if (boundsFeet.y + vecY <= 0) {vecY = 0;}
|
if (boundsFeet.y + vecY <= 0) {vecY = 0;}
|
||||||
|
|
||||||
|
if (!dead) {
|
||||||
handleWallCollision();
|
handleWallCollision();
|
||||||
|
if (handler.getPlayers().getNumOfPlayers() > 1) handlePlayerCollision();
|
||||||
|
} else handleDeadPlayerCollision();
|
||||||
|
|
||||||
|
handleHealerCollision();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleHealerCollision() {
|
||||||
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
|
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("Healer")) {
|
||||||
|
Healer wall = (Healer)handler.getGameObjectHandler().getGameObjects().get(i);
|
||||||
|
if (vecX < 0) {
|
||||||
|
if (wall.getCollision(boundsFeet.x + vecX, boundsFeet.y) ||
|
||||||
|
wall.getCollision(boundsFeet.x + vecX, boundsFeet.y + boundsFeet.height)) {
|
||||||
|
vecX = 0;
|
||||||
|
}
|
||||||
|
} else if (vecX > 0) {
|
||||||
|
if (wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y) ||
|
||||||
|
wall.getCollision(boundsFeet.x + boundsFeet.width + vecX, boundsFeet.y + boundsFeet.height)) {
|
||||||
|
vecX = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vecY < 0) {
|
||||||
|
if (wall.getCollision(boundsFeet.x, boundsFeet.y + vecY) ||
|
||||||
|
wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + vecY)) {
|
||||||
|
vecY = 0;
|
||||||
|
}
|
||||||
|
} else if (vecY > 0) {
|
||||||
|
if (wall.getCollision(boundsFeet.x, boundsFeet.y + boundsFeet.height + vecY) ||
|
||||||
|
wall.getCollision(boundsFeet.x + boundsFeet.width, boundsFeet.y + boundsFeet.height + vecY)) {
|
||||||
|
vecY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleWallCollision() {// Also breaking walls
|
private void handleWallCollision() {// Also breaking walls
|
||||||
@ -146,7 +238,7 @@ public class Player extends GameObject {
|
|||||||
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("ShortWall")) {
|
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("ShortWall")) {
|
||||||
ShortWall wall = (ShortWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
ShortWall wall = (ShortWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
||||||
if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && Gdx.input.isKeyPressed(Keys.E)) {
|
if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && actionPressed) {
|
||||||
if (wall.getHitPoints() > 0) {
|
if (wall.getHitPoints() > 0) {
|
||||||
wall.setHitPoints(wall.getHitPoints() - 1);
|
wall.setHitPoints(wall.getHitPoints() - 1);
|
||||||
}
|
}
|
||||||
@ -177,14 +269,22 @@ public class Player extends GameObject {
|
|||||||
}
|
}
|
||||||
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) {
|
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("TallWall")) {
|
||||||
TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
TallWall wall = (TallWall)handler.getGameObjectHandler().getGameObjects().get(i);
|
||||||
|
//build walls
|
||||||
if (wall.getState() == TallWallStates.startCreation) {
|
if (wall.getState() == TallWallStates.startCreation) {
|
||||||
if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && Gdx.input.isKeyPressed(Keys.E)) {
|
if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && actionPressed) {
|
||||||
if (wall.getHitPoints() < wall.getTotalHitPoints()) {
|
if (wall.getHitPoints() < wall.getTotalHitPoints()) {
|
||||||
wall.setHitPoints(wall.getHitPoints() + 1);
|
wall.setHitPoints(wall.getHitPoints() + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Repair walls
|
||||||
|
if (wall.getState() == TallWallStates.normal) {
|
||||||
|
if (wall.getShowHealthBounds() != null && boundsFeet.overlaps(wall.getShowHealthBounds()) && actionPressed) {
|
||||||
|
wall.setCounterIncreaseHealth(wall.getCounterIncreaseHealth() + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (vecX < 0) {
|
if (vecX < 0) {
|
||||||
if (wall.getCollision(boundsFeet.x + vecX, boundsFeet.y) ||
|
if (wall.getCollision(boundsFeet.x + vecX, boundsFeet.y) ||
|
||||||
wall.getCollision(boundsFeet.x + vecX, boundsFeet.y + boundsFeet.height)) {
|
wall.getCollision(boundsFeet.x + vecX, boundsFeet.y + boundsFeet.height)) {
|
||||||
@ -212,6 +312,45 @@ public class Player extends GameObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handlePlayerCollision() {
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (player == this) continue;
|
||||||
|
if (player.getBoundsFeet().overlaps(boundsFeet)) {
|
||||||
|
if (wood > 0 && giveWood) {
|
||||||
|
player.setWood(player.getWood() + 1);
|
||||||
|
wood -= 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleDeadPlayerCollision() {
|
||||||
|
drawHealth = false;
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (player == this) continue;
|
||||||
|
if (player.getBoundsFeet().overlaps(boundsFeet)) {
|
||||||
|
drawHealth = true;
|
||||||
|
if (player.actionPressed) {
|
||||||
|
counterToIncreaseHealth++;
|
||||||
|
if (counterToIncreaseHealth >= 4) {
|
||||||
|
hitPoints++;
|
||||||
|
counterToIncreaseHealth = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
|
if (handler.getGameObjectHandler().getGameObjects().get(i).toString().equalsIgnoreCase("Healer")) {
|
||||||
|
Healer healer = (Healer)handler.getGameObjectHandler().getGameObjects().get(i);
|
||||||
|
if (healer.getBoundsHeal().overlaps(boundsFeet)) {
|
||||||
|
drawHealth = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleAnimation() {
|
private void handleAnimation() {
|
||||||
Animation<TextureRegion> currentAnimation;
|
Animation<TextureRegion> currentAnimation;
|
||||||
if (vecY > 0) dir = 1;
|
if (vecY > 0) dir = 1;
|
||||||
@ -222,7 +361,7 @@ public class Player extends GameObject {
|
|||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 0: currentAnimation = animRight; break;
|
case 0: currentAnimation = animRight; break;
|
||||||
case 1: currentAnimation = animUp; break;
|
case 1: currentAnimation = animUp; break;
|
||||||
case 2: currentAnimation = animRight; break;
|
case 2: currentAnimation = animLeft; break;
|
||||||
case 3: currentAnimation = animDown; break;
|
case 3: currentAnimation = animDown; break;
|
||||||
default: currentAnimation = animDown; break;
|
default: currentAnimation = animDown; break;
|
||||||
}
|
}
|
||||||
@ -231,8 +370,8 @@ public class Player extends GameObject {
|
|||||||
texture = currentAnimation.getKeyFrame(elapsedTime);
|
texture = currentAnimation.getKeyFrame(elapsedTime);
|
||||||
else texture = currentAnimation.getKeyFrame(0);
|
else texture = currentAnimation.getKeyFrame(0);
|
||||||
|
|
||||||
if (texture.isFlipX()) texture.flip(true, false);
|
//if (texture.isFlipX()) texture.flip(true, false);
|
||||||
if (dir == 2 && !texture.isFlipX()) texture.flip(true, false);
|
//if (dir == 2 && !texture.isFlipX()) texture.flip(true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checks() {
|
private void checks() {
|
||||||
@ -240,6 +379,25 @@ public class Player extends GameObject {
|
|||||||
if (wood > 20) wood = 20;
|
if (wood > 20) wood = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetPlayer() {
|
||||||
|
dead = false;
|
||||||
|
|
||||||
|
actionPressed = false;
|
||||||
|
giveWood = false;
|
||||||
|
|
||||||
|
hitPoints = 0;
|
||||||
|
totalHitPoints = 450;
|
||||||
|
counterToIncreaseHealth = 0;
|
||||||
|
|
||||||
|
dir = 3;
|
||||||
|
vecX = 0;
|
||||||
|
vecY = 0;
|
||||||
|
wood = 0;
|
||||||
|
highestNumberOfTallWallsCreated = 0;
|
||||||
|
highestNumberOfTallWallsDestroyed = 0;
|
||||||
|
numberOfWoodPickedUp = 0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {return "Player";}
|
public String toString() {return "Player";}
|
||||||
|
|
||||||
@ -249,10 +407,87 @@ public class Player extends GameObject {
|
|||||||
public int getHighestNumberOfTallWallsCreated() {return highestNumberOfTallWallsCreated;}
|
public int getHighestNumberOfTallWallsCreated() {return highestNumberOfTallWallsCreated;}
|
||||||
public int getHighestNumberOfTallWallsDestroyed() {return highestNumberOfTallWallsDestroyed;}
|
public int getHighestNumberOfTallWallsDestroyed() {return highestNumberOfTallWallsDestroyed;}
|
||||||
public int getNumberOfWoodPickedUp() {return numberOfWoodPickedUp;}
|
public int getNumberOfWoodPickedUp() {return numberOfWoodPickedUp;}
|
||||||
|
public boolean getActionPressed() {return actionPressed;}
|
||||||
|
public int getHitPoints() {return hitPoints;}
|
||||||
|
public int getTotalHitPoints() {return totalHitPoints;}
|
||||||
|
public boolean isDead() {return dead;}
|
||||||
|
public int getPlayerId() {return playerid;}
|
||||||
|
|
||||||
public void setWood(int wood) {this.wood = wood;}
|
public void setWood(int wood) {this.wood = wood;}
|
||||||
public void setHighestNumberOfTallWallsCreated(int tallWalls) {this.highestNumberOfTallWallsCreated = tallWalls;}
|
public void setHighestNumberOfTallWallsCreated(int tallWalls) {this.highestNumberOfTallWallsCreated = tallWalls;}
|
||||||
public void setHighestNumberOfTallWallsDestroyed(int tallWalls) {this.highestNumberOfTallWallsDestroyed = tallWalls;}
|
public void setHighestNumberOfTallWallsDestroyed(int tallWalls) {this.highestNumberOfTallWallsDestroyed = tallWalls;}
|
||||||
public void setNumberOfWoodPickedUp(int wood) {this.numberOfWoodPickedUp = wood;}
|
public void setNumberOfWoodPickedUp(int wood) {this.numberOfWoodPickedUp = wood;}
|
||||||
|
public void setHitPoints(int hitPoints) {this.hitPoints = hitPoints;}
|
||||||
|
public void setTotalHitPoints(int hitPoints) {this.totalHitPoints = hitPoints;}
|
||||||
|
public void setDead(boolean dead) {this.dead = dead;}
|
||||||
|
public void setPlayerId(int id) {this.playerid = id;}
|
||||||
|
|
||||||
|
//Controls
|
||||||
|
private class Controls {
|
||||||
|
|
||||||
|
private static final int KEYBOARD = 0, GAMEPAD = 1;
|
||||||
|
private int controllerType;
|
||||||
|
|
||||||
|
public boolean up, down, left, right;
|
||||||
|
public boolean actionPressed, placeWall, giveWood;
|
||||||
|
public boolean pauseGame;
|
||||||
|
|
||||||
|
private int key_up, key_down, key_left, key_right;
|
||||||
|
private int key_actionPressed, key_placeWall, key_giveWood;
|
||||||
|
private int key_pauseGame;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Controls(Handler handler, int playerNum) {
|
||||||
|
defaultSetup(playerNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void defaultSetup(int playerNum) {
|
||||||
|
switch (playerNum) {
|
||||||
|
case 1: controllerType = KEYBOARD; break;
|
||||||
|
case 2: controllerType = KEYBOARD; break;
|
||||||
|
case 3: controllerType = GAMEPAD; break;
|
||||||
|
case 4: controllerType = GAMEPAD; break;
|
||||||
|
default: controllerType = KEYBOARD; break;
|
||||||
|
}
|
||||||
|
switch (playerNum) {
|
||||||
|
case 1:
|
||||||
|
key_up = Keys.W;
|
||||||
|
key_down = Keys.S;
|
||||||
|
key_left = Keys.A;
|
||||||
|
key_right = Keys.D;
|
||||||
|
key_actionPressed = Keys.E;
|
||||||
|
key_placeWall = Keys.SPACE;
|
||||||
|
key_giveWood = Keys.Q;
|
||||||
|
key_pauseGame = Keys.P;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
key_up = Keys.UP;
|
||||||
|
key_down = Keys.DOWN;
|
||||||
|
key_left = Keys.LEFT;
|
||||||
|
key_right = Keys.RIGHT;
|
||||||
|
key_actionPressed = Keys.CONTROL_RIGHT;
|
||||||
|
key_placeWall = Keys.SHIFT_RIGHT;
|
||||||
|
key_giveWood = Keys.END;
|
||||||
|
key_pauseGame = Keys.ENTER;
|
||||||
|
break;
|
||||||
|
case 3: break;
|
||||||
|
case 4: break;
|
||||||
|
default: controllerType = KEYBOARD; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update() {
|
||||||
|
up = Gdx.input.isKeyPressed(key_up);
|
||||||
|
down = Gdx.input.isKeyPressed(key_down);
|
||||||
|
left = Gdx.input.isKeyPressed(key_left);
|
||||||
|
right = Gdx.input.isKeyPressed(key_right);
|
||||||
|
actionPressed = Gdx.input.isKeyPressed(key_actionPressed);
|
||||||
|
placeWall = Gdx.input.isKeyJustPressed(key_placeWall);
|
||||||
|
giveWood = Gdx.input.isKeyJustPressed(key_giveWood);
|
||||||
|
pauseGame = Gdx.input.isKeyJustPressed(key_pauseGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,9 +78,18 @@ public class ShortWall extends Wall {
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case creation:
|
case creation:
|
||||||
elapsedTime += dt;
|
elapsedTime += dt;
|
||||||
if (!noPlayerBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) {
|
if (bounds.area() != noPlayerBounds.area()) {
|
||||||
|
boolean check = true;
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (noPlayerBounds.overlaps(player.getBoundsFeet())) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (check) {
|
||||||
bounds = new Rectangle(noPlayerBounds);
|
bounds = new Rectangle(noPlayerBounds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (elapsedTime >= 0.25 && timer <= 2) {
|
if (elapsedTime >= 0.25 && timer <= 2) {
|
||||||
timer += 0.25;
|
timer += 0.25;
|
||||||
elapsedTime -= 0.25;
|
elapsedTime -= 0.25;
|
||||||
@ -89,7 +98,7 @@ public class ShortWall extends Wall {
|
|||||||
}
|
}
|
||||||
if (timer > 2) {
|
if (timer > 2) {
|
||||||
alpha = 1;
|
alpha = 1;
|
||||||
if (bounds == null) {
|
if (bounds.area() == 0) {
|
||||||
bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
bounds = new Rectangle((int)x, (int)y, Main.WIDTH/10, Main.HEIGHT/10);
|
||||||
}
|
}
|
||||||
deathBounds = new Rectangle((int)x+8, (int)y+8, Main.WIDTH/10-16, Main.HEIGHT/10-16);
|
deathBounds = new Rectangle((int)x+8, (int)y+8, Main.WIDTH/10-16, Main.HEIGHT/10-16);
|
||||||
@ -105,7 +114,22 @@ public class ShortWall extends Wall {
|
|||||||
if (hitPoints <= 0) {
|
if (hitPoints <= 0) {
|
||||||
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) {
|
if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) {
|
||||||
handler.getGameState().getPlayer().setWood(handler.getGameState().getPlayer().getWood()+2);
|
Player[] players = new Player[handler.getPlayers().getPlayers().size];
|
||||||
|
int numOfWood = 2;
|
||||||
|
int numOfPeople = 0;
|
||||||
|
for (int p = 1; p <= players.length; p++) {
|
||||||
|
if (showHealthBounds.overlaps(handler.getPlayers().getPlayer(p).getBoundsFeet()) &&
|
||||||
|
!handler.getPlayers().getPlayer(p).isDead()) {
|
||||||
|
players[p-1] = handler.getPlayers().getPlayer(p);
|
||||||
|
numOfPeople++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numOfPeople >= 2) numOfWood = 1;
|
||||||
|
for (int p = 1; p <= players.length; p++) {
|
||||||
|
if (players[p-1] != null) {
|
||||||
|
handler.getPlayers().getPlayer(p).setWood(handler.getPlayers().getPlayer(p).getWood() + numOfWood);
|
||||||
|
}
|
||||||
|
}
|
||||||
handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight()));
|
handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight()));
|
||||||
handler.getGameState().getWallGen().setHighestNumberOfShortWallsDestroyed(handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() + 1);
|
handler.getGameState().getWallGen().setHighestNumberOfShortWallsDestroyed(handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() + 1);
|
||||||
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
||||||
@ -148,14 +172,15 @@ public class ShortWall extends Wall {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void boundCollisions() {
|
private void boundCollisions() {
|
||||||
if (deathBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) {
|
drawHealth = false;
|
||||||
handler.getGameState().getTimer().stop();
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
State.setCurrenState(handler.getGameOverState());
|
if (deathBounds.overlaps(player.getBoundsFeet())) {
|
||||||
State.getCurrentState().init();
|
player.setDead(true);
|
||||||
handler.getGameObjectHandler().dispose();
|
}
|
||||||
handler.getGameState().dispose();
|
if (showHealthBounds.overlaps(player.getBoundsFeet())) {
|
||||||
|
drawHealth = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
drawHealth = (showHealthBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
|
@ -21,6 +21,7 @@ public class TallWall extends Wall {
|
|||||||
private int imageIndex;
|
private int imageIndex;
|
||||||
private int hitPoints;
|
private int hitPoints;
|
||||||
private int totalHitPoints;
|
private int totalHitPoints;
|
||||||
|
private int counterIncreaseHealth;
|
||||||
private boolean drawHealth;
|
private boolean drawHealth;
|
||||||
private HealthBar health;
|
private HealthBar health;
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ public class TallWall extends Wall {
|
|||||||
imageIndex = 2;
|
imageIndex = 2;
|
||||||
hitPoints = 0;
|
hitPoints = 0;
|
||||||
totalHitPoints = 600;
|
totalHitPoints = 600;
|
||||||
|
counterIncreaseHealth = 0;
|
||||||
drawHealth = false;
|
drawHealth = false;
|
||||||
health = new HealthBar(handler, x, y, new TextureRegion(handler.getGameState().getHealthTexture()), totalHitPoints);
|
health = new HealthBar(handler, x, y, new TextureRegion(handler.getGameState().getHealthTexture()), totalHitPoints);
|
||||||
health.setHealth(hitPoints);
|
health.setHealth(hitPoints);
|
||||||
@ -54,7 +56,15 @@ public class TallWall extends Wall {
|
|||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case waitingCreation:
|
case waitingCreation:
|
||||||
if (!noPlayerBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet())) {
|
boolean check = true;
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (noPlayerBounds.overlaps(player.getBoundsFeet())) {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check) {
|
||||||
state = TallWallStates.startCreation;
|
state = TallWallStates.startCreation;
|
||||||
bounds = new Rectangle(noPlayerBounds);
|
bounds = new Rectangle(noPlayerBounds);
|
||||||
showHealthBounds = new Rectangle((int)x-8, (int)y-8, bounds.width+16, bounds.height+16);
|
showHealthBounds = new Rectangle((int)x-8, (int)y-8, bounds.width+16, bounds.height+16);
|
||||||
@ -71,7 +81,7 @@ public class TallWall extends Wall {
|
|||||||
noArrowBounds.width += 8;
|
noArrowBounds.width += 8;
|
||||||
noArrowBounds.y += 16;
|
noArrowBounds.y += 16;
|
||||||
imageIndex = 0;
|
imageIndex = 0;
|
||||||
handler.getGameState().getPlayer().setHighestNumberOfTallWallsCreated(handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated() + 1);
|
handler.getPlayers().getPlayer1().setHighestNumberOfTallWallsCreated(handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsCreated() + 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case normal:
|
case normal:
|
||||||
@ -81,11 +91,15 @@ public class TallWall extends Wall {
|
|||||||
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
for (int i = 0; i < handler.getGameObjectHandler().getGameObjects().size; i++) {
|
||||||
if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) {
|
if (handler.getGameObjectHandler().getGameObjects().get(i).equals(this)) {
|
||||||
handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight()));
|
handler.getGameState().getGrid().setFree(true, (int)(x / handler.getGameState().getGrid().getAreaWidth()), (int)(y / handler.getGameState().getGrid().getAreaHeight()));
|
||||||
handler.getGameState().getPlayer().setHighestNumberOfTallWallsDestroyed(handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed()+1);
|
handler.getPlayers().getPlayer1().setHighestNumberOfTallWallsDestroyed(handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsDestroyed()+1);
|
||||||
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (counterIncreaseHealth >= 3) {
|
||||||
|
if (hitPoints < totalHitPoints) hitPoints++;
|
||||||
|
counterIncreaseHealth = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
@ -111,18 +125,26 @@ public class TallWall extends Wall {
|
|||||||
public String toString() {return "TallWall";}
|
public String toString() {return "TallWall";}
|
||||||
|
|
||||||
public void boundCollisions() {
|
public void boundCollisions() {
|
||||||
drawHealth = (showHealthBounds.overlaps(handler.getGameState().getPlayer().getBoundsFeet()));
|
drawHealth = false;
|
||||||
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (showHealthBounds.overlaps(player.getBoundsFeet())) {
|
||||||
|
drawHealth = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
public int getHitPoints() {return hitPoints;}
|
public int getHitPoints() {return hitPoints;}
|
||||||
public int getTotalHitPoints() {return totalHitPoints;}
|
public int getTotalHitPoints() {return totalHitPoints;}
|
||||||
|
public int getCounterIncreaseHealth() {return counterIncreaseHealth;}
|
||||||
public Rectangle getShowHealthBounds() {return showHealthBounds;}
|
public Rectangle getShowHealthBounds() {return showHealthBounds;}
|
||||||
public Rectangle getNoPlayerBounds() {return noPlayerBounds;}
|
public Rectangle getNoPlayerBounds() {return noPlayerBounds;}
|
||||||
public Rectangle getNoArrowBounds() {return noArrowBounds;}
|
public Rectangle getNoArrowBounds() {return noArrowBounds;}
|
||||||
public TallWallStates getState() {return state;}
|
public TallWallStates getState() {return state;}
|
||||||
|
|
||||||
public void setHitPoints(int hitPoints) {this.hitPoints = hitPoints;}
|
public void setHitPoints(int hitPoints) {this.hitPoints = hitPoints;}
|
||||||
|
public void setCounterIncreaseHealth(int counter) {this.counterIncreaseHealth = counter;}
|
||||||
public void setState(TallWallStates state) {this.state = state;}
|
public void setState(TallWallStates state) {this.state = state;}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,17 @@ public class Wood extends GameObject {
|
|||||||
public String toString() {return "Wood";}
|
public String toString() {return "Wood";}
|
||||||
|
|
||||||
public void boundCollision() {
|
public void boundCollision() {
|
||||||
if (bounds.overlaps(handler.getGameState().getPlayer().getBounds())) {
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
handler.getGameState().getPlayer().setWood(handler.getGameState().getPlayer().getWood() + 1);
|
if (bounds.overlaps(player.getBounds()) && !player.isDead()) {
|
||||||
handler.getGameState().getPlayer().setNumberOfWoodPickedUp(handler.getGameState().getPlayer().getNumberOfWoodPickedUp() + 1);
|
player.setWood(player.getWood() + 1);
|
||||||
|
player.setNumberOfWoodPickedUp(player.getNumberOfWoodPickedUp() + 1);
|
||||||
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
handler.getGameObjectHandler().getGameObjects().removeValue(this, false);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
|
|
||||||
|
@ -18,17 +18,20 @@ public class WoodGUI extends GameObject {
|
|||||||
private TextureRegion[][] texture;
|
private TextureRegion[][] texture;
|
||||||
private TextureRegion backTexture;
|
private TextureRegion backTexture;
|
||||||
|
|
||||||
private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
//private Texture boundsTexture = new Texture("DodgeGame_boundsMask.png");
|
||||||
|
|
||||||
|
private int playerid;
|
||||||
|
|
||||||
//--- Constructor
|
//--- Constructor
|
||||||
public WoodGUI(Handler handler, double x, double y, TextureRegion image) {
|
public WoodGUI(Handler handler, double x, double y, TextureRegion image, int playerid) {
|
||||||
super(handler, x, y, image);
|
super(handler, x, y, image);
|
||||||
bounds = new Rectangle((int)x, (int)y, Main.WIDTH/5, Main.HEIGHT/20);
|
setGUIPosition(playerid);
|
||||||
font = new BitmapFont(Gdx.files.internal("customFont4.fnt"));
|
font = new BitmapFont(Gdx.files.internal("customFont4.fnt"));
|
||||||
font.getData().setScale(3, 3);
|
font.getData().setScale(3, 3);
|
||||||
font.setColor(Color.WHITE);
|
font.setColor(Color.WHITE);
|
||||||
backTexture = new TextureRegion(handler.getGameState().getHealthTexture()).split(16, 4)[0][0];
|
backTexture = new TextureRegion(handler.getGameState().getHealthTexture()).split(16, 4)[0][0];
|
||||||
texture = image.split(16, 16);
|
texture = image.split(16, 16);
|
||||||
|
this.playerid = playerid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -41,19 +44,29 @@ public class WoodGUI extends GameObject {
|
|||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
batch.draw(backTexture, bounds.x-bounds.width, bounds.y, bounds.width, bounds.height);
|
batch.draw(backTexture, bounds.x-bounds.width, bounds.y, bounds.width, bounds.height);
|
||||||
font.draw(batch, "x " + handler.getGameState().getPlayer().getWood(), bounds.x-64, bounds.y+Main.HEIGHT/20, 0, Align.left, false);
|
font.draw(batch, "x " + handler.getPlayers().getPlayer(playerid).getWood(), bounds.x-64, bounds.y+Main.HEIGHT/20, 0, Align.left, false);
|
||||||
batch.draw(texture[0][0], bounds.x-bounds.width+16, bounds.y-4, Main.WIDTH/16, Main.HEIGHT/16);
|
batch.draw(texture[0][0], bounds.x-bounds.width+16, bounds.y-4, Main.WIDTH/16, Main.HEIGHT/16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
font.dispose();
|
font.dispose();
|
||||||
boundsTexture.dispose();
|
//boundsTexture.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {return "WoodGUI";}
|
public String toString() {return "WoodGUI";}
|
||||||
|
|
||||||
|
private void setGUIPosition(int playerid) {
|
||||||
|
switch (playerid) {
|
||||||
|
case 1: bounds = new Rectangle((int)(Main.WIDTH/5), (int)(Main.HEIGHT-Main.HEIGHT/20), Main.WIDTH/5, Main.HEIGHT/20); break;
|
||||||
|
case 2: bounds = new Rectangle((int)(Main.WIDTH), (int)(Main.HEIGHT-Main.HEIGHT/20), Main.WIDTH/5, Main.HEIGHT/20); break;
|
||||||
|
case 3: bounds = new Rectangle((int)(Main.WIDTH/5), (int)0, Main.WIDTH/5, Main.HEIGHT/20); break;
|
||||||
|
case 4: bounds = new Rectangle((int)(Main.WIDTH), (int)0, Main.WIDTH/5, Main.HEIGHT/20); break;
|
||||||
|
default: bounds = new Rectangle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +58,7 @@ public class ExitState extends State {
|
|||||||
public void dispose() {
|
public void dispose() {
|
||||||
font.dispose();
|
font.dispose();
|
||||||
texture.dispose();
|
texture.dispose();
|
||||||
|
handler.getPlayers().dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.jalenwinslow.game.states;
|
package com.jalenwinslow.game.states;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||||
@ -14,6 +16,7 @@ public class GameOverState extends State {
|
|||||||
//--- Propreties
|
//--- Propreties
|
||||||
private Texture gameOverTexture;
|
private Texture gameOverTexture;
|
||||||
private BitmapFont font;
|
private BitmapFont font;
|
||||||
|
private float elapsedTime;
|
||||||
|
|
||||||
//--- Constructor
|
//--- Constructor
|
||||||
public GameOverState(Handler handler) {
|
public GameOverState(Handler handler) {
|
||||||
@ -32,13 +35,16 @@ public class GameOverState extends State {
|
|||||||
font = new BitmapFont(Gdx.files.internal("customFont4.fnt"));
|
font = new BitmapFont(Gdx.files.internal("customFont4.fnt"));
|
||||||
font.getData().setScale(3, 3);
|
font.getData().setScale(3, 3);
|
||||||
font.setColor(Color.WHITE);
|
font.setColor(Color.WHITE);
|
||||||
|
elapsedTime = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
if (Gdx.input.justTouched()) {
|
elapsedTime += dt;
|
||||||
|
if (elapsedTime > 1 && Gdx.input.isKeyJustPressed(Keys.ANY_KEY)) {
|
||||||
State.setCurrenState(handler.getMenuState());
|
State.setCurrenState(handler.getMenuState());
|
||||||
State.getCurrentState().init();
|
State.getCurrentState().init();
|
||||||
|
handler.getPlayers().resetPlayers();
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +52,7 @@ public class GameOverState extends State {
|
|||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
batch.draw(gameOverTexture, 0, 0, Main.WIDTH, Main.HEIGHT);
|
batch.draw(gameOverTexture, 0, 0, Main.WIDTH, Main.HEIGHT);
|
||||||
font.draw(batch, "CLICK LEFT TO CONTINUE", 16, Main.HEIGHT-16);
|
font.draw(batch, "PRESS ANY KEY TO CONTINUE", 16, Main.HEIGHT-16);
|
||||||
font.draw(batch, "SURVIVED FOR " + String.valueOf(handler.getGameState().getTimer().getTime()) + " SEC", Main.WIDTH/2, Main.HEIGHT/2 - 64, 0, Align.center, false);
|
font.draw(batch, "SURVIVED FOR " + String.valueOf(handler.getGameState().getTimer().getTime()) + " SEC", Main.WIDTH/2, Main.HEIGHT/2 - 64, 0, Align.center, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,23 +15,27 @@ public class GameState extends State{
|
|||||||
|
|
||||||
//--- Propreties
|
//--- Propreties
|
||||||
Texture background;
|
Texture background;
|
||||||
Texture playerTexture;
|
|
||||||
Texture woodTexture;
|
Texture woodTexture;
|
||||||
Texture arrowTexture;
|
Texture arrowTexture;
|
||||||
Texture wallTexture;
|
Texture wallTexture;
|
||||||
Texture tallWallTexture;
|
Texture tallWallTexture;
|
||||||
Texture healthTexture;
|
Texture healthTexture;
|
||||||
|
Texture healTexture;
|
||||||
|
|
||||||
private Player player;
|
private WoodGUI[] woodGUIs;
|
||||||
private WoodGUI woodGui;
|
private WoodGUI woodGui;
|
||||||
|
private WoodGUI woodGui2;
|
||||||
private Grid grid;
|
private Grid grid;
|
||||||
private ArrowGenerator arrowGen;
|
private ArrowGenerator arrowGen;
|
||||||
private WallGenerator wallGen;
|
private WallGenerator wallGen;
|
||||||
private WoodGenerator woodGen;
|
private WoodGenerator woodGen;
|
||||||
|
private HealerGenerator healGen;
|
||||||
private Wall[] bottomWalls;
|
private Wall[] bottomWalls;
|
||||||
private Timer timer;
|
private Timer timer;
|
||||||
private Random rand;
|
private Random rand;
|
||||||
|
|
||||||
|
private boolean pause;
|
||||||
|
|
||||||
//--- Constructor
|
//--- Constructor
|
||||||
public GameState(Handler handler) {
|
public GameState(Handler handler) {
|
||||||
super(handler);
|
super(handler);
|
||||||
@ -42,25 +46,35 @@ public class GameState extends State{
|
|||||||
@Override
|
@Override
|
||||||
public void init() {
|
public void init() {
|
||||||
background = new Texture("b&w_DodgeGame_background2.png");
|
background = new Texture("b&w_DodgeGame_background2.png");
|
||||||
playerTexture = new Texture("b&w_DodgeGame_man1.png");
|
|
||||||
woodTexture = new Texture("b&w_DodgeGame_wood1.png");
|
woodTexture = new Texture("b&w_DodgeGame_wood1.png");
|
||||||
arrowTexture = new Texture("b&w_DodgeGame_arrow.png");
|
arrowTexture = new Texture("b&w_DodgeGame_arrow.png");
|
||||||
wallTexture = new Texture("b&w_DodgeGame_wall1.png");
|
wallTexture = new Texture("b&w_DodgeGame_wall1.png");
|
||||||
tallWallTexture = new Texture("b&w_DodgeGame_tallWall1.png");
|
tallWallTexture = new Texture("b&w_DodgeGame_tallWall1.png");
|
||||||
healthTexture = new Texture("b&w_DodgeGame_health1.png");
|
healthTexture = new Texture("b&w_DodgeGame_health1.png");
|
||||||
player = new Player(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playerTexture));
|
healTexture = new Texture("b&w_DodgeGame_healer.png");
|
||||||
woodGui = new WoodGUI(handler, Main.WIDTH, 0, new TextureRegion(woodTexture));
|
//players
|
||||||
|
//numOfPlayers = handler.getPlayers().getNumOfPlayers();
|
||||||
|
//players = new Player[numOfPlayers];
|
||||||
|
//player = new Player(handler, Main.WIDTH/2-64, Main.HEIGHT/2, new TextureRegion(playerTexture), 1);
|
||||||
|
//players[0] = player;
|
||||||
|
handler.getPlayers().addPlayersToGameObjects();
|
||||||
|
woodGUIs = new WoodGUI[handler.getPlayers().getNumOfPlayers()];
|
||||||
|
for (int i = 0; i < woodGUIs.length; i++) {
|
||||||
|
woodGUIs[i] = new WoodGUI(handler, 0, 0, new TextureRegion(woodTexture), i+1);
|
||||||
|
}
|
||||||
|
|
||||||
grid = new Grid(handler);
|
grid = new Grid(handler);
|
||||||
arrowGen = new ArrowGenerator(handler, 0, 0, new TextureRegion(arrowTexture));
|
arrowGen = new ArrowGenerator(handler, 0, 0, new TextureRegion(arrowTexture));
|
||||||
wallGen = new WallGenerator(handler, 0, 0, new TextureRegion(wallTexture));
|
wallGen = new WallGenerator(handler, 0, 0, new TextureRegion(wallTexture));
|
||||||
woodGen = new WoodGenerator(handler, 0, 0, new TextureRegion(woodTexture));
|
woodGen = new WoodGenerator(handler, 0, 0, new TextureRegion(woodTexture));
|
||||||
|
healGen = new HealerGenerator(handler, 0, 0, new TextureRegion(healTexture));
|
||||||
bottomWalls = new Wall[Main.WIDTH/64];
|
bottomWalls = new Wall[Main.WIDTH/64];
|
||||||
for (int i = 0; i < Main.WIDTH/64; i++) {
|
for (int i = 0; i < Main.WIDTH/64; i++) {
|
||||||
bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture));
|
bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture));
|
||||||
}
|
}
|
||||||
timer = new Timer(handler, Main.WIDTH/2, Main.HEIGHT-(Main.HEIGHT/10+32), null);
|
timer = new Timer(handler, Main.WIDTH/2, Main.HEIGHT-(Main.HEIGHT/10+32), null);
|
||||||
|
pause = false;
|
||||||
|
|
||||||
handler.getGameObjectHandler().add(player);
|
|
||||||
handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length);
|
handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +84,16 @@ public class GameState extends State{
|
|||||||
arrowGen.update(dt);
|
arrowGen.update(dt);
|
||||||
wallGen.update(dt);
|
wallGen.update(dt);
|
||||||
woodGen.update(dt);
|
woodGen.update(dt);
|
||||||
|
healGen.update(dt);
|
||||||
timer.update(dt);
|
timer.update(dt);
|
||||||
woodGui.update(dt);
|
for (WoodGUI wgui : woodGUIs) {
|
||||||
if (Gdx.input.isKeyJustPressed(Keys.P)) {
|
wgui.update(dt);
|
||||||
|
}
|
||||||
|
if (pause) {
|
||||||
State.setCurrenState(handler.getPauseState());
|
State.setCurrenState(handler.getPauseState());
|
||||||
State.getCurrentState().init();
|
State.getCurrentState().init();
|
||||||
}
|
}
|
||||||
|
checkForPlayers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,33 +103,56 @@ public class GameState extends State{
|
|||||||
arrowGen.render(batch);
|
arrowGen.render(batch);
|
||||||
wallGen.render(batch);
|
wallGen.render(batch);
|
||||||
woodGen.render(batch);
|
woodGen.render(batch);
|
||||||
|
healGen.render(batch);
|
||||||
timer.render(batch);
|
timer.render(batch);
|
||||||
woodGui.render(batch);
|
for (WoodGUI wgui : woodGUIs) wgui.render(batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (background != null) background.dispose();
|
if (background != null) background.dispose();
|
||||||
if (playerTexture != null) playerTexture.dispose();
|
|
||||||
if (arrowTexture != null) arrowTexture.dispose();
|
if (arrowTexture != null) arrowTexture.dispose();
|
||||||
if (wallTexture != null) wallTexture.dispose();
|
if (wallTexture != null) wallTexture.dispose();
|
||||||
if (woodTexture != null) woodTexture.dispose();
|
if (woodTexture != null) woodTexture.dispose();
|
||||||
if (tallWallTexture != null) tallWallTexture.dispose();
|
if (tallWallTexture != null) tallWallTexture.dispose();
|
||||||
if (healthTexture != null) healthTexture.dispose();
|
if (healthTexture != null) healthTexture.dispose();
|
||||||
|
if (healTexture != null) healTexture.dispose();
|
||||||
if (timer != null) timer.dispose();
|
if (timer != null) timer.dispose();
|
||||||
if (woodGui != null) woodGui.dispose();
|
if (woodGui != null) woodGui.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkForPlayers() {
|
||||||
|
boolean check = false;
|
||||||
|
for (int i = 0; i < handler.getPlayers().getNumOfPlayers(); i++) {
|
||||||
|
if (handler.getPlayers().getPlayer(i+1).isDead()) {
|
||||||
|
check = true;
|
||||||
|
} else {
|
||||||
|
check = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (check) {
|
||||||
|
handler.getGameState().getTimer().stop();
|
||||||
|
State.setCurrenState(handler.getGameOverState());
|
||||||
|
State.getCurrentState().init();
|
||||||
|
handler.getGameObjectHandler().dispose();
|
||||||
|
handler.getGameState().dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
public Texture getHealthTexture() {return healthTexture;}
|
public Texture getHealthTexture() {return healthTexture;}
|
||||||
public Texture getTallWallTexture() {return tallWallTexture;}
|
public Texture getTallWallTexture() {return tallWallTexture;}
|
||||||
|
|
||||||
public Player getPlayer() {return player;}
|
|
||||||
public Grid getGrid() {return grid;}
|
public Grid getGrid() {return grid;}
|
||||||
public ArrowGenerator getArrowGen() {return arrowGen;}
|
public ArrowGenerator getArrowGen() {return arrowGen;}
|
||||||
public WallGenerator getWallGen() {return wallGen;}
|
public WallGenerator getWallGen() {return wallGen;}
|
||||||
public WoodGenerator getWoodGen() {return woodGen;}
|
public WoodGenerator getWoodGen() {return woodGen;}
|
||||||
|
public HealerGenerator getHealGen() {return healGen;}
|
||||||
public Wall[] getBottomWalls() {return bottomWalls;}
|
public Wall[] getBottomWalls() {return bottomWalls;}
|
||||||
public Timer getTimer() {return timer;}
|
public Timer getTimer() {return timer;}
|
||||||
|
public boolean getPause() {return pause;}
|
||||||
|
|
||||||
|
public void setPause(boolean pause) {this.pause = pause;}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
package com.jalenwinslow.game.states;
|
package com.jalenwinslow.game.states;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
|
import com.badlogic.gdx.Input;
|
||||||
|
import com.badlogic.gdx.Input.Keys;
|
||||||
import com.badlogic.gdx.graphics.Texture;
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.jalenwinslow.game.Handler;
|
import com.jalenwinslow.game.Handler;
|
||||||
import com.jalenwinslow.game.Main;
|
import com.jalenwinslow.game.Main;
|
||||||
import com.jalenwinslow.game.gameobjects.Button;
|
import com.jalenwinslow.game.gameobjects.Button;
|
||||||
|
import com.jalenwinslow.game.gameobjects.ControllerButton;
|
||||||
import com.jalenwinslow.game.gameobjects.Player;
|
import com.jalenwinslow.game.gameobjects.Player;
|
||||||
import com.jalenwinslow.game.gameobjects.ScoreBoard;
|
import com.jalenwinslow.game.gameobjects.ScoreBoard;
|
||||||
import com.jalenwinslow.game.gameobjects.ShortWall;
|
import com.jalenwinslow.game.gameobjects.ShortWall;
|
||||||
import com.jalenwinslow.game.gameobjects.Wall;
|
import com.jalenwinslow.game.gameobjects.Wall;
|
||||||
|
import com.jalenwinslow.game.utils.Players;
|
||||||
|
|
||||||
public class MenuState extends State{
|
public class MenuState extends State{
|
||||||
|
|
||||||
@ -19,14 +24,13 @@ public class MenuState extends State{
|
|||||||
Texture menuBg;
|
Texture menuBg;
|
||||||
//Texture playButtonTexture;
|
//Texture playButtonTexture;
|
||||||
Texture buttonTexture;
|
Texture buttonTexture;
|
||||||
Texture playerTexture;
|
|
||||||
Texture wallTexture;
|
Texture wallTexture;
|
||||||
Texture healthTexture;
|
Texture healthTexture;
|
||||||
Texture scoreBoardTexture;
|
Texture scoreBoardTexture;
|
||||||
|
|
||||||
private Button[] buttons;
|
private Button[] buttons;
|
||||||
|
private ControllerButton[] cButtons;
|
||||||
private Button backButton;
|
private Button backButton;
|
||||||
private Player player;
|
|
||||||
private Wall[] bottomWalls;
|
private Wall[] bottomWalls;
|
||||||
private ScoreBoard scoreBoard;
|
private ScoreBoard scoreBoard;
|
||||||
//private PlayButton playBtn;
|
//private PlayButton playBtn;
|
||||||
@ -45,22 +49,30 @@ public class MenuState extends State{
|
|||||||
menuBg = new Texture("b&w_DodgeGame_background2.png");
|
menuBg = new Texture("b&w_DodgeGame_background2.png");
|
||||||
//playButtonTexture = new Texture("b&w_DodgeGame_playButton.png");
|
//playButtonTexture = new Texture("b&w_DodgeGame_playButton.png");
|
||||||
buttonTexture = new Texture("b&w_DodgeGame_buttons1.png");
|
buttonTexture = new Texture("b&w_DodgeGame_buttons1.png");
|
||||||
playerTexture = new Texture("b&w_DodgeGame_man1.png");
|
|
||||||
wallTexture = new Texture("b&w_DodgeGame_wall1.png");
|
wallTexture = new Texture("b&w_DodgeGame_wall1.png");
|
||||||
healthTexture = new Texture("b&w_DodgeGame_health1.png");
|
healthTexture = new Texture("b&w_DodgeGame_health1.png");
|
||||||
scoreBoardTexture = new Texture("b&w_DodgeGame_scoreBoard.png");
|
scoreBoardTexture = new Texture("b&w_DodgeGame_scoreBoard.png");
|
||||||
buttons = new Button[3];
|
buttons = new Button[4];
|
||||||
buttons[0] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "PLAY", 6);
|
buttons[0] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "PLAY", 6);
|
||||||
buttons[1] = new Button(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "STATS", 6);
|
buttons[1] = new Button(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "STATS", 6);
|
||||||
buttons[2] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "EXIT", 6 );
|
buttons[2] = new Button(handler, Main.WIDTH/4-64, Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "EXIT", 6 );
|
||||||
player = new Player(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playerTexture));
|
buttons[3] = new Button(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "MULTI-\nPLAYER", 3);
|
||||||
|
cButtons = new ControllerButton[4];
|
||||||
|
cButtons[0] = new ControllerButton(handler, Main.WIDTH/4-64, Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "PLAYER 1", 4, 1);
|
||||||
|
cButtons[1] = new ControllerButton(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT*3/4-96, new TextureRegion(buttonTexture), "PLAYER\n2", 4, 2);
|
||||||
|
cButtons[2] = new ControllerButton(handler, Main.WIDTH/4-64, Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "PLAYER\n3", 4 , 3);
|
||||||
|
cButtons[3] = new ControllerButton(handler, Main.WIDTH*3/4-(64*2), Main.HEIGHT/4+32, new TextureRegion(buttonTexture), "PLAYER\n4", 4, 4);
|
||||||
|
//player
|
||||||
|
if (handler.getPlayers().getNumOfPlayers() == 0) {
|
||||||
|
handler.getPlayers().addPlayer(new Player(handler, Main.WIDTH/2-64, Main.HEIGHT/2, new TextureRegion(Players.player1Texture), 1));
|
||||||
|
} else handler.getPlayers().addPlayersToGameObjects();
|
||||||
|
|
||||||
backButton = new Button(handler, Main.WIDTH/2-96, Main.HEIGHT/4-64, new TextureRegion(buttonTexture), "BACK", 6);
|
backButton = new Button(handler, Main.WIDTH/2-96, Main.HEIGHT/4-64, new TextureRegion(buttonTexture), "BACK", 6);
|
||||||
bottomWalls = new Wall[Main.WIDTH/64];
|
bottomWalls = new Wall[Main.WIDTH/64];
|
||||||
for (int i = 0; i < bottomWalls.length; i++) {
|
for (int i = 0; i < bottomWalls.length; i++) {
|
||||||
bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture));
|
bottomWalls[i] = new ShortWall(handler, 64*i, 0, new TextureRegion(wallTexture));
|
||||||
}
|
}
|
||||||
scoreBoard = new ScoreBoard(handler, Main.WIDTH/8, Main.HEIGHT*3/8, new TextureRegion(scoreBoardTexture));
|
scoreBoard = new ScoreBoard(handler, Main.WIDTH/8, Main.HEIGHT*3/8, new TextureRegion(scoreBoardTexture));
|
||||||
handler.getGameObjectHandler().add(player);
|
|
||||||
handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length);
|
handler.getGameObjectHandler().getGameObjects().addAll(bottomWalls, 0, bottomWalls.length);
|
||||||
//playBtn = new PlayButton(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playButtonTexture));
|
//playBtn = new PlayButton(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(playButtonTexture));
|
||||||
}
|
}
|
||||||
@ -72,10 +84,19 @@ public class MenuState extends State{
|
|||||||
for (Button button : buttons) {
|
for (Button button : buttons) {
|
||||||
if (button != null) button.update(dt);
|
if (button != null) button.update(dt);
|
||||||
}
|
}
|
||||||
|
addPlayers();
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
backButton.update(dt);
|
backButton.update(dt);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
for (ControllerButton cb : cButtons) {
|
||||||
|
if (cb != null) cb.update(dt);
|
||||||
|
}
|
||||||
|
backButton.update(dt);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
backButton.update(dt);
|
||||||
default:
|
default:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -96,6 +117,14 @@ public class MenuState extends State{
|
|||||||
scoreBoard.render(batch);
|
scoreBoard.render(batch);
|
||||||
backButton.render(batch);
|
backButton.render(batch);
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
|
for (ControllerButton cb : cButtons) {
|
||||||
|
if (cb != null) cb.render(batch);
|
||||||
|
}
|
||||||
|
backButton.render(batch);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
backButton.render(batch);
|
||||||
default:
|
default:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -108,7 +137,6 @@ public class MenuState extends State{
|
|||||||
public void dispose() {
|
public void dispose() {
|
||||||
menuBg.dispose();
|
menuBg.dispose();
|
||||||
buttonTexture.dispose();
|
buttonTexture.dispose();
|
||||||
playerTexture.dispose();
|
|
||||||
wallTexture.dispose();
|
wallTexture.dispose();
|
||||||
healthTexture.dispose();
|
healthTexture.dispose();
|
||||||
scoreBoardTexture.dispose();
|
scoreBoardTexture.dispose();
|
||||||
@ -116,13 +144,15 @@ public class MenuState extends State{
|
|||||||
for (Button button: buttons) {button.dispose();}
|
for (Button button: buttons) {button.dispose();}
|
||||||
backButton.dispose();
|
backButton.dispose();
|
||||||
//playButtonTexture.dispose();
|
//playButtonTexture.dispose();
|
||||||
//player = null;
|
}
|
||||||
//buttons = null;
|
|
||||||
//bottomWalls = null;
|
public void addPlayers() {
|
||||||
|
if (Gdx.input.isKeyJustPressed(Keys.NUM_2)) {
|
||||||
|
handler.getPlayers().addPlayer(new Player(handler, Main.WIDTH/2, Main.HEIGHT/2, new TextureRegion(Players.player2Texture), 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--- Getters and Setters
|
//--- Getters and Setters
|
||||||
public Player getPlayer() {return player;}
|
|
||||||
public Texture getHealthTexture() {return healthTexture;}
|
public Texture getHealthTexture() {return healthTexture;}
|
||||||
public int getSubState() {return subState;}
|
public int getSubState() {return subState;}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
import com.jalenwinslow.game.Handler;
|
import com.jalenwinslow.game.Handler;
|
||||||
import com.jalenwinslow.game.Main;
|
import com.jalenwinslow.game.Main;
|
||||||
|
import com.jalenwinslow.game.gameobjects.Player;
|
||||||
|
|
||||||
public class PauseState extends State {
|
public class PauseState extends State {
|
||||||
|
|
||||||
@ -31,11 +32,14 @@ public class PauseState extends State {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float dt) {
|
public void update(float dt) {
|
||||||
if (Gdx.input.isKeyJustPressed(Keys.P)) {
|
for (Player player : handler.getPlayers().getPlayers()) {
|
||||||
|
if (player.returnPausePressed()) {
|
||||||
State.setCurrenState(handler.getGameState());
|
State.setCurrenState(handler.getGameState());
|
||||||
|
handler.getGameState().setPause(false);
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(SpriteBatch batch) {
|
public void render(SpriteBatch batch) {
|
||||||
|
97
core/src/com/jalenwinslow/game/utils/Players.java
Normal file
97
core/src/com/jalenwinslow/game/utils/Players.java
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package com.jalenwinslow.game.utils;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.jalenwinslow.game.Handler;
|
||||||
|
import com.jalenwinslow.game.Main;
|
||||||
|
import com.jalenwinslow.game.gameobjects.Player;
|
||||||
|
|
||||||
|
public class Players {
|
||||||
|
|
||||||
|
//--- Propreties
|
||||||
|
public static Texture playerHealthTexture = new Texture("b&w_DodgeGame_health1.png");
|
||||||
|
public static Texture player1Texture = new Texture("b&w_DodgeGame_man1.png");
|
||||||
|
public static Texture player2Texture = new Texture("b&w_DodgeGame_woman1.png");
|
||||||
|
|
||||||
|
private Handler handler;
|
||||||
|
private Array<Player> players;
|
||||||
|
private int numOfPlayers;
|
||||||
|
|
||||||
|
//--- Constructor
|
||||||
|
public Players(Handler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
players = new Array<Player>();
|
||||||
|
numOfPlayers = players.size;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--- Methods
|
||||||
|
|
||||||
|
|
||||||
|
public void addPlayer(Player player) {
|
||||||
|
if (numOfPlayers < 4) {
|
||||||
|
players.add(player);
|
||||||
|
handler.getGameObjectHandler().add(player);
|
||||||
|
numOfPlayers = players.size;
|
||||||
|
for (int i = 0; i < players.size; i++) {
|
||||||
|
players.get(i).setPlayerId(i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayersToGameObjects() {
|
||||||
|
for (Player player : players) {
|
||||||
|
handler.getGameObjectHandler().add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(Player player) {
|
||||||
|
if (numOfPlayers > 0) {
|
||||||
|
players.removeValue(player, false);
|
||||||
|
handler.getGameObjectHandler().getGameObjects().removeValue(player, false);
|
||||||
|
numOfPlayers = players.size;
|
||||||
|
for (int i = 0; i < players.size; i++) {
|
||||||
|
players.get(i).setPlayerId(i+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer(int index) {
|
||||||
|
if (players.get(index-1) != null)
|
||||||
|
return players.get(index-1);
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void centerPlayers() {
|
||||||
|
if (players.get(0) != null) players.get(0).setPosition(Main.WIDTH/2-Main.WIDTH/10, Main.HEIGHT/2);
|
||||||
|
if (numOfPlayers == 2 && players.get(1) != null) players.get(1).setPosition(Main.WIDTH/2, Main.HEIGHT/2);
|
||||||
|
if (numOfPlayers == 3 && players.get(2) != null) players.get(2).setPosition(Main.WIDTH/2-Main.WIDTH/10, Main.HEIGHT/2-Main.HEIGHT/10);
|
||||||
|
if (numOfPlayers == 4 && players.get(3) != null) players.get(3).setPosition(Main.WIDTH/2, Main.HEIGHT/2-Main.HEIGHT/10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetPlayers() {
|
||||||
|
for (Player player : players) {
|
||||||
|
player.resetPlayer();
|
||||||
|
}
|
||||||
|
centerPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose() {
|
||||||
|
player1Texture.dispose();
|
||||||
|
playerHealthTexture.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
//--- Getters and Setters
|
||||||
|
public Array<Player> getPlayers() {return players;}
|
||||||
|
public Player getPlayer1() {return players.get(0);}
|
||||||
|
public Player getPlayer2() {return players.get(1);}
|
||||||
|
public Player getPlayer3() {return players.get(2);}
|
||||||
|
public Player getPlayer4() {return players.get(3);}
|
||||||
|
public int getNumOfPlayers() {return numOfPlayers;}
|
||||||
|
|
||||||
|
public void setPlayer(Player player, int playerNum) {players.set(playerNum-1, player);}
|
||||||
|
public void setNumOfPlayers(int num) {this.numOfPlayers = num;}
|
||||||
|
|
||||||
|
}
|
@ -38,15 +38,15 @@ public class Score {
|
|||||||
if (handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() > highestNumberOfShortWallsDestroyed)
|
if (handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed() > highestNumberOfShortWallsDestroyed)
|
||||||
highestNumberOfShortWallsDestroyed = handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed();
|
highestNumberOfShortWallsDestroyed = handler.getGameState().getWallGen().getHighestNumberOfShortWallsDestroyed();
|
||||||
|
|
||||||
if (handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated() > highestNumberOfTallWallsCreated)
|
if (handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsCreated() > highestNumberOfTallWallsCreated)
|
||||||
highestNumberOfTallWallsCreated = handler.getGameState().getPlayer().getHighestNumberOfTallWallsCreated();
|
highestNumberOfTallWallsCreated = handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsCreated();
|
||||||
if (handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce() > highestNumberOfTallWallsAtOnce)
|
if (handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce() > highestNumberOfTallWallsAtOnce)
|
||||||
highestNumberOfTallWallsAtOnce = handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce();
|
highestNumberOfTallWallsAtOnce = handler.getGameObjectHandler().getHighestNumberOfTallWallsAtOnce();
|
||||||
if (handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed() > highestNumberOfTallWallsDestroyed)
|
if (handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsDestroyed() > highestNumberOfTallWallsDestroyed)
|
||||||
highestNumberOfTallWallsDestroyed = handler.getGameState().getPlayer().getHighestNumberOfTallWallsDestroyed();
|
highestNumberOfTallWallsDestroyed = handler.getPlayers().getPlayer1().getHighestNumberOfTallWallsDestroyed();
|
||||||
|
|
||||||
if (handler.getGameState().getPlayer().getNumberOfWoodPickedUp() > highestNumberOfWoodPickedUp)
|
if (handler.getPlayers().getPlayer1().getNumberOfWoodPickedUp() > highestNumberOfWoodPickedUp)
|
||||||
highestNumberOfWoodPickedUp = handler.getGameState().getPlayer().getNumberOfWoodPickedUp();
|
highestNumberOfWoodPickedUp = handler.getPlayers().getPlayer1().getNumberOfWoodPickedUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getScoresFromFile() {
|
public void getScoresFromFile() {
|
||||||
|
55
desktop/build_1.gradle
Normal file
55
desktop/build_1.gradle
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
apply plugin: "java"
|
||||||
|
|
||||||
|
sourceCompatibility = 1.6
|
||||||
|
sourceSets.main.java.srcDirs = [ "src/" ]
|
||||||
|
|
||||||
|
project.ext.mainClassName = "com.jwinslow.game.desktop.DesktopLauncher"
|
||||||
|
project.ext.assetsDir = new File("../android/assets");
|
||||||
|
|
||||||
|
task run(dependsOn: classes, type: JavaExec) {
|
||||||
|
main = project.mainClassName
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
standardInput = System.in
|
||||||
|
workingDir = project.assetsDir
|
||||||
|
ignoreExitValue = true
|
||||||
|
}
|
||||||
|
|
||||||
|
task debug(dependsOn: classes, type: JavaExec) {
|
||||||
|
main = project.mainClassName
|
||||||
|
classpath = sourceSets.main.runtimeClasspath
|
||||||
|
standardInput = System.in
|
||||||
|
workingDir = project.assetsDir
|
||||||
|
ignoreExitValue = true
|
||||||
|
debug = true
|
||||||
|
}
|
||||||
|
|
||||||
|
task dist(type: Jar) {
|
||||||
|
from files(sourceSets.main.output.classesDir)
|
||||||
|
from files(sourceSets.main.output.resourcesDir)
|
||||||
|
from {configurations.compile.collect {zipTree(it)}}
|
||||||
|
from files(project.assetsDir);
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes 'Main-Class': project.mainClassName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dist.dependsOn classes
|
||||||
|
|
||||||
|
eclipse {
|
||||||
|
project {
|
||||||
|
name = appName + "-desktop"
|
||||||
|
linkedResource name: 'assets', type: '2', location: 'PARENT-1-PROJECT_LOC/android/assets'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task afterEclipseImport(description: "Post processing after project generation", group: "IDE") {
|
||||||
|
doLast {
|
||||||
|
def classpath = new XmlParser().parse(file(".classpath"))
|
||||||
|
new Node(classpath, "classpathentry", [ kind: 'src', path: 'assets' ]);
|
||||||
|
def writer = new FileWriter(file(".classpath"))
|
||||||
|
def printer = new XmlNodePrinter(new PrintWriter(writer))
|
||||||
|
printer.setPreserveWhitespace(true)
|
||||||
|
printer.print(classpath)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user