-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.pde
More file actions
70 lines (63 loc) · 1.32 KB
/
Main.pde
File metadata and controls
70 lines (63 loc) · 1.32 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
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
Aliens theAlien[];
final static ArrayList<Bullet> bulletList = new ArrayList();
Bomb theBomb;
PImage spaceInvader;
PImage explosion;
Player thePlayer;
int killCount=0;
void settings()
{
size(SCREENX, SCREENY);
}
void setup()
{
thePlayer = new Player(SCREENY-MARGIN-PADDLEHEIGHT);
theAlien = new Aliens[10];
theBomb = null;
spaceInvader = loadImage("Space_invaders_alien.png");
explosion = loadImage("explosion.png");
init_aliens(theAlien);
}
void draw()
{
background(0);
move_aliens(theAlien);
draw_aliens(theAlien);
thePlayer.move(mouseX);
thePlayer.draw();
for (Bullet theBullet : bulletList)
{
theBullet.draw();
theBullet.move();
theBullet.collide();
}
}
void init_aliens(Aliens theAlien[])
{
for (int i=0; i<theAlien.length; i++)
theAlien[i] = new Aliens((IMAGEWIDTH+20)*i, 0);
}
void draw_aliens(Aliens theAlien[])
{
for (int i=0; i<theAlien.length; i++)
theAlien[i].draw();
}
void move_aliens(Aliens theAlien[])
{
for (int i=0; i<theAlien.length; i++)
{
theAlien[i].move();
theBomb = theAlien[i].getBomb();
if (theBomb != null)
{
theBomb.draw();
theBomb.offScreen();
theBomb.move();
theBomb.collide();
}
}
}
void mousePressed()
{
bulletList.add(new Bullet());
}