1
0
mirror of https://github.com/Klagarge/PokeHES.git synced 2024-11-23 01:43: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;
TextEnemy textEnemy;
public int lineSpeech = 0;
private int lineSpeech;
public int answer = 0;
private boolean c;
public int answer;
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(){
@ -35,6 +39,10 @@ public class Battle {
public String getLine(){
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

@ -35,26 +35,42 @@ public class TextEnemy {
}
int[] randomGenerate(int max_val){
int min_val = 0;
int[] randomGenerate(int max_val){
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;
}
//assign 4 different random value between 0 and max
while(i< nbre){
x = r.nextInt(max);
while(i<t.length){
System.out.println(i);
t[i] = ran.nextInt(max_val) + min_val;
//test if the value is valid
for(int j : t){
if(t[i] == j){
t[i] = ran.nextInt(max_val) + min_val;
}
else{
i++;
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;
}
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);
}
}
}