mirror of
https://github.com/Klagarge/PokeHES.git
synced 2025-07-17 21:31:10 +00:00
d
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user