Repository navigation
Expand file tree
/
Copy pathSpecial.java
More file actions
37 lines (35 loc) · 1.74 KB
/
Copy pathSpecial.java
File metadata and controls
37 lines (35 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Random;
import java.awt.Color;
import java.awt.geom.Rectangle2D;
import java.util.ArrayList;
import java.awt.Dimension;
import java.awt.Toolkit;
public class Special {
public Color couleurUp = new Color(0,255,0);
public Color couleurDown = new Color(0,0,255);
public Color couleurPoison = new Color(255,0,0);
public Color couleurBouton = new Color(255,255,255);
public ArrayList<Rectangle2D.Double> tabSpecial ;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public int nbSpecial;
public float rayon;
private Player joueur;
//création d'un Special : une ArrayList contenant des Rectangle2D.Double et des couleurs caractérisant chaque type d'élément spécial
// un carre est un Rectangle2D.Double de caractéristiques x,y,width,height avec x et y les coordonnées du coin nord est du carré
public Special(float rayon, int nbSpecial, Player joueur){
this.nbSpecial=nbSpecial;
this.rayon=rayon;
this.joueur=joueur;
tabSpecial= new ArrayList<Rectangle2D.Double>();
Rectangle2D.Double unSpecial;
for(int i=0;i<nbSpecial;i++){
Random a=new Random();
do{
unSpecial=(new Rectangle2D.Double(a.nextInt(30*(int)screenSize.getWidth())-a.nextInt(30*(int)screenSize.getWidth()),
a.nextInt(30*(int)screenSize.getHeight())-a.nextInt(30*(int)screenSize.getHeight()),
rayon, rayon)); // x,y,width,height
}while(joueur.playerr.intersects(unSpecial.x, unSpecial.y, unSpecial.width, unSpecial.height));
tabSpecial.add(unSpecial);
}
}
}