2022-06-08 23:30:15 +02:00
|
|
|
package Main;
|
|
|
|
|
2022-06-09 19:15:11 +02:00
|
|
|
|
|
|
|
import java.util.Vector;
|
2022-06-10 18:49:02 +02:00
|
|
|
import java.util.Map.Entry;
|
2022-06-09 19:20:43 +02:00
|
|
|
|
2022-06-09 19:15:11 +02:00
|
|
|
import com.badlogic.gdx.Input;
|
2022-06-09 19:20:43 +02:00
|
|
|
|
2022-06-09 19:15:11 +02:00
|
|
|
import Control.Controller;
|
|
|
|
import Entity.Enemy;
|
|
|
|
import Entity.Entity;
|
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-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();
|
|
|
|
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-09 19:15:11 +02:00
|
|
|
|
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-10 18:49:02 +02:00
|
|
|
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();
|
|
|
|
sp.p.manageEntity(sp.sm, controller);
|
|
|
|
sp.render(g);
|
2022-06-10 18:49:02 +02:00
|
|
|
System.out.println(sp.screenManager.getActiveScreen().getClass());
|
|
|
|
//System.out.println(ScreenMap.class);
|
2022-06-09 19:15:11 +02:00
|
|
|
for (Entity entity : entities) {
|
2022-06-10 18:49:02 +02:00
|
|
|
|
|
|
|
if (entity.getMap().equals(sp.sm.map) && sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class))
|
|
|
|
entity.graphicRender(g);
|
2022-06-09 19:15:11 +02:00
|
|
|
}
|
2022-06-10 18:49:02 +02:00
|
|
|
|
|
|
|
if (sp.p.frontOfEnemy && sp.screenManager.getActiveScreen().getClass().equals(ScreenMap.class)){
|
|
|
|
sp.e = sp.p.lastEnemy;
|
|
|
|
System.out.println("switch screen");
|
|
|
|
sp.screenManager.activateNextScreen();
|
2022-06-10 18:59:59 +02:00
|
|
|
g.resetCamera();
|
2022-06-10 18:49:02 +02:00
|
|
|
}
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//key gestion
|
|
|
|
@Override
|
|
|
|
public void onKeyDown(int keycode) {
|
|
|
|
super.onKeyDown(keycode);
|
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-09 19:15:11 +02:00
|
|
|
controller.keyStatus.put(keycode, false);
|
|
|
|
sp.screenManager.getActiveScreen().onKeyDown(keycode);
|
2022-06-08 23:30:15 +02:00
|
|
|
}
|
|
|
|
}
|