-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpawner.java
96 lines (81 loc) · 2.78 KB
/
Spawner.java
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import java.util.ArrayList;
import java.awt.Color;
import java.awt.Graphics2D;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
public class Spawner extends Item{
private static BufferedImage imageFirst;
private static BufferedImage imageSecond;
private static BufferedImage imageThird;
private static BufferedImage imageForth;
private static BufferedImage imageFifth;
private int iSpawn;
private boolean close = false;
private int iClose = 0;
public Spawner(int posX, int posY, int iSpawn){
super(posX,posY);
this.iSpawn = iSpawn;
}
public static void loadAssets(){
try{
imageFirst = ImageIO.read(new File("world/spawn1-1.png"));
imageSecond = ImageIO.read(new File("world/spawn1-2.png"));
imageThird = ImageIO.read(new File("world/spawn1-3.png"));
imageForth = ImageIO.read(new File("world/spawn1-4.png"));
imageFifth = ImageIO.read(new File("world/spawn1-5.png"));
}catch(Exception e){e.printStackTrace();}
}
public void update(){
if(list.isEmpty()){
if (close) return;
close = true;
iClose = Window.getTps();
return;
}
if(((Window.getTps()%iSpawn)!=0)) return;
list.get(0).spawn();
list.remove(0);
}
public void draw(Graphics2D g){
//Dessine l'image avec l'image .png choisi au debut
if (!close){
if(Window.getTps()<10){
g.drawImage(imageFirst,posX-(int)(imageFirst.getWidth()/2),posY-(int)(imageFirst.getHeight()/2),null);
return;
}
if(Window.getTps()<20){
g.drawImage(imageSecond,posX-(int)(imageSecond.getWidth()/2),posY-(int)(imageSecond.getHeight()/2),null);
return;
}
if(Window.getTps()<30){
g.drawImage(imageThird,posX-(int)(imageThird.getWidth()/2),posY-(int)(imageThird.getHeight()/2),null);
return;
}
if(Window.getTps()<40){
g.drawImage(imageForth,posX-(int)(imageForth.getWidth()/2),posY-(int)(imageForth.getHeight()/2),null);
return;
}
g.drawImage(imageFifth,posX-(int)(imageFifth.getWidth()/2),posY-(int)(imageFifth.getHeight()/2),null);
}
else{
if((Window.getTps()-iClose)<10){
g.drawImage(imageFifth,posX-(int)(imageFifth.getWidth()/2),posY-(int)(imageFifth.getHeight()/2),null);
return;
}
if((Window.getTps()-iClose)<20){
g.drawImage(imageForth,posX-(int)(imageForth.getWidth()/2),posY-(int)(imageForth.getHeight()/2),null);
return;
}
if((Window.getTps()-iClose)<30){
g.drawImage(imageThird,posX-(int)(imageThird.getWidth()/2),posY-(int)(imageThird.getHeight()/2),null);
return;
}
if((Window.getTps()-iClose)<40){
g.drawImage(imageSecond,posX-(int)(imageSecond.getWidth()/2),posY-(int)(imageSecond.getHeight()/2),null);
return;
}
g.drawImage(imageFirst,posX-(int)(imageFirst.getWidth()/2),posY-(int)(imageFirst.getHeight()/2),null);
}
}
}