-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.c
executable file
·207 lines (179 loc) · 6.89 KB
/
player.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// Graeber
//
// Copyright (C) 2018-2021 Heiko Wolf
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License As published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY Or FITNESS For A PARTICULAR PURPOSE. See the
// GNU General Public License For more details.
//
// You should have received a copy of the GNU General Public License along
// With this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// Kontakt: projekte@kabelmail.net
//#pragma bank 1
#include "player.h"
#include "engine.h"
#include "items.h"
///Init
void p_player_init (void) __banked
{
v_slp = 3; v_smlp = 3; v_sxk = 16; v_syk = 16; v_sgo = 0; v_smgo = 250; v_edelstein = 0;
v_shalt = 5; v_smhalt = 5; v_sschlaege = 0;
set_sprite_tile (0, 0);
set_sprite_tile (1, 1);
}
///setzt Spielersprite und berechnet Bildschirmkoordinate
void p_player_setSprite (UINT8 l_xk, UINT8 l_yk, UINT8 l_mxk, UINT8 l_myk) __banked
{
v_sxk = l_xk;
v_syk = l_yk;
v_smxk = l_mxk;
v_smyk = l_myk;
v_smk = ((v_sxk - 8) / 8) + 20 * ((v_syk - 16) / 8);
move_sprite (0, v_sxk, v_syk);
}
///bewegt Spieler nach Norden (oben)
void p_player_moveNorth (void) __banked
{
v_sri = NORTH;
//Kolisionsdaten
if ((v_lvldat [v_smk - 20] != 3) &&
(v_lvldat [v_smk - 20] != 2) &&
(v_lvldat [v_smk - 20] != 6) &&
(v_lvldat [v_smk - 20] != 7))
{
p_player_setSprite (v_sxk, v_syk - 8, v_smxk, v_smyk - 1);
p_item ();
}
}
///bewegt Spieler nach Süden (unten)
void p_player_moveSouth (void) __banked
{
v_sri = SOUTH;
//Kolisionsdaten
if ((v_lvldat [v_smk + 20] != 3) &&
(v_lvldat [v_smk + 20] != 2) &&
(v_lvldat [v_smk + 20] != 6) &&
(v_lvldat [v_smk + 20] != 7))
{
p_player_setSprite (v_sxk, v_syk + 8, v_smxk, v_smyk + 1);
p_item ();
}
}
///bewegt Spieler nach Westen (links)
void p_player_moveWest (void) __banked
{
v_sri = WEST;
if ((v_lvldat [v_smk - 1] != 3) &&
(v_lvldat [v_smk - 1] != 2) &&
(v_lvldat [v_smk - 1] != 6) &&
(v_lvldat [v_smk - 1] != 7))
{
p_player_setSprite (v_sxk - 8, v_syk, v_smxk - 1, v_smyk);
p_item ();
}
}
///bewegt Spieler nach Osten (rechts)
void p_player_moveEast (void) __banked
{
v_sri = EAST;
if ((v_lvldat [v_smk + 1] != 3) &&
(v_lvldat [v_smk + 1] != 2) &&
(v_lvldat [v_smk + 1] != 6) &&
(v_lvldat [v_smk + 1] != 7))
{
p_player_setSprite (v_sxk + 8, v_syk, v_smxk + 1, v_smyk);
p_item ();
}
}
///Schlag Spitzhacke Spieler
void p_player_schlag (void) __banked
{
if (v_sri == NORTH)
{
move_sprite (1, v_sxk, v_syk - 8);
if (v_lvldat [v_smk - 20] == 3) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk, v_smyk - 1, 1, 1, v_tile);
v_lvldat [v_smk - 20] = 1; ++v_sschlaege;
}
else if (v_lvldat [v_smk - 20] == 2) {
v_tile [0] = 7;
set_bkg_tiles (v_smxk, v_smyk - 1, 1, 1, v_tile);
v_lvldat [v_smk - 20] = 7; ++v_sschlaege;
}
else if (v_lvldat [v_smk - 20] == 7) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk, v_smyk - 1, 1, 1, v_tile);
v_lvldat [v_smk - 20] = 1; ++v_sschlaege;
}
}
else if (v_sri == SOUTH)
{
move_sprite (1, v_sxk, v_syk + 8);
if (v_lvldat [v_smk + 20] == 3) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk, v_smyk + 1, 1, 1, v_tile);
v_lvldat [v_smk + 20] = 1; ++v_sschlaege;
}
else if (v_lvldat [v_smk + 20] == 2) {
v_tile [0] = 7;
set_bkg_tiles (v_smxk, v_smyk + 1, 1, 1, v_tile);
v_lvldat [v_smk + 20] = 7; ++v_sschlaege;
}
else if (v_lvldat [v_smk + 20] == 7) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk, v_smyk + 1, 1, 1, v_tile);
v_lvldat [v_smk + 20] = 1; ++v_sschlaege;
}
}
else if (v_sri == WEST) {
move_sprite (1, v_sxk - 8, v_syk);
if (v_lvldat [v_smk - 1] == 3) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk - 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk - 1] = 1; ++v_sschlaege;
}
else if (v_lvldat [v_smk - 1] == 2) {
v_tile [0] = 7;
set_bkg_tiles (v_smxk - 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk - 1] = 7; ++v_sschlaege;
}
else if (v_lvldat [v_smk - 1] == 7) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk - 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk - 1] = 1; ++v_sschlaege;
}
}
else if (v_sri == EAST) {
move_sprite (1, v_sxk + 8, v_syk);
if (v_lvldat [v_smk + 1] == 3) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk + 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk + 1] = 1; ++v_sschlaege;
}
else if (v_lvldat [v_smk + 1] == 2) {
v_tile [0] = 7;
set_bkg_tiles (v_smxk + 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk + 1] = 7; ++v_sschlaege;
}
else if (v_lvldat [v_smk + 1] == 7) {
v_tile [0] = 1;
set_bkg_tiles (v_smxk + 1, v_smyk, 1, 1, v_tile);
v_lvldat [v_smk + 1] = 1; ++v_sschlaege;
}
}
v_sangriff = TRUE;
v_angriffstimer = 0;
if (v_sschlaege == 25) {
--v_shalt;
v_sschlaege = 0;
}
}