Skip to content

Commit 1eef000

Browse files
AMDmi3shinyquagsire23
authored andcommitted
Declare functions before they are used
1 parent 989d67e commit 1eef000

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

src/player.c

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,108 @@ void player_goto_door_in()
138138
player_entity.y = DOOR_IN_y;
139139
}
140140

141+
void player_bump(int dir, int x, int y)
142+
{
143+
u32 meta = -1;
144+
int bump_x = player_entity.x;
145+
int bump_y = player_entity.y;
146+
147+
switch(dir)
148+
{
149+
case LEFT:
150+
bump_x--;
151+
break;
152+
case RIGHT:
153+
bump_x++;
154+
break;
155+
case UP:
156+
bump_y--;
157+
break;
158+
case DOWN:
159+
bump_y++;
160+
break;
161+
case UP_LEFT:
162+
bump_x--;
163+
bump_y--;
164+
break;
165+
case UP_RIGHT:
166+
bump_x++;
167+
bump_y--;
168+
break;
169+
case DOWN_LEFT:
170+
bump_x--;
171+
bump_y++;
172+
break;
173+
case DOWN_RIGHT:
174+
bump_x++;
175+
bump_y++;
176+
break;
177+
default:
178+
break;
179+
}
180+
meta = map_get_meta(LAYER_MIDDLE, bump_x, bump_y);
181+
182+
int object_index = 0;
183+
bool locked;
184+
bool remove_tile = false;
185+
while(1)
186+
{
187+
obj_info *object = map_get_object(object_index++, bump_x, bump_y);
188+
if(object == NULL)
189+
break;
190+
191+
u32 obj_type = object->type;
192+
193+
if (obj_type == OBJ_DOOR_IN && !locked)
194+
{
195+
remove_tile = true;
196+
}
197+
else if (obj_type == OBJ_LOCK)
198+
{
199+
locked = true;
200+
remove_tile = false;
201+
printf("This door is locked!\n");
202+
}
203+
}
204+
205+
iact_set_trigger(IACT_TRIG_BumpTile, 3, bump_x, bump_y, map_get_tile(LAYER_MIDDLE, bump_x, bump_y));
206+
}
207+
208+
void player_stand(int x, int y)
209+
{
210+
u32 meta = map_get_meta(LAYER_MIDDLE, x, y);
211+
int object_index = 0;
212+
while(1)
213+
{
214+
obj_info *object = map_get_object(object_index++, x, y);
215+
if(object == NULL)
216+
break;
217+
218+
u32 obj_type = object->type;
219+
220+
if (obj_type == OBJ_DOOR_IN)
221+
{
222+
DOOR_IN_x = x;
223+
DOOR_IN_y = y;
224+
DOOR_IN_map = map_get_id();
225+
226+
PLAYER_MAP_CHANGE_REASON = MAP_CHANGE_DOOR_IN;
227+
228+
unload_map();
229+
load_map(object->arg);
230+
}
231+
else if (obj_type == OBJ_DOOR_OUT)
232+
{
233+
PLAYER_MAP_CHANGE_REASON = MAP_CHANGE_DOOR_OUT;
234+
235+
unload_map();
236+
load_map(DOOR_IN_map);
237+
}
238+
}
239+
240+
iact_set_trigger(IACT_TRIG_Walk, 2, player_entity.x, player_entity.y);
241+
}
242+
141243
void player_move(int dir)
142244
{
143245
if(dir != last_dir)
@@ -324,108 +426,6 @@ void player_handle_walk_animation()
324426
moving = 0;
325427
}
326428

327-
void player_bump(int dir, int x, int y)
328-
{
329-
u32 meta = -1;
330-
int bump_x = player_entity.x;
331-
int bump_y = player_entity.y;
332-
333-
switch(dir)
334-
{
335-
case LEFT:
336-
bump_x--;
337-
break;
338-
case RIGHT:
339-
bump_x++;
340-
break;
341-
case UP:
342-
bump_y--;
343-
break;
344-
case DOWN:
345-
bump_y++;
346-
break;
347-
case UP_LEFT:
348-
bump_x--;
349-
bump_y--;
350-
break;
351-
case UP_RIGHT:
352-
bump_x++;
353-
bump_y--;
354-
break;
355-
case DOWN_LEFT:
356-
bump_x--;
357-
bump_y++;
358-
break;
359-
case DOWN_RIGHT:
360-
bump_x++;
361-
bump_y++;
362-
break;
363-
default:
364-
break;
365-
}
366-
meta = map_get_meta(LAYER_MIDDLE, bump_x, bump_y);
367-
368-
int object_index = 0;
369-
bool locked;
370-
bool remove_tile = false;
371-
while(1)
372-
{
373-
obj_info *object = map_get_object(object_index++, bump_x, bump_y);
374-
if(object == NULL)
375-
break;
376-
377-
u32 obj_type = object->type;
378-
379-
if (obj_type == OBJ_DOOR_IN && !locked)
380-
{
381-
remove_tile = true;
382-
}
383-
else if (obj_type == OBJ_LOCK)
384-
{
385-
locked = true;
386-
remove_tile = false;
387-
printf("This door is locked!\n");
388-
}
389-
}
390-
391-
iact_set_trigger(IACT_TRIG_BumpTile, 3, bump_x, bump_y, map_get_tile(LAYER_MIDDLE, bump_x, bump_y));
392-
}
393-
394-
void player_stand(int x, int y)
395-
{
396-
u32 meta = map_get_meta(LAYER_MIDDLE, x, y);
397-
int object_index = 0;
398-
while(1)
399-
{
400-
obj_info *object = map_get_object(object_index++, x, y);
401-
if(object == NULL)
402-
break;
403-
404-
u32 obj_type = object->type;
405-
406-
if (obj_type == OBJ_DOOR_IN)
407-
{
408-
DOOR_IN_x = x;
409-
DOOR_IN_y = y;
410-
DOOR_IN_map = map_get_id();
411-
412-
PLAYER_MAP_CHANGE_REASON = MAP_CHANGE_DOOR_IN;
413-
414-
unload_map();
415-
load_map(object->arg);
416-
}
417-
else if (obj_type == OBJ_DOOR_OUT)
418-
{
419-
PLAYER_MAP_CHANGE_REASON = MAP_CHANGE_DOOR_OUT;
420-
421-
unload_map();
422-
load_map(DOOR_IN_map);
423-
}
424-
}
425-
426-
iact_set_trigger(IACT_TRIG_Walk, 2, player_entity.x, player_entity.y);
427-
}
428-
429429
void player_init()
430430
{
431431
player_entity.health = 300;

0 commit comments

Comments
 (0)