mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-10-30 11:19:17 +00:00 
			
		
		
		
	avancée sur la base de donnée des attaques et discours
This commit is contained in:
		
							
								
								
									
										7
									
								
								resources/Battle/Speech/enemi.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								resources/Battle/Speech/enemi.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | introduction text | ||||||
|  | attack 1 | ||||||
|  | attack 2 | ||||||
|  | attack 3 | ||||||
|  | attack 4 | ||||||
|  | death | ||||||
|  | win | ||||||
| @@ -14,6 +14,11 @@ public class Controller { | |||||||
| 		keyStatus.put(Input.Keys.DOWN, false); | 		keyStatus.put(Input.Keys.DOWN, false); | ||||||
| 		keyStatus.put(Input.Keys.LEFT, false); | 		keyStatus.put(Input.Keys.LEFT, false); | ||||||
| 		keyStatus.put(Input.Keys.RIGHT, false); | 		keyStatus.put(Input.Keys.RIGHT, false); | ||||||
|  |         keyStatus.put(Input.Keys.NUM_1, false); | ||||||
|  |         keyStatus.put(Input.Keys.NUM_2, false); | ||||||
|  |         keyStatus.put(Input.Keys.NUM_3, false); | ||||||
|  |         keyStatus.put(Input.Keys.NUM_4, false); | ||||||
|  |         keyStatus.put(Input.Keys.SPACE, false); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| package Entity; | package Entity; | ||||||
|  |  | ||||||
| import Text.FightData; | import Text.TextEnemy; | ||||||
|  |  | ||||||
| import com.badlogic.gdx.math.Vector2; | import com.badlogic.gdx.math.Vector2; | ||||||
|  |  | ||||||
| @@ -8,12 +8,13 @@ import ch.hevs.gdx2d.lib.GdxGraphics; | |||||||
|  |  | ||||||
| public class Enemy extends Character{ | public class Enemy extends Character{ | ||||||
|  |  | ||||||
|     public FightData fightData; |     public TextEnemy textEnemy; | ||||||
|  |  | ||||||
|     public Enemy(String name, int x, int y, String img) { |     public Enemy(String name, int x, int y, String img) { | ||||||
|         super(name, x, y, img); |         super(name, x, y, img); | ||||||
|         //generate the vector of fight |         //generate his text | ||||||
|         fightData = new FightData(name); |         this.textEnemy = new TextEnemy(name); | ||||||
|  |         textEnemy.generateText(); | ||||||
|         //TODO Auto-generated constructor stub |         //TODO Auto-generated constructor stub | ||||||
|  |  | ||||||
|     } |     } | ||||||
|   | |||||||
							
								
								
									
										42
									
								
								src/Main/PokeMudry.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/Main/PokeMudry.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | package Main; | ||||||
|  |  | ||||||
|  | import Screen.ScreenPlayer; | ||||||
|  | import ch.hevs.gdx2d.desktop.PortableApplication; | ||||||
|  | import ch.hevs.gdx2d.lib.GdxGraphics; | ||||||
|  |  | ||||||
|  | public class PokeMudry extends PortableApplication { | ||||||
|  |      | ||||||
|  |     private ScreenPlayer screenPlayer = new ScreenPlayer(); | ||||||
|  |  | ||||||
|  |     public static void main(String[] args) { | ||||||
|  |         new PokeMudry(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     PokeMudry(){ | ||||||
|  |         super(Settings.SIDE, Settings.SIDE); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void onInit() { | ||||||
|  |         screenPlayer.init(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     public void onGraphicRender(GdxGraphics g) { | ||||||
|  |         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); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										11
									
								
								src/Main/Settings.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/Main/Settings.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | package Main; | ||||||
|  |  | ||||||
|  | public class Settings { | ||||||
|  |  | ||||||
|  |     public final boolean ANDROID = false; | ||||||
|  |     public final int PLAYERS = 1; | ||||||
|  |     public static final int TIME = 10; // number of minutes for kill all enemy | ||||||
|  |  | ||||||
|  |     public static final int SIDE = 800; | ||||||
|  |      | ||||||
|  | } | ||||||
| @@ -7,6 +7,10 @@ public class PokeMudry extends PortableApplication { | |||||||
|     public final int PLAYERS = 1; |     public final int PLAYERS = 1; | ||||||
|     public static final int TIME = 10; // number of minutes for kill all enemy |     public static final int TIME = 10; // number of minutes for kill all enemy | ||||||
|  |  | ||||||
|  |     public static final int HEIGHT = 800; | ||||||
|  |     public static final int width = 800; | ||||||
|  |  | ||||||
|  |  | ||||||
|     private ScreenPlayer screenPlayer = new ScreenPlayer(); |     private ScreenPlayer screenPlayer = new ScreenPlayer(); | ||||||
|  |  | ||||||
|      |      | ||||||
|   | |||||||
| @@ -1,30 +1,44 @@ | |||||||
| package Screen; | package Screen; | ||||||
|  |  | ||||||
|  | import Main.Settings; | ||||||
|  |  | ||||||
| import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | ||||||
| import ch.hevs.gdx2d.lib.GdxGraphics; | import ch.hevs.gdx2d.lib.GdxGraphics; | ||||||
| import com.badlogic.gdx.Gdx; | import com.badlogic.gdx.Gdx; | ||||||
|  | import com.badlogic.gdx.Input; | ||||||
| import com.badlogic.gdx.files.FileHandle; | import com.badlogic.gdx.files.FileHandle; | ||||||
| import com.badlogic.gdx.graphics.Color; | import com.badlogic.gdx.graphics.Color; | ||||||
| import com.badlogic.gdx.graphics.g2d.BitmapFont; | import com.badlogic.gdx.graphics.g2d.BitmapFont; | ||||||
| import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; | import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator; | ||||||
| import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; | import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; | ||||||
|  |  | ||||||
|  | import Control.Controller; | ||||||
|  | import Entity.Enemy; | ||||||
|  |  | ||||||
| public class ScreenBattle extends RenderingScreen{ | public class ScreenBattle extends RenderingScreen{ | ||||||
|  |  | ||||||
|  | 	private static int EDGE = 10; | ||||||
|  | 	private static int HEIGHT_DIALOG = Settings.SIDE / 3; | ||||||
|  | 	private static int WIDTH_DIALOG = Settings.SIDE - 2*EDGE; | ||||||
|  | 	 | ||||||
|  | 	private boolean attackOn; | ||||||
|  |  | ||||||
|  |  | ||||||
| 	private BitmapFont optimus40; | 	private BitmapFont optimus40; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| 	public void onInit() { | 	public void onInit() { | ||||||
|  |  | ||||||
|         //display the question |         //display the question | ||||||
| 		generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 100, Color.WHITE); | 		generateFont("resources//font//OptimusPrinceps.ttf", optimus40, 20, Color.BLACK); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	@Override | 	@Override | ||||||
| 	public void onGraphicRender(GdxGraphics g) { | 	public void onGraphicRender(GdxGraphics g) { | ||||||
| 		g.clear(Color.GREEN); | 		g.clear(Color.BLACK); | ||||||
| 		g.drawStringCentered(g.getScreenHeight()/2, "question", optimus40); | 		g.drawStringCentered(g.getScreenHeight()/2, "attack", optimus40); | ||||||
|  | 		g.drawFilledRectangle(Settings.SIDE/2, HEIGHT_DIALOG/2 + EDGE, WIDTH_DIALOG, HEIGHT_DIALOG, 0); | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -45,6 +59,24 @@ public class ScreenBattle extends RenderingScreen{ | |||||||
|  |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	public void displayEnemy(Enemy e){ | ||||||
|  | 		if(e.textEnemy.attackOn){ | ||||||
|  | 			attackOn = true; | ||||||
|  | 		} | ||||||
|  | 		else() | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void readNextLine(){ | ||||||
|  |  | ||||||
|  | 		 | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public void manage(Controller c){ | ||||||
|  | 		if (c.keyStatus.get(Input.Keys.SPACE)){ | ||||||
|  | 			readNextLine(); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |      | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,6 @@ import com.badlogic.gdx.maps.tiled.TmxMapLoader; | |||||||
| import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer; | ||||||
| import com.badlogic.gdx.math.Vector2; | import com.badlogic.gdx.math.Vector2; | ||||||
|  |  | ||||||
| import Entity.Player; |  | ||||||
| import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | import ch.hevs.gdx2d.components.screen_management.RenderingScreen; | ||||||
| import ch.hevs.gdx2d.lib.GdxGraphics; | import ch.hevs.gdx2d.lib.GdxGraphics; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,5 @@ public class ScreenPlayer { | |||||||
|  |  | ||||||
|     public void render(GdxGraphics g){ |     public void render(GdxGraphics g){ | ||||||
|         screenManager.render(g); |         screenManager.render(g); | ||||||
|          |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ public class FightData { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     //return the vector with one attak |     //return the vector with one attak | ||||||
|     public Attack getAttacks(int a){ |     public Attack getAttack(int a){ | ||||||
|         return attacks.get(a); |         return attacks.get(a); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										42
									
								
								src/Text/SpeechData.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/Text/SpeechData.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | package Text; | ||||||
|  |  | ||||||
|  | import java.util.Vector; | ||||||
|  | import java.io.BufferedReader; | ||||||
|  | import java.io.File; | ||||||
|  | import java.io.FileReader; | ||||||
|  |  | ||||||
|  | public class SpeechData { | ||||||
|  |  | ||||||
|  |     Vector<String> speechs = new Vector<String>(); | ||||||
|  |     File file; | ||||||
|  |      | ||||||
|  |  | ||||||
|  |     public SpeechData(String name){ | ||||||
|  |         file = new File("resources//fight//" + name + ".csv"); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     public void readFile() { | ||||||
|  |         String line = ""; | ||||||
|  |         try { | ||||||
|  |             FileReader f = new FileReader(file); | ||||||
|  |             BufferedReader bf = new BufferedReader(f);  | ||||||
|  |  | ||||||
|  |             line = bf.readLine();  | ||||||
|  |             while(line != null){ | ||||||
|  |                  | ||||||
|  |                 Speechs.add(line); | ||||||
|  |  | ||||||
|  |                 line = bf.readLine(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             bf.close(); | ||||||
|  |  | ||||||
|  |           } catch (Exception e) { | ||||||
|  |             e.printStackTrace(); | ||||||
|  |           } | ||||||
|  |          | ||||||
|  |     } | ||||||
|  |     public String getSpeechs(int i) { | ||||||
|  |         return speechs.elementAt(i); | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										42
									
								
								src/Text/TextEnemy.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								src/Text/TextEnemy.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,42 @@ | |||||||
|  | package Text; | ||||||
|  |  | ||||||
|  | import java.util.Vector; | ||||||
|  |  | ||||||
|  | public class TextEnemy { | ||||||
|  |     public FightData fightData; | ||||||
|  |     public SpeechData speechData; | ||||||
|  |     public boolean attackOn = false; | ||||||
|  |  | ||||||
|  |     Vector<String> line = new Vector<String>(); | ||||||
|  |      | ||||||
|  |     public TextEnemy(String name){ | ||||||
|  |         //generate the vector of fight | ||||||
|  |         fightData = new FightData(name); | ||||||
|  |         fightData.readFile(); | ||||||
|  |  | ||||||
|  |         //generate the vector of Speechs | ||||||
|  |         speechData = new SpeechData(name); | ||||||
|  |         speechData.readFile(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public void generateText(){ | ||||||
|  |         int i =0; | ||||||
|  |         //introduction line | ||||||
|  |         line.add(speechData.getSpeechs(i++)); | ||||||
|  |  | ||||||
|  |         for(int j=0; i<4;i++){ | ||||||
|  |         //attack and answer (number on vector : 1-4) | ||||||
|  |             line.add( | ||||||
|  |             speechData.getSpeechs(i++) + fightData.getAttack(j).attack + "?  ("+fightData.getAttack(j).xp+ ") " + "\n" + | ||||||
|  |             fightData.getAttack(j).answer1 + "\n" + | ||||||
|  |             fightData.getAttack(j).answer2 + "\n" +  | ||||||
|  |             fightData.getAttack(j).answer3 + "\n" +  | ||||||
|  |             fightData.getAttack(j).answer4); | ||||||
|  |         } | ||||||
|  |         //finish (win and death) | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |      | ||||||
|  | } | ||||||
| @@ -1,5 +1,13 @@ | |||||||
|  |  | ||||||
|  | import java.util.TreeMap; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
|  | import com.badlogic.gdx.Input; | ||||||
|  |  | ||||||
|  | import Control.Controller; | ||||||
|  | import Entity.Enemy; | ||||||
| import Screen.ScreenBattle; | import Screen.ScreenBattle; | ||||||
|  |  | ||||||
| import ch.hevs.gdx2d.desktop.PortableApplication; | import ch.hevs.gdx2d.desktop.PortableApplication; | ||||||
| import ch.hevs.gdx2d.lib.GdxGraphics; | import ch.hevs.gdx2d.lib.GdxGraphics; | ||||||
| import ch.hevs.gdx2d.lib.ScreenManager; | import ch.hevs.gdx2d.lib.ScreenManager; | ||||||
| @@ -7,8 +15,9 @@ import ch.hevs.gdx2d.lib.ScreenManager; | |||||||
| public class testYann extends PortableApplication{ | public class testYann extends PortableApplication{ | ||||||
|  |  | ||||||
|     private ScreenManager s = new ScreenManager(); |     private ScreenManager s = new ScreenManager(); | ||||||
|  |     public Map<Integer, Boolean> keyStatus = new TreeMap<Integer, Boolean>(); | ||||||
|     ScreenBattle b; |     double zoom; | ||||||
|  |     Controller controller = new Controller(); | ||||||
|      |      | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|         new testYann(); |         new testYann(); | ||||||
| @@ -16,32 +25,37 @@ public class testYann extends PortableApplication{ | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     testYann(){ |     testYann(){ | ||||||
| 		super(1000, 800); | 		super(800, 800); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onInit() { |     public void onInit() { | ||||||
|         b = new ScreenBattle(); |          | ||||||
|         s.registerScreen(b.getClass()); |         s.registerScreen(ScreenBattle.class); | ||||||
|  |         Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png"); | ||||||
|  |          | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onGraphicRender(GdxGraphics g) { |     public void onGraphicRender(GdxGraphics g) { | ||||||
|         s.render(g); |         s.render(g); | ||||||
|          |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|      |  | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public void onKeyDown(int keycode) { | 	public void onKeyUp(int keycode) { | ||||||
|         // TODO Auto-generated method stub | 		super.onKeyUp(keycode); | ||||||
|         super.onKeyDown(keycode); |  | ||||||
|     } |  | ||||||
|     @Override |  | ||||||
|     public void onKeyUp(int keycode) { |  | ||||||
|         // TODO Auto-generated method stub |  | ||||||
|         super.onKeyUp(keycode); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  | 		controller.keyStatus.put(keycode, false); | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  | 	public void onKeyDown(int keycode) { | ||||||
|  | 		super.onKeyDown(keycode); | ||||||
|  |  | ||||||
|  | 		switch (keycode) { | ||||||
|  | 		default: | ||||||
|  | 			break; | ||||||
|  | 		} | ||||||
|  | 		controller.keyStatus.put(keycode, true); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user