1 /* Tower Toppler - Nebulus
2 * Copyright (C) 2000-2012 Andreas R�ver
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 #include "robots.h"
20 #include "level.h"
21 #include "points.h"
22 #include "sound.h"
23
24 static int an;
25 static long subKind;
26 static long ve;
27 static long time;
28
snb_init(void)29 void snb_init(void) {
30 time = -1;
31 }
32
33 /* move the snowball and check if it hits something */
snb_movesnowball(void)34 void snb_movesnowball(void) {
35
36 /* the snowball moves up this fiels specifies by how much */
37 static long schusshoch[12] = {
38 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0
39 };
40
41 int nr;
42
43 if (time < 0) return;
44
45 if (time == 12) {
46 time = -1;
47 return;
48 }
49
50 time++;
51 an = (an + subKind * 2) & 0x7f;
52 ve += schusshoch[time - 1];
53
54 if (!lev_testfigure(an, ve, -1, 0, 2, 2, 5)) {
55 time = -1;
56 return;
57 }
58
59 nr = rob_snowballcollision(an, ve);
60
61 if (nr == -1)
62 return;
63 else {
64 ttsounds::instance()->startsound(SND_HIT);
65 pts_add(rob_gothit(nr));
66 time = -1;
67 }
68 }
69
snb_exists(void)70 bool snb_exists(void) { return time != -1; }
71
snb_start(int verticalpos,int anglepos,bool look_left)72 void snb_start(int verticalpos, int anglepos, bool look_left) {
73
74 ve = verticalpos;
75 if (!look_left) {
76 an = anglepos - 1;
77 subKind = -1;
78 } else {
79 an = anglepos + 1;
80 subKind = 1;
81 }
82 an &= 0x7f;
83 time = 0;
84 }
85
snb_verticalpos(void)86 int snb_verticalpos(void) { return ve; }
snb_anglepos(void)87 int snb_anglepos(void) { return an; }
88
89