1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-26 19:13:27 +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 = 0; public int answer;
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(){
@ -35,6 +39,10 @@ public class Battle {
public String getLine(){ public String getLine(){
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

@ -35,26 +35,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;
}
//assign 4 different random value between 0 and max
while(i< nbre){
x = r.nextInt(max);
while(i<t.length){ //test if the value is valid
System.out.println(i);
t[i] = ran.nextInt(max_val) + min_val;
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;
else{
i++;
} }
} }
//do again the loop
if(same){
same = false;
}
else{
t[i] = x;
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>(); class testYann{
double zoom;
Controller controller = new Controller();
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;
}
while(i< nbre){
x = r.nextInt(max);
System.out.println(x);
for(int j : a){
if(x==j){
same = true;
break;
}
}
if(same){
same = false;
}
else{
a[i] = x;
i++;
}
}
System.out.println("\n");
for(int j : a){
System.out.println(j);
}
} }
testYann(){
super( 800, 800);
}
@Override }
public void onInit() {
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;
}
controller.keyStatus.put(keycode, true);
}
}