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