-
Notifications
You must be signed in to change notification settings - Fork 0
/
drop rocket.c
130 lines (107 loc) · 1.93 KB
/
drop rocket.c
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/***
*int drop_rocket
*
*Purpose:
* move the rocket y down, x by tank position.
*Entry:
*
*
*Exit:
* TIE = continue.
* LOOSE = end of game
*
**********************************************************/
#include "atari.h"
int drop_rocket (
BOMB *rocket,
int *tank_x,
int *tanks,
short screen[][ROW],
char *tank_shape,
short BackGround[][ROW + 1],
short Tools_Color[]
)
{
int dir = 0;
int next = 0;
char rocket_shape[] = {(char)219, 31};
if (*tank_x < rocket -> x)
{
dir = rocket -> x - 1;
}
else if (*tank_x > rocket -> x)
{
dir = rocket -> x + 1;
}
else
{
dir = rocket -> x;
}
next = screen[dir][(rocket -> y) + 1];
if (next == TANK_ON)
{
Clear_Object (
screen,
BackGround,
rocket -> x,
rocket -> y - 1,
0, 2
);
rocket -> on = false;
//CHANGE THE COLOR OF THE TANK WHAN GOT SHOT.
Move_Object (
BackGround,
tank_shape,
LIGHT_RED,
*tank_x - 2,
ROW,
5, 0
);
-- *tanks;
SetColor(YELLOW, LIGHT_BLUE);
SetCursor (70, 0);
printf("TANKS:%d",*tanks);
sndPlaySound ("Explode.wav", SND_SYNC);
// GIVE THE TANK THE ORIGINAL COLOR.
Move_Object (
BackGround,
tank_shape,
Tools_Color[TAN],
*tank_x - 2,
ROW,
5, 0
);
}
else if (rocket -> y >= ROW - 1)
{
Clear_Object (
screen,
BackGround,
rocket -> x,
rocket -> y - 1,
0, 2
);
rocket -> on = false;
}
else //((next == 0 || next == ARROW_ON) && rocket -> y < ROW)
{
Clear_Object (
screen,
BackGround,
rocket -> x,
rocket -> y - 1,
0, 3
);
rocket -> x = dir;
rocket -> y ++;
Move_Object (
BackGround,
rocket_shape,
Tools_Color[BOM],
rocket -> x,
rocket -> y - 1,
0, 2);
}
if (*tanks > 0) return TIE;
else return LOOSE;
}