diff --git a/Data/img/Image_prof/Mudry.png b/Data/img/Image_prof/Mudry.png new file mode 100644 index 0000000..164d5f7 Binary files /dev/null and b/Data/img/Image_prof/Mudry.png differ diff --git a/Data/img/Image_prof/Mudry.xcf b/Data/img/Image_prof/Mudry.xcf new file mode 100644 index 0000000..370935c Binary files /dev/null and b/Data/img/Image_prof/Mudry.xcf differ diff --git a/src/Control/Keyboard.java b/src/Control/Keyboard.java index 56721ac..3da4174 100644 --- a/src/Control/Keyboard.java +++ b/src/Control/Keyboard.java @@ -1,23 +1,9 @@ package Control; -import com.badlogic.gdx.Input; - import Screen.ScreenPlayer; public class Keyboard { public void keyDown(int keycode, ScreenPlayer sp, Controller c) { - switch (keycode) { - case Input.Keys.Z: - if (sp.sm.zoom == 1.0) { - sp.sm.zoom = 0.5f; - } else { - sp.sm.zoom = 1; - } - return; - - default: - break; - } c.keyStatus.put(keycode, true); } public void onKeyUp(int keycode, ScreenPlayer sp, Controller c) { diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 2164933..89f6078 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -1,10 +1,13 @@ package Entity; -import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.math.Vector2; + +import Main.Settings; public class Enemy extends Character{ private String branch; + public int recoveredTime = Settings.RECOVERED; diff --git a/src/Entity/Player.java b/src/Entity/Player.java index ca48738..1385a04 100644 --- a/src/Entity/Player.java +++ b/src/Entity/Player.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.math.Vector2; import Control.Controller; import Main.PokeMudry; +import Main.Settings; import Screen.ScreenMap; public class Player extends Character{ @@ -77,6 +78,8 @@ public class Player extends Character{ if(onDoor){ + long time = System.currentTimeMillis(); + while (System.currentTimeMillis()-time < Settings.SWITCHMAPTIME) { } String nMap = null; Integer x = null; Integer y = null; diff --git a/src/Game/Battle.java b/src/Game/Battle.java index 915ffd2..f724359 100644 --- a/src/Game/Battle.java +++ b/src/Game/Battle.java @@ -45,6 +45,7 @@ public class Battle { } else if( getLineSpeech() == 5 || getLineSpeech() == 6){ finish(); + e.recoveredTime = 0; } else if(0 < getLineSpeech() && getLineSpeech() < 4){ checkAnswer(answer); diff --git a/src/Main/PokeMudry.java b/src/Main/PokeMudry.java index 632cb73..39eae5b 100644 --- a/src/Main/PokeMudry.java +++ b/src/Main/PokeMudry.java @@ -1,12 +1,11 @@ package Main; import java.util.Vector; -import com.badlogic.gdx.Input; import Control.Controller; +import Entity.Character.Direction; import Entity.Enemy; import Entity.Entity; -import Entity.Character.Direction; import Game.Battle; import Screen.ScreenBattle; import Screen.ScreenMap; @@ -20,6 +19,8 @@ public class PokeMudry extends PortableApplication { private Controller controller; private static Vector enemies = new Vector<>(); private static Vector entities = new Vector<>(); + private long beginTime; + private long lastMesure; public static boolean front_montant = false; @@ -42,7 +43,7 @@ public class PokeMudry extends PortableApplication { public void onInit() { sp.init(); controller.init(); - + // add player, create and add all enemies in entities entities.add((Entity) sp.p); enemies.add(new Enemy("Mudry", 5, 11, "lumberjack_sheet32", "21N304", 25, "informatique", Direction.DOWN)); @@ -51,11 +52,13 @@ public class PokeMudry extends PortableApplication { enemies.add(new Enemy("Bianchi", 1, 3, "lumberjack_sheet32", "23N308", 0, "electricite", Direction.RIGHT)); enemies.add(new Enemy("Nicollier", 4, 2, "lumberjack_sheet32", "21N308", 0, "mathematique", Direction.LEFT)); enemies.add(new Enemy("Ellert", 1, 4, "lumberjack_sheet32", "23N215", 0, "physique", Direction.RIGHT)); - for (Enemy enemy : enemies) { entities.add(enemy); } - + //Init all entities for (Entity entity : entities) { entity.init(); } + + beginTime = System.currentTimeMillis(); + lastMesure = beginTime; } @Override @@ -63,6 +66,14 @@ public class PokeMudry extends PortableApplication { g.clear(); boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class); boolean onBattleScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenBattle.class); + + long timeNow = System.currentTimeMillis(); + if((timeNow-lastMesure) >= 1000){ + lastMesure = timeNow; + for (Enemy enemy : enemies) { enemy.recoveredTime++; } + } + if((timeNow-beginTime)/1000 >= 60 * Settings.TIME) System.out.println("Game finished"); + if(onMapScreen) sp.p.manageEntity(sp.sm, controller); @@ -71,14 +82,16 @@ public class PokeMudry extends PortableApplication { sp.e = sp.p.lastEnemy; int pv = sp.e.getPv(); + boolean recovered = sp.e.recoveredTime>=Settings.RECOVERED; - if (pv>0) { + if (pv>0 && recovered) { sp.sb = sp.screenManager.getScreenBattle(); sp.b = new Battle(sp.e); //set pv and xp to display sp.b.setXpPlayer(sp.p.getXp()); + g.zoom(1); g.resetCamera(); } else { sp.p.onEnemy = false; @@ -114,17 +127,6 @@ public class PokeMudry extends PortableApplication { public void onKeyDown(int keycode) { super.onKeyDown(keycode); front_montant = true; - switch (keycode) { - case Input.Keys.Z: - if (sp.sm.zoom == 1.0) { - sp.sm.zoom = 0.5f; - } else { - sp.sm.zoom = 1; - } - return; - default: - break; - } controller.keyStatus.put(keycode, true); sp.screenManager.getActiveScreen().onKeyUp(keycode); } diff --git a/src/Main/Settings.java b/src/Main/Settings.java index fe96e1e..c12d489 100644 --- a/src/Main/Settings.java +++ b/src/Main/Settings.java @@ -5,6 +5,8 @@ public class Settings { public static final boolean ANDROID = false; public static final int PLAYERS = 1; public static final int TIME = 10; // number of minutes for kill all enemy + public static final int RECOVERED = 30; // number of seconds an enemy need for recovered + public static final int SWITCHMAPTIME = 250; // Number of milliseconds the player wait for switch map public static final int SIDE = 800; diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index cdecbac..643164a 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -16,7 +16,6 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; -import Entity.Character.Direction; import Entity.Character; import Entity.Player; import ch.hevs.gdx2d.components.screen_management.RenderingScreen; @@ -30,7 +29,6 @@ public class ScreenMap extends RenderingScreen{ Map tMap = new TreeMap(); Map tMapRenderer = new TreeMap(); public String map; - public float zoom; private int width; public int tileWidth; private int height; @@ -46,7 +44,6 @@ public class ScreenMap extends RenderingScreen{ @Override public void onInit() { // Set initial zoom - zoom = 1; try { map = player.getMap(); } catch (Exception e) {} @@ -107,13 +104,11 @@ public class ScreenMap extends RenderingScreen{ // Render the tileMap - g.zoom(zoom); + g.zoom(0.5f); g.moveCamera((int)player.getPosition().x, (int)player.getPosition().y, width * tileWidth, height * tileHeight); tMapRenderer.get(map).setView(g.getCamera()); tMapRenderer.get(map).render(); - - g.drawFPS(); }