-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalien_class.js
76 lines (69 loc) · 1.9 KB
/
alien_class.js
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
// JavaScript Document
//<script type="text/javascript" src="drawBitmap_function.js">
function c_alien(l_x,l_y)
{
this.xpos = l_x;
this.ypos = l_y;
this.collisionflag = 0;
this.cannon = new c_bullet(5);
this.cannon.y_decrement = 5;
this.trigger = 0;
this.frameFlag = 1;
this.explosionFlag = 0;
this.alienFrame_1 = new Array(88);
this.alienFrame_2 = new Array(88);
this.alienFrame_1 = [ 0,0,1,0,0,0,0,0,1,0,0,
0,0,0,1,0,0,0,1,0,0,0,
0,0,1,1,1,1,1,1,1,0,0,
0,1,1,0,1,1,1,0,1,1,0,
1,1,1,1,1,1,1,1,1,1,1,
1,0,1,1,1,1,1,1,1,0,1,
1,0,1,0,0,0,0,0,1,0,1,
0,0,0,1,1,0,1,1,0,0,0 ]
this.alienFrame_2 = [ 0,0,1,0,0,0,0,0,1,0,0,
1,0,0,1,0,0,0,1,0,0,1,
1,0,1,1,1,1,1,1,1,0,1,
1,1,1,0,1,1,1,0,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,
0,0,1,1,1,1,1,1,1,0,0,
0,0,1,0,0,0,0,0,1,0,0,
0,1,0,0,0,0,0,0,0,1,0 ]
this.alienFrame_3 = [ 0,1,0,0,0,1,0,0,0,1,0,
0,0,1,0,0,1,0,0,1,0,0,
0,0,0,1,0,1,0,1,0,0,0,
1,1,1,0,0,0,0,0,1,1,1,
0,0,0,1,0,1,0,1,0,0,0,
0,0,1,0,0,1,0,0,1,0,0,
0,1,0,0,0,1,0,0,0,1,0 ]
this.drawAlien = drawAlien;
this.managebullet = managebullet;
}
function drawAlien()
{
if(this.collisionflag!=1)
{
if(this.frameFlag==1)
{
drawBitmap(this.alienFrame_1,this.xpos,this.ypos,11,88,4,4,"#00ff00");
}
if(this.frameFlag==-1)
{
drawBitmap(this.alienFrame_2,this.xpos,this.ypos,11,88,4,4,"#00ff00");
}
}
if((this.collisionflag==1)&&(this.explosionFlag==0))
{
drawBitmap(this.alienFrame_3,this.xpos,this.ypos,11,88,4,4,"#00ff00");
this.explosionFlag=1;
}
}
function managebullet()
{
if(this.trigger==1)
{
this.cannon.xpos = this.xpos+15; //15= to fire bullet from the center of the spaceship
this.cannon.ypos = this.ypos+28;
this.cannon.active = 1;
this.trigger=0;
}
}