2022-06-08 23:30:15 +02:00
|
|
|
package Main;
|
|
|
|
|
2022-06-09 19:15:11 +02:00
|
|
|
|
|
|
|
import java.util.Vector;
|
|
|
|
import com.badlogic.gdx.Input;
|
2022-06-12 17:02:27 +02:00
|
|
|
|
2022-06-09 19:15:11 +02:00
|
|
|
import Control.Controller;
|
|
|
|
import Entity.Enemy;
|
|
|
|
import Entity.Entity;
|
2022-06-12 16:33:04 +02:00
|
|
|
import Game.Battle;
|
|
|
|
import Screen.ScreenBattle;
|
2022-06-10 18:49:02 +02:00
|
|
|
import Screen.ScreenMap;
|
2022-06-08 23:30:15 +02:00
|
|
|
import Screen.ScreenPlayer;
|
|
|
|
import ch.hevs.gdx2d.desktop.PortableApplication;
|
|
|
|
import ch.hevs.gdx2d.lib.GdxGraphics;
|
|
|
|
|
|
|
|
public class PokeMudry extends PortableApplication {
|
2022-06-09 19:15:11 +02:00
|
|
|
|
|
|
|
private ScreenPlayer sp;
|
|
|
|
private Controller controller;
|
|
|
|
private static Vector<Enemy> enemies = new Vector<>();
|
|
|
|
private static Vector<Entity> entities = new Vector<>();
|
|
|
|
|
2022-06-11 21:45:45 +02:00
|
|
|
public static boolean front_montant = false;
|
|
|
|
|
2022-06-08 23:30:15 +02:00
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
new PokeMudry();
|
|
|
|
}
|
|
|
|
|
|
|
|
PokeMudry(){
|
|
|
|
super(Settings.SIDE, Settings.SIDE);
|
2022-06-09 19:15:11 +02:00
|
|
|
controller = new Controller();
|
|
|
|
sp = new ScreenPlayer();
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
2022-06-09 19:15:11 +02:00
|
|
|
|
|
|
|
public static Vector<Enemy> getEnemies() {
|
|
|
|
return enemies;
|
|
|
|
}
|
2022-06-08 23:30:15 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInit() {
|
2022-06-09 19:15:11 +02:00
|
|
|
sp.init();
|
|
|
|
controller.init();
|
2022-06-12 12:35:08 +02:00
|
|
|
|
|
|
|
// add player, create and add all enemies in entities
|
2022-06-09 19:15:11 +02:00
|
|
|
entities.add((Entity) sp.p);
|
|
|
|
enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert"));
|
2022-06-09 21:07:13 +02:00
|
|
|
enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test"));
|
2022-06-10 18:49:02 +02:00
|
|
|
for (Enemy enemy : enemies) { entities.add(enemy); }
|
2022-06-09 19:15:11 +02:00
|
|
|
|
2022-06-12 12:35:08 +02:00
|
|
|
//Init all entities
|
|
|
|
for (Entity entity : entities) { entity.init(); }
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onGraphicRender(GdxGraphics g) {
|
2022-06-09 19:15:11 +02:00
|
|
|
g.clear();
|
2022-06-12 12:35:08 +02:00
|
|
|
boolean onMapScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class);
|
2022-06-12 16:33:04 +02:00
|
|
|
boolean onBattleScreen = sp.screenManager.getActiveScreen().getClass().equals(ScreenBattle.class);
|
2022-06-12 12:35:08 +02:00
|
|
|
|
|
|
|
if(onMapScreen) sp.p.manageEntity(sp.sm, controller);
|
2022-06-10 18:49:02 +02:00
|
|
|
|
2022-06-12 12:35:08 +02:00
|
|
|
// Switch screen
|
2022-06-13 21:08:11 +02:00
|
|
|
if (sp.p.onEnemy && onMapScreen){
|
2022-06-10 18:49:02 +02:00
|
|
|
sp.e = sp.p.lastEnemy;
|
2022-06-12 16:33:04 +02:00
|
|
|
sp.sb = sp.screenManager.getScreenBattle();
|
|
|
|
sp.b = new Battle(sp.e);
|
2022-06-10 18:59:59 +02:00
|
|
|
g.resetCamera();
|
2022-06-10 18:49:02 +02:00
|
|
|
}
|
2022-06-12 16:33:04 +02:00
|
|
|
|
|
|
|
if(onBattleScreen) sp.sb.manage(controller, sp.b);
|
|
|
|
|
2022-06-13 21:38:00 +02:00
|
|
|
|
|
|
|
if(!sp.sb.getScreenBattleOn() && onBattleScreen){
|
|
|
|
sp.p.onEnemy = false;
|
|
|
|
sp.sm = sp.screenManager.getScreenMap();
|
|
|
|
}
|
|
|
|
|
2022-06-12 16:33:04 +02:00
|
|
|
// Graphics render
|
|
|
|
sp.render(g);
|
|
|
|
for (Entity entity : entities) {
|
|
|
|
// Render only entities on the good map
|
|
|
|
if (entity.getMap().equals(sp.sm.map) && onMapScreen)
|
|
|
|
entity.graphicRender(g);
|
|
|
|
}
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//key gestion
|
|
|
|
@Override
|
|
|
|
public void onKeyDown(int keycode) {
|
|
|
|
super.onKeyDown(keycode);
|
2022-06-11 21:45:45 +02:00
|
|
|
front_montant = true;
|
2022-06-09 19:15:11 +02:00
|
|
|
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);
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void onKeyUp(int keycode) {
|
|
|
|
super.onKeyUp(keycode);
|
2022-06-11 21:45:45 +02:00
|
|
|
front_montant = false;
|
2022-06-09 19:15:11 +02:00
|
|
|
controller.keyStatus.put(keycode, false);
|
|
|
|
sp.screenManager.getActiveScreen().onKeyDown(keycode);
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
}
|