mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-07-07 00:41:10 +00:00
Merge branch 'master' into xp-modifiaction
This commit is contained in:
@ -137,10 +137,10 @@ public abstract class Character extends Entity{
|
||||
textureY = 2;
|
||||
break;
|
||||
case LEFT:
|
||||
textureY = 1;
|
||||
textureY = 3;
|
||||
break;
|
||||
case UP:
|
||||
textureY = 3;
|
||||
textureY = 1;
|
||||
break;
|
||||
case DOWN:
|
||||
textureY = 0;
|
||||
|
@ -6,13 +6,17 @@ public class Enemy extends Character{
|
||||
|
||||
private String branch;
|
||||
|
||||
public Enemy(String name, int x, int y, String img, String map, int pv, String branch) {
|
||||
|
||||
|
||||
|
||||
public Enemy(String name, int x, int y, String img, String map, int pv, String branch, Character.Direction dir) {
|
||||
|
||||
super(name, x, y, img, map);
|
||||
//generate his text
|
||||
|
||||
this.map = map;
|
||||
|
||||
turn(Character.Direction.DOWN);
|
||||
turn(dir);
|
||||
|
||||
this.branch = branch;
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class Player extends Character{
|
||||
public boolean onEnemy = false;
|
||||
|
||||
public Player(int x, int y, String map) {
|
||||
super("Player", x, y, "Character", map);
|
||||
super("Player", x, y, "Character_flipped", map);
|
||||
}
|
||||
|
||||
public void addXp(int xp){
|
||||
@ -30,6 +30,8 @@ public class Player extends Character{
|
||||
|
||||
public void manageEntity(ScreenMap sm, Controller c) {
|
||||
|
||||
boolean onDoor = sm.isDoor(getPosition());
|
||||
|
||||
// Do nothing if hero is already moving
|
||||
if (!isMoving()) {
|
||||
|
||||
@ -38,19 +40,21 @@ public class Player extends Character{
|
||||
Player.Direction goalDirection = Player.Direction.NULL;
|
||||
Vector2 nextPos = new Vector2(position);
|
||||
|
||||
if (c.keyStatus.get(Input.Keys.RIGHT)) {
|
||||
|
||||
|
||||
if (c.keyStatus.get(Input.Keys.RIGHT) && !onDoor) {
|
||||
goalDirection = Player.Direction.RIGHT;
|
||||
nextCell = sm.getTile(getPosition(), 1, 0);
|
||||
nextPos.x+=sm.tileWidth;
|
||||
} else if (c.keyStatus.get(Input.Keys.LEFT)) {
|
||||
} else if (c.keyStatus.get(Input.Keys.LEFT) && !onDoor) {
|
||||
goalDirection = Player.Direction.LEFT;
|
||||
nextCell = sm.getTile(getPosition(), -1, 0);
|
||||
nextPos.x-=sm.tileWidth;
|
||||
} else if (c.keyStatus.get(Input.Keys.UP)) {
|
||||
} else if (c.keyStatus.get(Input.Keys.UP) && !onDoor) {
|
||||
goalDirection = Player.Direction.UP;
|
||||
nextCell = sm.getTile(getPosition(), 0, 1);
|
||||
nextPos.y+=sm.tileHeight;
|
||||
} else if (c.keyStatus.get(Input.Keys.DOWN)) {
|
||||
} else if (c.keyStatus.get(Input.Keys.DOWN) && !onDoor) {
|
||||
goalDirection = Player.Direction.DOWN;
|
||||
nextCell = sm.getTile(getPosition(), 0, -1);
|
||||
nextPos.y-=sm.tileHeight;
|
||||
@ -63,7 +67,7 @@ public class Player extends Character{
|
||||
turn(goalDirection);
|
||||
System.out.println("It's a enemy !!");
|
||||
} else {
|
||||
setSpeed(sm.getSpeed(nextCell));
|
||||
setSpeed(sm.getSpeed(nextCell)*3); //TODO remove x3
|
||||
go(goalDirection);
|
||||
}
|
||||
} else {
|
||||
@ -72,7 +76,7 @@ public class Player extends Character{
|
||||
}
|
||||
|
||||
|
||||
if(sm.isDoor(getPosition())){
|
||||
if(onDoor){
|
||||
String nMap = null;
|
||||
Integer x = null;
|
||||
Integer y = null;
|
||||
@ -86,7 +90,8 @@ public class Player extends Character{
|
||||
if (nMap == null || x == null || y == null) return;
|
||||
map = nMap;
|
||||
setPosition(x*sm.tileWidth, y*sm.tileHeight);
|
||||
System.out.println("Go to: " + sm.map + " in " + x + " x " + y);
|
||||
turn(goalDirection);
|
||||
System.out.println("Go to: " + map + " in " + x + " x " + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.badlogic.gdx.Input;
|
||||
import Control.Controller;
|
||||
import Entity.Enemy;
|
||||
import Entity.Entity;
|
||||
import Entity.Character.Direction;
|
||||
import Game.Battle;
|
||||
import Screen.ScreenBattle;
|
||||
import Screen.ScreenMap;
|
||||
@ -44,8 +45,13 @@ public class PokeMudry extends PortableApplication {
|
||||
|
||||
// add player, create and add all enemies in entities
|
||||
entities.add((Entity) sp.p);
|
||||
enemies.add(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique"));
|
||||
//enemies.add(new Enemy("Pignat", 5, 1, "lumberjack_sheet32", "test", 150));
|
||||
enemies.add(new Enemy("Mudry", 5, 11, "lumberjack_sheet32", "21N304", 25, "informatique", Direction.DOWN));
|
||||
enemies.add(new Enemy("Paciotti", 5, 11, "lumberjack_sheet32", "21N205", 0, "mecanique", Direction.DOWN));
|
||||
enemies.add(new Enemy("Gloeckner", 1, 7, "lumberjack_sheet32", "21N307", 0, "allemand", Direction.RIGHT));
|
||||
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
|
||||
@ -63,6 +69,7 @@ public class PokeMudry extends PortableApplication {
|
||||
// Switch screen
|
||||
if (sp.p.onEnemy && onMapScreen){
|
||||
sp.e = sp.p.lastEnemy;
|
||||
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
if(sp.e == null) System.out.println("sdfsdfsdfsdf");
|
||||
|
||||
@ -72,6 +79,17 @@ public class PokeMudry extends PortableApplication {
|
||||
sp.b.setXpPlayer(sp.p.getXp());
|
||||
|
||||
g.resetCamera();
|
||||
|
||||
int pv = sp.e.getPv();
|
||||
|
||||
if (pv>0) {
|
||||
sp.sb = sp.screenManager.getScreenBattle();
|
||||
sp.b = new Battle(sp.e);
|
||||
g.resetCamera();
|
||||
} else {
|
||||
sp.p.onEnemy = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(onBattleScreen) sp.sb.manage(controller, sp.b);
|
||||
|
@ -17,6 +17,7 @@ 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;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
@ -53,16 +54,28 @@ public class ScreenMap extends RenderingScreen{
|
||||
createMap("test");
|
||||
createMap("test_couloir");
|
||||
createMap("desert");
|
||||
|
||||
createMap("SS");
|
||||
//createMap("RI");
|
||||
//createMap("RS");
|
||||
|
||||
createMap("21RI");
|
||||
createMap("21RS");
|
||||
createMap("21N1");
|
||||
createMap("21N2");
|
||||
createMap("21N3");
|
||||
createMap("21N205");
|
||||
createMap("21N3");
|
||||
createMap("21N304");
|
||||
createMap("21N307");
|
||||
createMap("21N308");
|
||||
|
||||
createMap("23RI");
|
||||
createMap("23RS");
|
||||
createMap("23N1");
|
||||
createMap("23N2");
|
||||
createMap("23N215");
|
||||
createMap("23N3");
|
||||
createMap("23N308");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,11 +83,15 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
tiledLayer.clear();
|
||||
|
||||
// Get actual map of the player
|
||||
try { map = player.getMap(); } catch (Exception e) {}
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
// Get all layers on the current map
|
||||
for (int i = 0; i < 50; i++) {
|
||||
try { tiledLayer.add((TiledMapTileLayer) tMap.get(map).getLayers().get(i)); } catch (Exception e) { }
|
||||
}
|
||||
|
||||
// Get heigh and width of tiles and the size of the tiles
|
||||
TiledMapTileLayer tl = tiledLayer.get(0);
|
||||
width = tl.getWidth();
|
||||
tileWidth = (int) tl.getTileWidth();
|
||||
@ -83,14 +100,15 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
//System.out.println(width + " x " + height + " - " + tileWidth + " x " + tileHeight);
|
||||
|
||||
try {
|
||||
// Get all doors on the current map
|
||||
try {
|
||||
doors = tMap.get(map).getLayers().get("door").getObjects();
|
||||
} catch (Exception e) { doors = null; }
|
||||
|
||||
|
||||
// Render the tileMap
|
||||
//g.zoom(zoom);
|
||||
g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
g.zoom(zoom);
|
||||
g.moveCamera((int)player.getPosition().x, (int)player.getPosition().y, width * tileWidth, height * tileHeight);
|
||||
|
||||
tMapRenderer.get(map).setView(g.getCamera());
|
||||
tMapRenderer.get(map).render();
|
||||
@ -117,10 +135,11 @@ public class ScreenMap extends RenderingScreen{
|
||||
|
||||
public boolean isWalkable(Vector<TiledMapTile> tile) {
|
||||
if (tile == null) return false;
|
||||
boolean walkable = false;
|
||||
if (tile.size() == 0) return false;
|
||||
boolean walkable = true;
|
||||
for (TiledMapTile tiledMapTile : tile) {
|
||||
Object test = tiledMapTile.getProperties().get("walkable");
|
||||
walkable = Boolean.parseBoolean(test.toString()) ? true:walkable;
|
||||
walkable = Boolean.parseBoolean(test.toString()) ? walkable:false;
|
||||
}
|
||||
return walkable;
|
||||
}
|
||||
@ -161,7 +180,9 @@ public class ScreenMap extends RenderingScreen{
|
||||
try { Door.nextMap = mapProperties.get("nextMap").toString(); } catch (Exception e) { }
|
||||
try { Door.nextX = Integer.parseInt(mapProperties.get("nextX").toString()); } catch (Exception e) { }
|
||||
try { Door.nextY = Integer.parseInt(mapProperties.get("nextY").toString()); } catch (Exception e) { }
|
||||
try { Door.nextDirection = Direction.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { }
|
||||
|
||||
try { Door.nextDirection = Character.Direction.valueOf(mapProperties.get("nextDirection").toString()); } catch (Exception e) { }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +193,7 @@ public class ScreenMap extends RenderingScreen{
|
||||
public static String nextMap;
|
||||
public static Integer nextX;
|
||||
public static Integer nextY;
|
||||
public static Player.Direction nextDirection;
|
||||
public static Character.Direction nextDirection;
|
||||
|
||||
public static void reset(){
|
||||
nextMap = null;
|
||||
|
@ -2,6 +2,7 @@ package Screen;
|
||||
|
||||
import Entity.Enemy;
|
||||
import Entity.Player;
|
||||
import Entity.Character.Direction;
|
||||
import Game.Battle;
|
||||
import ch.hevs.gdx2d.lib.GdxGraphics;
|
||||
|
||||
@ -16,10 +17,10 @@ public class ScreenPlayer {
|
||||
public void init(){
|
||||
|
||||
// One player by ScreenPlayer
|
||||
p = new Player(8, 15, "desert");
|
||||
// = new Player(4, 2, "21RI");
|
||||
//p = new Player(8, 15, "desert");
|
||||
p = new Player(4, 2, "21RI");
|
||||
|
||||
b = new Battle(new Enemy("enemi", 0, 0, "charachter", "desert", 50, "enemi"));
|
||||
b = new Battle(new Enemy("enemy", 0, 0, "lumberjack_sheet32", "desert", 50, "enemy",Direction.NULL));
|
||||
|
||||
// Create both type of screen and record for reuse
|
||||
screenManager.registerScreen(ScreenMap.class);
|
||||
|
@ -3,6 +3,7 @@ package Text;
|
||||
import java.util.Vector;
|
||||
|
||||
import Entity.Enemy;
|
||||
import Entity.Character.Direction;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
@ -21,7 +22,7 @@ public class TextEnemy {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique"));
|
||||
TextEnemy t = new TextEnemy(new Enemy("Mudry", 10, 15, "lumberjack_sheet32", "desert", 25, "informatique",Direction.NULL));
|
||||
|
||||
t.generateText();
|
||||
|
||||
|
Reference in New Issue
Block a user