diff --git a/core/assets/hit.png b/core/assets/hit.png new file mode 100644 index 0000000..ce2d65d Binary files /dev/null and b/core/assets/hit.png differ diff --git a/core/assets/earrape.mp3 b/core/assets/sound/earrape.mp3 similarity index 100% rename from core/assets/earrape.mp3 rename to core/assets/sound/earrape.mp3 diff --git a/core/assets/sound/hit.mp3 b/core/assets/sound/hit.mp3 new file mode 100644 index 0000000..ff586b9 Binary files /dev/null and b/core/assets/sound/hit.mp3 differ diff --git a/core/assets/music.mp3 b/core/assets/sound/music.mp3 similarity index 100% rename from core/assets/music.mp3 rename to core/assets/sound/music.mp3 diff --git a/core/src/netwerkprog/game/client/MainGame.java b/core/src/netwerkprog/game/client/MainGame.java index f15ff4a..1b6b858 100644 --- a/core/src/netwerkprog/game/client/MainGame.java +++ b/core/src/netwerkprog/game/client/MainGame.java @@ -12,6 +12,7 @@ import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.utils.TimeUtils; import netwerkprog.game.client.game.GAMESTATE; import netwerkprog.game.client.game.characters.Agent; import netwerkprog.game.client.game.characters.Hacker; @@ -44,6 +45,7 @@ public class MainGame extends ApplicationAdapter { private GlyphLayout layout; private GAMESTATE gamestate; private Faction chosenFaction; + private long lastTimeCounted = 0; private Map map; public MapRenderer mapRenderer; @@ -101,7 +103,7 @@ public class MainGame extends ApplicationAdapter { // this.tree.insert(new Hacker(,new BodySwap())); - playSong(); +// playSong(); // connectToServer(); @@ -113,6 +115,7 @@ public class MainGame extends ApplicationAdapter { Texture texture = assets.get("core/assets/characters.png"); TextureRegion[][] characters = TextureRegion.split(texture, 32, 32); this.team = new Team(); + this.enemyTeam = new Team(); for (int i = 1; i <= 5; i++) { GameCharacter temp = new Hacker("hacker" + i, characters[5][0], new BodySwap("test")); @@ -195,9 +198,12 @@ public class MainGame extends ApplicationAdapter { * update method that does all calculation before something is being drawn */ public void update() { + frameRate.update(); camera.update(); this.gameInputProcessor.update(); + this.team.update(Gdx.graphics.getDeltaTime()); + this.enemyTeam.update(Gdx.graphics.getDeltaTime()); } @Override diff --git a/core/src/netwerkprog/game/client/game/characters/Team.java b/core/src/netwerkprog/game/client/game/characters/Team.java index daa3a01..caf9145 100644 --- a/core/src/netwerkprog/game/client/game/characters/Team.java +++ b/core/src/netwerkprog/game/client/game/characters/Team.java @@ -54,6 +54,12 @@ public class Team { return null; } + public void update(double deltaTime) { + for (GameCharacter character : this.members) { + character.update(deltaTime); + } + } + public boolean isDead() { int dead = 0; for (GameCharacter character : this.members) { diff --git a/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java b/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java index 3fa795d..b5ce136 100644 --- a/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java +++ b/core/src/netwerkprog/game/client/game/map/GameInputProcessor.java @@ -125,7 +125,7 @@ public class GameInputProcessor implements InputProcessor { System.out.println("HACKER"); mainGame.setChosenFaction(Faction.HACKER); mainGame.initCharacters(); - camera.translate(-400,0); + camera.translate(-400, 0); mainGame.setGamestate(GAMESTATE.PLAYING); } @@ -163,8 +163,10 @@ public class GameInputProcessor implements InputProcessor { } // clicking on enemy if (mainGame.hasCharacterSelected() && gameTile.containsCharacter() && gameTile.getCharacter().getFaction() != mainGame.getChosenFaction()) { - if (mainGame.mapRenderer.getSurroundedTilesOfCurrentCharacter().contains(gameTile)) - gameTile.getCharacter().damage(10); + if (mainGame.mapRenderer.getSurroundedTilesOfCurrentCharacter().contains(gameTile)) { + gameTile.getCharacter().damage(10); + + } } // set selected character if (!mainGame.hasCharacterSelected() && gameTile.containsCharacter()) { diff --git a/core/src/netwerkprog/game/client/game/map/MapRenderer.java b/core/src/netwerkprog/game/client/game/map/MapRenderer.java index d745a88..0e69407 100644 --- a/core/src/netwerkprog/game/client/game/map/MapRenderer.java +++ b/core/src/netwerkprog/game/client/game/map/MapRenderer.java @@ -27,6 +27,7 @@ public class MapRenderer implements Renderable { private MainGame mainGame; private Texture square; private Texture square2; + private Texture hitMarker; public static TextureRegion FLOOR_TILE; @@ -62,9 +63,11 @@ public class MapRenderer implements Renderable { mainGame.assets.load("square.png", Texture.class); mainGame.assets.load("square2.png", Texture.class); mainGame.assets.load(tilePath, Texture.class); + mainGame.assets.load("hit.png",Texture.class); mainGame.assets.finishLoading(); square = mainGame.assets.get("square.png"); square2 = mainGame.assets.get("square2.png"); + hitMarker = mainGame.assets.get("hit.png"); Texture texture = mainGame.assets.get(tilePath); TextureRegion[][] tileTextures = TextureRegion.split(texture, 32, 32); @@ -118,7 +121,13 @@ public class MapRenderer implements Renderable { batch.draw(cur.getTextureRegion(), cur.x, cur.y); if (cur.containsCharacter()) { - batch.draw(cur.getCharacter().getTextureRegion(), cur.x, cur.y); + GameCharacter character = cur.getCharacter(); + batch.draw(character.getTextureRegion(), cur.x, cur.y); + if (character.isShowingAnimation()) { +// System.out.println("animation"); + batch.draw(hitMarker,cur.x,cur.y); + } + if (cur.getCharacter().equals(mainGame.getSelectedCharacter())) { batch.draw(square, cur.x, cur.y); diff --git a/core/src/netwerkprog/game/util/application/Timer.java b/core/src/netwerkprog/game/util/application/Timer.java index 11d61fb..2d8174f 100644 --- a/core/src/netwerkprog/game/util/application/Timer.java +++ b/core/src/netwerkprog/game/util/application/Timer.java @@ -38,6 +38,7 @@ public class Timer implements Updatable { public void start() { this.timeout = 0; + System.out.println("starting timer for " + wait + ", timeout is " + this.timeout); } public void stop() { @@ -54,7 +55,7 @@ public class Timer implements Updatable { public boolean timeout() { if (this.timeout == -1) { // timeout has occurred and is not looped - return false; + return true; } if (this.timeout - 1 < 0) { @@ -89,11 +90,14 @@ public class Timer implements Updatable { @Override public void update(double deltaTime) { + System.out.println("timeout: " + this.timeout); if (this.timeout != -1) { // Only update when timer is not aborted this.time += deltaTime; + System.out.println("time is " + this.time); if (this.time >= this.wait) { // timeout occurred + System.out.println("timeout occurred, time is " + this.time); this.time -= this.wait; this.timeout++; } diff --git a/core/src/netwerkprog/game/util/game/GameCharacter.java b/core/src/netwerkprog/game/util/game/GameCharacter.java index 83689b7..0eb629c 100644 --- a/core/src/netwerkprog/game/util/game/GameCharacter.java +++ b/core/src/netwerkprog/game/util/game/GameCharacter.java @@ -1,9 +1,11 @@ package netwerkprog.game.util.game; +import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.scenes.scene2d.Actor; import netwerkprog.game.client.game.map.GameTile; +import netwerkprog.game.util.application.Timer; import java.util.ArrayList; import java.util.Arrays; @@ -19,6 +21,8 @@ public abstract class GameCharacter extends Actor implements Comparable allowedToMove; + protected boolean damageAnimation = false; + protected Timer hitAnimationTimer; public GameCharacter(String name, Faction faction, TextureRegion textureRegion, Ability... abilities) { super(); @@ -29,6 +33,7 @@ public abstract class GameCharacter extends Actor implements Comparable(); + this.hitAnimationTimer = new Timer(5000); } public String getName() { @@ -58,7 +63,9 @@ public abstract class GameCharacter extends Actor implements Comparable