diff --git a/.vscode/settings.json b/.vscode/settings.json index e112a70..58c0223 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "java.project.outputPath": "bin", "java.project.referencedLibraries": [ "lib/**/*.jar" - ] + ], + "java.configuration.updateBuildConfiguration": "interactive" } diff --git a/bin/Entity/Character.class b/bin/Entity/Character.class deleted file mode 100644 index 02b1e72..0000000 Binary files a/bin/Entity/Character.class and /dev/null differ diff --git a/bin/Entity/Enemy.class b/bin/Entity/Enemy.class deleted file mode 100644 index 68f86ae..0000000 Binary files a/bin/Entity/Enemy.class and /dev/null differ diff --git a/bin/Entity/Entity.class b/bin/Entity/Entity.class deleted file mode 100644 index b7a8f9e..0000000 Binary files a/bin/Entity/Entity.class and /dev/null differ diff --git a/bin/Entity/Player.class b/bin/Entity/Player.class deleted file mode 100644 index 0408b7a..0000000 Binary files a/bin/Entity/Player.class and /dev/null differ diff --git a/bin/Entity/Stuff.class b/bin/Entity/Stuff.class deleted file mode 100644 index 5b389fe..0000000 Binary files a/bin/Entity/Stuff.class and /dev/null differ diff --git a/bin/PokeMudry.class b/bin/PokeMudry.class deleted file mode 100644 index 4e0a6c6..0000000 Binary files a/bin/PokeMudry.class and /dev/null differ diff --git a/bin/Screen/Hero$Direction.class b/bin/Screen/Hero$Direction.class deleted file mode 100644 index 4bbc909..0000000 Binary files a/bin/Screen/Hero$Direction.class and /dev/null differ diff --git a/bin/Screen/Hero.class b/bin/Screen/Hero.class deleted file mode 100644 index d40d1c9..0000000 Binary files a/bin/Screen/Hero.class and /dev/null differ diff --git a/bin/Screen/ScreenBattle.class b/bin/Screen/ScreenBattle.class deleted file mode 100644 index 04a2c2c..0000000 Binary files a/bin/Screen/ScreenBattle.class and /dev/null differ diff --git a/bin/Screen/ScreenMap$Door.class b/bin/Screen/ScreenMap$Door.class deleted file mode 100644 index 86696ed..0000000 Binary files a/bin/Screen/ScreenMap$Door.class and /dev/null differ diff --git a/bin/Screen/ScreenMap.class b/bin/Screen/ScreenMap.class deleted file mode 100644 index 61fb66b..0000000 Binary files a/bin/Screen/ScreenMap.class and /dev/null differ diff --git a/bin/Screen/ScreenPlayer.class b/bin/Screen/ScreenPlayer.class deleted file mode 100644 index 6b981b7..0000000 Binary files a/bin/Screen/ScreenPlayer.class and /dev/null differ diff --git a/bin/testHER.class b/bin/testHER.class deleted file mode 100644 index e6c891d..0000000 Binary files a/bin/testHER.class and /dev/null differ diff --git a/resources/fight/enemi.csv b/resources/fight/enemi.csv new file mode 100644 index 0000000..253ef70 --- /dev/null +++ b/resources/fight/enemi.csv @@ -0,0 +1,7 @@ +attaque,contre-attaque 1,contre-attaque 2,contre-attaque 3,contre-attaque 4,1 +df,sdfs,dfs,df,sdf,10 +sdf,sdf,sd,sdf,sdfs,3 +sdf,sdf,fsd,sdf,dfs,45 +sd,fsdf,fsd,f,dfsd,4 +sdfsf,df,sdf,sdf,fsdf,6 +sdf,sdf,sdf,sdfs,df,3 diff --git a/resources/font/OptimusPrinceps.ttf b/resources/font/OptimusPrinceps.ttf new file mode 100644 index 0000000..e11017f Binary files /dev/null and b/resources/font/OptimusPrinceps.ttf differ diff --git a/resources/font/RobotoSlab-Regular.ttf b/resources/font/RobotoSlab-Regular.ttf new file mode 100644 index 0000000..eb52a79 Binary files /dev/null and b/resources/font/RobotoSlab-Regular.ttf differ diff --git a/resources/font/Starjedi.ttf b/resources/font/Starjedi.ttf new file mode 100644 index 0000000..2ac5bb1 Binary files /dev/null and b/resources/font/Starjedi.ttf differ diff --git a/resources/font/Timeless.ttf b/resources/font/Timeless.ttf new file mode 100644 index 0000000..0876626 Binary files /dev/null and b/resources/font/Timeless.ttf differ diff --git a/resources/font/ice_pixel-7.ttf b/resources/font/ice_pixel-7.ttf new file mode 100644 index 0000000..b447fca Binary files /dev/null and b/resources/font/ice_pixel-7.ttf differ diff --git a/src/Entity/Enemy.java b/src/Entity/Enemy.java index 99b443c..5fb1d14 100644 --- a/src/Entity/Enemy.java +++ b/src/Entity/Enemy.java @@ -1,14 +1,23 @@ package Entity; +import Text.FightData; + import com.badlogic.gdx.math.Vector2; import ch.hevs.gdx2d.lib.GdxGraphics; public class Enemy extends Character{ + public FightData fightData; + public Enemy(String name, int x, int y, String img) { super(name, x, y, img); + turn(Character.Direction.DOWN); + //generate the vector of fight + fightData = new FightData(name); + //TODO Auto-generated constructor stub + } public void setPosition(int x, int y){ diff --git a/src/PokeMudry.java b/src/PokeMudry.java index 0b46f85..a777dca 100644 --- a/src/PokeMudry.java +++ b/src/PokeMudry.java @@ -1,26 +1,44 @@ +import Screen.ScreenPlayer; import ch.hevs.gdx2d.desktop.PortableApplication; import ch.hevs.gdx2d.lib.GdxGraphics; -public class PokeMudry extends PortableApplication{ +public class PokeMudry extends PortableApplication { public final boolean ANDROID = false; public final int PLAYERS = 1; public static final int TIME = 10; // number of minutes for kill all enemy - /* + private ScreenPlayer screenPlayer = new ScreenPlayer(); + + public static void main(String[] args) { - + new PokeMudry(); } - */ + + PokeMudry(){ + super(1000, 800); + } + @Override public void onInit() { - // TODO Auto-generated method stub - + screenPlayer.init(); } @Override public void onGraphicRender(GdxGraphics g) { - // TODO Auto-generated method stub - + screenPlayer.render(g); + } + + + //key gestion + @Override + public void onKeyDown(int keycode) { + screenPlayer.screenManager.getActiveScreen().onKeyDown(keycode); + super.onKeyDown(keycode); + } + @Override + public void onKeyUp(int keycode) { + screenPlayer.screenManager.getActiveScreen().onKeyUp(keycode); + super.onKeyUp(keycode); } } diff --git a/src/Screen/ScreenBattle.java b/src/Screen/ScreenBattle.java index a4ac024..647cd2e 100644 --- a/src/Screen/ScreenBattle.java +++ b/src/Screen/ScreenBattle.java @@ -1,5 +1,51 @@ package Screen; -public class ScreenBattle { +import ch.hevs.gdx2d.components.screen_management.RenderingScreen; +import ch.hevs.gdx2d.lib.GdxGraphics; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; +import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.BitmapFont; +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; +import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; + +public class ScreenBattle extends RenderingScreen{ + + private BitmapFont optimus40; + + @Override + public void onInit() { + + //display the question + generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 100, Color.WHITE); + + } + + @Override + public void onGraphicRender(GdxGraphics g) { + g.clear(Color.GREEN); + g.drawStringCentered(g.getScreenHeight()/2, "question", optimus40); + + } + + @Override + public void dispose() { + optimus40.dispose(); + + } + + public void generateFont(String file, BitmapFont bitmapFont, int height, Color c ){ + FileHandle fileHandle = Gdx.files.internal(file); + FreeTypeFontParameter parameter = new FreeTypeFontParameter(); + FreeTypeFontGenerator generator = new FreeTypeFontGenerator(fileHandle); + parameter.size = generator.scaleForPixelHeight(height); + parameter.color = c; + optimus40 = generator.generateFont(parameter); + generator.dispose(); + + } + + + } diff --git a/src/Screen/ScreenMap.java b/src/Screen/ScreenMap.java index 0dba65e..4e9f955 100644 --- a/src/Screen/ScreenMap.java +++ b/src/Screen/ScreenMap.java @@ -17,9 +17,10 @@ import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; import com.badlogic.gdx.math.Vector2; import Entity.Player; +import ch.hevs.gdx2d.components.screen_management.RenderingScreen; import ch.hevs.gdx2d.lib.GdxGraphics; -public class ScreenMap { +public class ScreenMap extends RenderingScreen{ // tiles management private Vector tiledLayer = new Vector<>(); @@ -41,7 +42,8 @@ public class ScreenMap { tMapRenderer.put(name,new OrthogonalTiledMapRenderer(tm)); } - public void init() { + @Override + public void onInit() { // Set initial zoom zoom = 1; @@ -51,7 +53,8 @@ public class ScreenMap { createMap("desert"); } - public void graphicRender(GdxGraphics g, Player p) { + @Override + public void onGraphicRender(GdxGraphics g) { tiledLayer.clear(); for (int i = 0; i < 50; i++) { @@ -69,7 +72,7 @@ public class ScreenMap { // Camera follows the hero g.zoom(zoom); - g.moveCamera(p.getPosition().x, p.getPosition().y, width * tileWidth, height * tileHeight); + //g.moveCamera(player.getPosition().x, player.getPosition().y, width * tileWidth, height * tileHeight); // Render the tileMap tMapRenderer.get(map).setView(g.getCamera()); @@ -78,6 +81,7 @@ public class ScreenMap { g.drawFPS(); } + public Vector getTile(Vector2 position, int offsetX, int offsetY) { Vector tiles = new Vector<>(); for (TiledMapTileLayer tl : tiledLayer) { diff --git a/src/Screen/ScreenPlayer.java b/src/Screen/ScreenPlayer.java index 16d0af0..ce5fde5 100644 --- a/src/Screen/ScreenPlayer.java +++ b/src/Screen/ScreenPlayer.java @@ -1,17 +1,26 @@ package Screen; +import Entity.Player; +import ch.hevs.gdx2d.lib.GdxGraphics; import ch.hevs.gdx2d.lib.ScreenManager; public class ScreenPlayer { - private ScreenManager screenManager; - private ScreenMap screenMap; - private ScreenBattle screenBattle; + public ScreenManager screenManager = new ScreenManager(); + + private Player player; public void init(){ + + player = new Player(8, 15); + + + screenManager.registerScreen(ScreenMap.class); + screenManager.registerScreen(ScreenBattle.class); } - public void render(){ + public void render(GdxGraphics g){ + screenManager.render(g); } } diff --git a/src/Text/Attack.java b/src/Text/Attack.java new file mode 100644 index 0000000..e63e063 --- /dev/null +++ b/src/Text/Attack.java @@ -0,0 +1,23 @@ +package Text; + +public class Attack { + String attack; + String answer1; + String answer2; + String answer3; + String answer4; + float xp; + + Attack(String attack, String answer1,String answer2,String answer3, String answer4, float xp){ + this.attack = attack; + this.answer1 = answer1; + this.answer2 = answer2; + this.answer3 = answer3; + this.answer4 = answer4; + this.xp = xp; + } + + public String toString(){ + return attack+ " " + answer1+ " " + answer2+ " " + answer3+ " " + answer4+ " " + xp; + } +} diff --git a/src/Text/FightData.java b/src/Text/FightData.java new file mode 100644 index 0000000..7e87ca2 --- /dev/null +++ b/src/Text/FightData.java @@ -0,0 +1,64 @@ +package Text; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.Vector; + +public class FightData { + + private Vector attacks = new Vector(); + private File file; + private static final String REGEX = ","; + + /* + public static void main(String[] args) { + FightData d = new FightData("enemi"); + d.readFile(); + for(Attack a : d.attacks){ + System.out.println(a); + } + } + */ + + public FightData(String name) { + file = new File("resources//fight//" + name + ".csv"); + } + + public void readFile() { + Attack attack; + String line = ""; + try { + FileReader f = new FileReader(file); + BufferedReader bf = new BufferedReader(f); + + line = bf.readLine(); + while(line != null){ + String[] a = line.split(REGEX);//change the regex if it is another + attack = new Attack(a[0], a[1], a[2], a[3], a[4], Float.valueOf(a[5])); + attacks.add(attack); + line = bf.readLine(); + } + + bf.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + //return the vector with all attaks of one enemi + public Vector getAllAttacks(){ + return attacks; + } + + //return the vector with one attak + public Attack getAttacks(int a){ + return attacks.get(a); + } + +} + + + diff --git a/src/testYann.java b/src/testYann.java new file mode 100644 index 0000000..a99d05a --- /dev/null +++ b/src/testYann.java @@ -0,0 +1,47 @@ + +import Screen.ScreenBattle; +import ch.hevs.gdx2d.desktop.PortableApplication; +import ch.hevs.gdx2d.lib.GdxGraphics; +import ch.hevs.gdx2d.lib.ScreenManager; + +public class testYann extends PortableApplication{ + + private ScreenManager s = new ScreenManager(); + + ScreenBattle b; + + public static void main(String[] args) { + new testYann(); + + } + + testYann(){ + super(1000, 800); + } + + @Override + public void onInit() { + b = new ScreenBattle(); + s.registerScreen(b.getClass()); + } + + @Override + public void onGraphicRender(GdxGraphics g) { + s.render(g); + + } + + + + @Override + public void onKeyDown(int keycode) { + // TODO Auto-generated method stub + super.onKeyDown(keycode); + } + @Override + public void onKeyUp(int keycode) { + // TODO Auto-generated method stub + super.onKeyUp(keycode); + } + +}