-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpickup.c
97 lines (67 loc) · 2.18 KB
/
pickup.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
/***********************************************************
MEGA CAR WARS
PICKUP.C
Coins, health and info-spots question marks
***********************************************************/
#include "inc/pickup.h"
// LIBS ///////////////////////////////////////////////////
#include "inc/scenario.h"
#include "inc/screen.h"
#include "inc/hud.h"
// DATA ///////////////////////////////////////////////////
u8 colected_energy;
u8 colected_coins;
// FUNCTIONS //////////////////////////////////////////////
//---------------------------------------------------------
// INIT
//---------------------------------------------------------
u8 Pickup_init()
{
colected_energy = 0;
colected_coins = 0;
}
//---------------------------------------------------------
// PICKUP COIN
//---------------------------------------------------------
u8 Pickup_Coin()
{
if (colected_coins < MAX_COLECTED_COINS) colected_coins++;
HUD_drawCoins(colected_coins);
}
//---------------------------------------------------------
// PICKUP ENERGY
//---------------------------------------------------------
u8 Pickup_Energy()
{
if (colected_energy < MAX_COLECTED_ENERGY) colected_energy++;
HUD_drawEnergy(colected_energy);
}
//---------------------------------------------------------
// IS A COIN?
//---------------------------------------------------------
u8 Pickup_isCoin(u8 mapx, u8 mapy)
{
return (scenario.hardnessmap[(mapy * SCENARIO_WIDTH_TILES) + mapx] == TILE_COIN);
}
//---------------------------------------------------------
// IS ENERGY?
//---------------------------------------------------------
u8 Pickup_isEnergy(u8 mapx, u8 mapy)
{
return (scenario.hardnessmap[(mapy * SCENARIO_WIDTH_TILES) + mapx] == TILE_ENERGY);
}
//---------------------------------------------------------
// IS INFO?
// Check for "INFOSPLASH_ID_VOID" instead of zero
//---------------------------------------------------------
u8 Pickup_isInfo(u8 mapx, u8 mapy)
{
u8 value = scenario.hardnessmap[(mapy * SCENARIO_WIDTH_TILES) + mapx];
if TILE_IS_INFO(value)
{
// Return Info ID for that map
return TILE_GET_ATTRIBUTE(value);
}
// Else
return INFOSPLASH_ID_VOID;
}