1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-23 09:53:28 +00:00
This commit is contained in:
Fastium 2022-06-12 14:26:02 +02:00
parent c121320a04
commit 6248936e5a
4 changed files with 87 additions and 76 deletions

View File

@ -8,16 +8,19 @@ public class Battle {
private Enemy enemy; private Enemy enemy;
TextEnemy textEnemy; TextEnemy textEnemy;
public int lineSpeech = 0; private int lineSpeech;
public int answer;
public int answer = 0;
private boolean c;
public Battle(Enemy enemy){ public Battle(Enemy enemy){
this.enemy = enemy; this.enemy = enemy;
textEnemy = new TextEnemy("enemi"); // should be enemy.name textEnemy = new TextEnemy("enemi"); // should be enemy.name
textEnemy.generateText(); textEnemy.generateText();
lineSpeech = 0;
answer = 0;
//initialize the first line //initialize the first line
System.out.println("lll : "+ getLine()); System.out.println("lll : "+ getLine());
@ -26,6 +29,7 @@ public class Battle {
public void readNextLine(){ public void readNextLine(){
//change line //change line
lineSpeech++; lineSpeech++;
} }
public boolean getAttackOn(){ public boolean getAttackOn(){
@ -36,5 +40,9 @@ public class Battle {
return textEnemy.lines.get(lineSpeech).line; return textEnemy.lines.get(lineSpeech).line;
} }
public int getLineSpeech() {
return lineSpeech;
}
} }

View File

@ -52,7 +52,7 @@ public class ScreenBattle extends RenderingScreen{
displayDialog(g); displayDialog(g);
System.out.println(battle.lineSpeech); System.out.println("render: " + battle.getLineSpeech());
} }
@Override @Override
@ -97,7 +97,7 @@ public class ScreenBattle extends RenderingScreen{
public void manage(Controller c){ public void manage(Controller c){
if(PokeMudry.front_montant){ if(PokeMudry.front_montant){
System.out.println(battle.lineSpeech); System.out.println("manage: " + battle.getLineSpeech());
if( battle.getAttackOn() == false){ if( battle.getAttackOn() == false){

View File

@ -36,26 +36,42 @@ public class TextEnemy {
} }
int[] randomGenerate(int max_val){ int[] randomGenerate(int max_val){
int min_val = 0; int max = 8-1;
Random r = new Random();
int nbre = 4;
int[] t = new int[nbre];
int x; int x;
int[] t = new int[max_val-1];
Random ran = new Random();
int i=0; int i=0;
boolean same = false;
// initialize array at -1
for(int j=0; j<nbre ; j++){
t[j] = -1;
}
while(i<t.length){ //assign 4 different random value between 0 and max
System.out.println(i); while(i< nbre){
t[i] = ran.nextInt(max_val) + min_val; x = r.nextInt(max);
//test if the value is valid
for(int j : t){ for(int j : t){
if(t[i] == j){ if(x==j){
t[i] = ran.nextInt(max_val) + min_val; same = true;
break;
}
}
//do again the loop
if(same){
same = false;
} }
else{ else{
t[i] = x;
i++; i++;
} }
} }
}
return t; return t;
} }

View File

@ -1,67 +1,54 @@
import java.util.Map; import java.util.Random;
import java.util.TreeMap;
import Control.Controller;
import Entity.Enemy;
import Screen.ScreenBattle;
import Screen.ScreenPlayer;
import ch.hevs.gdx2d.desktop.PortableApplication;
import ch.hevs.gdx2d.lib.GdxGraphics;
import ch.hevs.gdx2d.lib.ScreenManager;
public class testYann extends PortableApplication{
ScreenPlayer sp = new ScreenPlayer();
public Map<Integer, Boolean> keyStatus = new TreeMap<Integer, Boolean>();
double zoom;
Controller controller = new Controller();
class testYann{
public static void main(String[] args) { public static void main(String[] args) {
new testYann(); int max = 8-1;
Random r = new Random();
int nbre = 4;
int[] a = new int[nbre];
int x;
int i=0;
boolean same = false;
for(int j=0; j<nbre ; j++){
a[j] = -1;
} }
testYann(){ while(i< nbre){
super( 800, 800); x = r.nextInt(max);
} System.out.println(x);
for(int j : a){
@Override if(x==j){
public void onInit() { same = true;
Enemy e = new Enemy("enemi", 50, 50, "resources//lumberjack_sheet32.png", "desert");
}
@Override
public void onGraphicRender(GdxGraphics g) {
sp.render(g);
sp.sb.manage(controller);
}
@Override
public void onDispose() {
// TODO Auto-generated method stub
super.onDispose();
}
@Override
public void onKeyUp(int keycode) {
super.onKeyUp(keycode);
controller.keyStatus.put(keycode, false);
}
@Override
public void onKeyDown(int keycode) {
super.onKeyDown(keycode);
switch (keycode) {
default:
break; break;
} }
controller.keyStatus.put(keycode, true);
} }
if(same){
same = false;
}
else{
a[i] = x;
i++;
}
}
System.out.println("\n");
for(int j : a){
System.out.println(j);
}
}
} }