1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-30 04:33:27 +00:00

finish to add time

This commit is contained in:
Rémi Heredero 2022-06-16 14:24:20 +02:00
parent e748f763a8
commit 20a4356f69
9 changed files with 30 additions and 38 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

View File

@ -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) {

View File

@ -2,9 +2,12 @@ package Entity;
import com.badlogic.gdx.math.Vector2;
import Main.Settings;
public class Enemy extends Character{
private String branch;
public int recoveredTime = Settings.RECOVERED;

View File

@ -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;

View File

@ -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);

View File

@ -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<Enemy> enemies = new Vector<>();
private static Vector<Entity> entities = new Vector<>();
private long beginTime;
private long lastMesure;
public static boolean front_montant = false;
@ -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
@ -64,6 +67,14 @@ public class PokeMudry extends PortableApplication {
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);
// Switch screen
@ -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);
}

View File

@ -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;

View File

@ -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<String,TiledMap> tMap = new TreeMap<String,TiledMap>();
Map<String,TiledMapRenderer> tMapRenderer = new TreeMap<String,TiledMapRenderer>();
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();
}