mirror of
				https://github.com/Klagarge/PokeHES.git
				synced 2025-10-31 03:39:16 +00:00 
			
		
		
		
	with row done
This commit is contained in:
		| @@ -1,5 +1,7 @@ | ||||
| package Control; | ||||
|  | ||||
| import com.badlogic.gdx.Input; | ||||
|  | ||||
| import Screen.ScreenPlayer; | ||||
|  | ||||
| /** | ||||
| @@ -10,9 +12,11 @@ import Screen.ScreenPlayer; | ||||
|  */ | ||||
| public class Keyboard { | ||||
|     public void keyDown(int keycode, ScreenPlayer sp, Controller c) { | ||||
|         if (keycode == Input.Keys.SPACE) c.keyStatus.put(Input.Keys.A, true); | ||||
|         c.keyStatus.put(keycode, true); | ||||
|     } | ||||
|     public void onKeyUp(int keycode, ScreenPlayer sp, Controller c) { | ||||
|         if (keycode == Input.Keys.SPACE) c.keyStatus.put(Input.Keys.A, false); | ||||
|         c.keyStatus.put(keycode, false); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -33,17 +33,13 @@ public class Battle { | ||||
|  | ||||
|     public void readNextLine(){ | ||||
|     //change line | ||||
|     System.out.println(textEnemy.lines.size()); | ||||
|     //System.out.println(textEnemy.lines.size()); | ||||
|         if(lineSpeech < 5){ | ||||
|             lineSpeech++; | ||||
|         } | ||||
|  | ||||
| 	} | ||||
|  | ||||
|     public void action(int answer){ | ||||
|         System.out.println("pv enemy : " +pvEnemy); | ||||
|         System.out.println("xp player : " + xpPlayer); | ||||
|         System.out.println("xp win " + newXp); | ||||
|  | ||||
|        //the player is at the last question, the finish text must be displayed | ||||
|         if(getLineSpeech() == 4){ | ||||
| @@ -98,10 +94,10 @@ public class Battle { | ||||
|     public void updatePlayerEnemy(int xp){ | ||||
|         //add xp for the player | ||||
|         xpPlayer += xp; | ||||
|         if(xpPlayer>6000) xpPlayer = 6000; | ||||
|         //remove pv enemy | ||||
|         pvEnemy -= xp; | ||||
|         if(pvEnemy<0) pvEnemy =0; | ||||
|          | ||||
|     } | ||||
|  | ||||
|     public void finishSpeech(){ | ||||
| @@ -158,4 +154,8 @@ public class Battle { | ||||
|     public void setPlayer(Player p){ | ||||
|         this.player = p; | ||||
|     } | ||||
|  | ||||
|     public void updateText(){ | ||||
|         if(e != null) textEnemy.generateText(cursor); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -2,6 +2,8 @@ package Main; | ||||
|  | ||||
| import java.util.Vector; | ||||
|  | ||||
| import com.badlogic.gdx.Input; | ||||
|  | ||||
| import Control.Controller; | ||||
| import Entity.Enemy; | ||||
| import Entity.Entity; | ||||
| @@ -21,7 +23,6 @@ public class PokeHES extends PortableApplication { | ||||
| 	private static Vector<Entity> entities = new Vector<>(); | ||||
|     private long beginTime; | ||||
|     private long lastMesure; | ||||
|     private long stairTime; | ||||
|  | ||||
|     public static boolean risingFront = false; | ||||
|  | ||||
| @@ -146,14 +147,16 @@ public class PokeHES extends PortableApplication { | ||||
|     public void onKeyDown(int keycode) { | ||||
|         super.onKeyDown(keycode); | ||||
|         risingFront = true; | ||||
|         if (keycode == Input.Keys.SPACE) controller.keyStatus.put(Input.Keys.A, true); | ||||
|         if (keycode == Input.Keys.ENTER) controller.keyStatus.put(Input.Keys.A, true); | ||||
|         controller.keyStatus.put(keycode, true); | ||||
|         sp.screenManager.getActiveScreen().onKeyUp(keycode); | ||||
|     } | ||||
|     @Override | ||||
|     public void onKeyUp(int keycode) { | ||||
|         super.onKeyUp(keycode); | ||||
|         risingFront = false; | ||||
|         if (keycode == Input.Keys.SPACE) controller.keyStatus.put(Input.Keys.A, false); | ||||
|         if (keycode == Input.Keys.ENTER) controller.keyStatus.put(Input.Keys.A, false); | ||||
|         controller.keyStatus.put(keycode, false); | ||||
|         sp.screenManager.getActiveScreen().onKeyDown(keycode); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -28,7 +28,7 @@ public class ScreenBattle extends RenderingScreen{ | ||||
| 	private BitmapImage enemyImg; | ||||
| 	private BitmapImage playerImg; | ||||
|  | ||||
| 	private Battle b = null; | ||||
| 	public Battle b = null; | ||||
|  | ||||
|  | ||||
|     @Override | ||||
| @@ -109,6 +109,17 @@ public class ScreenBattle extends RenderingScreen{ | ||||
| 	public void manage(Controller c, Battle battle){ | ||||
| 		//add a rising front to have one impulsion | ||||
| 		if(PokeHES.risingFront){ | ||||
| 			 | ||||
| 			if (c.keyStatus.get(Input.Keys.DOWN)){ | ||||
| 				battle.cursor++; | ||||
| 			} | ||||
| 			else if (c.keyStatus.get(Input.Keys.UP)){ | ||||
| 				battle.cursor--; | ||||
| 			} | ||||
|  | ||||
| 			if (battle.cursor > 3) battle.cursor = 0; | ||||
| 			if (battle.cursor < 0) battle.cursor = 3; | ||||
|  | ||||
| 			//the enemy is attacking | ||||
| 			if( battle.getAttackOn() == false){ | ||||
| 				if (c.keyStatus.get(Input.Keys.SPACE) || c.keyStatus.get(Input.Keys.A)){ | ||||
| @@ -116,33 +127,28 @@ public class ScreenBattle extends RenderingScreen{ | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			if (c.keyStatus.get(Input.Keys.DOWN)){ | ||||
| 				b.cursor++; | ||||
| 			} | ||||
| 			else if (c.keyStatus.get(Input.Keys.UP)){ | ||||
| 				b.cursor--; | ||||
| 			} | ||||
|  | ||||
| 			if (b.cursor>3)b.cursor =0; | ||||
| 			if (b.cursor<0)b.cursor =3; | ||||
|  | ||||
| 			System.out.println("" + b.cursor); | ||||
|  | ||||
| 			//the enemy is speaking | ||||
| 			if(battle.getAttackOn() == true){ | ||||
| 				if (c.keyStatus.get(Input.Keys.NUM_1) || c.keyStatus.get(Input.Keys.A) && b.cursor == 0){ | ||||
| 					battle.action(1); | ||||
| 					battle.cursor = 0; | ||||
| 				} | ||||
| 				else if (c.keyStatus.get(Input.Keys.NUM_2) || c.keyStatus.get(Input.Keys.A) && b.cursor == 1){ | ||||
| 					battle.action(2); | ||||
| 					battle.cursor = 0; | ||||
| 				} | ||||
| 				else if (c.keyStatus.get(Input.Keys.NUM_3) || c.keyStatus.get(Input.Keys.A) && b.cursor == 2){ | ||||
| 					battle.action(3); | ||||
| 					battle.cursor = 0; | ||||
| 				} | ||||
| 				else if (c.keyStatus.get(Input.Keys.NUM_4) || c.keyStatus.get(Input.Keys.A) && b.cursor == 3){ | ||||
| 					battle.action(4); | ||||
| 					battle.cursor = 0; | ||||
| 				} | ||||
| 			} | ||||
| 			 | ||||
| 			b.updateText(); | ||||
| 			 | ||||
| 			//mettre le front à false jusqu'à ce que le bouton soit relâché | ||||
| 			PokeHES.risingFront = false; | ||||
| 		} | ||||
|   | ||||
| @@ -2,7 +2,6 @@ package Text; | ||||
|  | ||||
| import Entity.Enemy; | ||||
| import java.util.Vector; | ||||
| import java.text.Normalizer; | ||||
| import java.util.Arrays; | ||||
| import java.util.Random; | ||||
|  | ||||
| @@ -30,6 +29,11 @@ public class TextEnemy { | ||||
|         //save random data (attack and answer) : attack, answer 1, answer 2 answer 3, answer 4 | ||||
|         currentData = new Vector<int[]>(); | ||||
|  | ||||
|         orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); | ||||
|  | ||||
|         //generate a random array to determine the order of the answer | ||||
|         orderAnswer = randomGenerate(0, 3, 4); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     public static int[] randomGenerate( int min, int max, int nbrRandom){ | ||||
| @@ -68,20 +72,21 @@ public class TextEnemy { | ||||
|  | ||||
|     //generate the text who is displays in battle screen | ||||
|     public void generateText(int cursor){ | ||||
|         lines.clear(); | ||||
|         int i =1; | ||||
|          | ||||
|         //introduction line | ||||
|         String introduction = formatLine(speechData.getSpeechs(0), CUT); | ||||
|         lines.add(new Line(introduction, false)); | ||||
|  | ||||
|         orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); | ||||
|         //orderAttack = randomGenerate(0, fightData.nbr_line-1, 4); | ||||
|  | ||||
|         for(int j=0; j<4;j++){ | ||||
|             int[] currentRandom = new int[5]; | ||||
|             currentRandom[0] = orderAttack[j]; | ||||
|  | ||||
|             //generate a random array to determine the order of the answer | ||||
|             orderAnswer = randomGenerate(0, 3, 4); | ||||
|             //orderAnswer = randomGenerate(0, 3, 4); | ||||
|  | ||||
|             //save the order of answer and attack | ||||
|             for(int k=1;k<5;k++){ | ||||
| @@ -90,7 +95,7 @@ public class TextEnemy { | ||||
|  | ||||
|             //Format the line | ||||
|             String[] row = new String[4]; | ||||
|             row[0] = row[1] = row[2] = row[3] = ""; | ||||
|             row[0] = row[1] = row[2] = row[3] = "    "; | ||||
|             row[cursor] = "->"; | ||||
|             String attack = formatLine(speechData.getSpeechs(i++) + fightData.getAttack(orderAttack[j]).attack + "  ("+fightData.getAttack(orderAttack[j]).getXp()+ ") ", CUT); | ||||
|             String answer1 = formatLine(row[0] + " " + fightData.getAttack(orderAttack[j]).getAnswer(orderAnswer[0]) , CUT); | ||||
| @@ -106,9 +111,11 @@ public class TextEnemy { | ||||
|         } | ||||
|          | ||||
|         //display answer | ||||
|         /* | ||||
|         for(int[] a : currentData){ | ||||
|             System.out.println(Arrays.toString(a)); | ||||
|         } | ||||
|         */ | ||||
|          | ||||
|  | ||||
|         //finish (win and death) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user