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

View File

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

View File

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

View File

@ -1,67 +1,54 @@
import java.util.Map;
import java.util.TreeMap;
import java.util.Random;
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) {
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(){
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:
while(i< nbre){
x = r.nextInt(max);
System.out.println(x);
for(int j : a){
if(x==j){
same = true;
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);
}
}
}