-
Notifications
You must be signed in to change notification settings - Fork 0
/
fireball.h
116 lines (85 loc) · 2.96 KB
/
fireball.h
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
/*
* Dragon - Fireballs (dragon's breath)
* Copyright (C) 2017 Sandor Zsuga (Jubatian)
*
* 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 3 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, see <http://www.gnu.org/licenses/>.
*/
/*
** Realizes the fireballs breathed by the dragon.
**
** RAM storage:
** Byte 0: bits 0-5: Burnout timer, 0: Empty slot
** bits 6-7: Fireball collided (no further damage until zeroes)
** byte 1: X velocity (signed)
** byte 2: Y velocity (signed)
** Byte 3: Level coordinate, b0
** byte 4: Level coordinate, b1
** byte 5: Level coordinate, b2
**
** Fireballs start to burn out as soon as released. The timer is also a frame
** counter to produce frames of fireball animations.
*/
#ifndef FIREBALL_H
#define FIREBALL_H
#include "types.h"
#include "physics.h"
/* Total count of fireballs. Note: keep in sync with that in firebals.s and
** in acsupp.s!
** Note: More is necessary than what the dragon might use since bombs and
** other things might also generate them. */
#define FIREBALL_N 12U
/* Initial fireball age (max 63, ~2.1 sec) */
#define FIREBALL_AGE 63U
/*
** Initializes the storage with all fireballs cleared (free).
*/
void fireball_init(void);
/*
** Creates a new fireball if possible. If not possible, nothing happens.
*/
void fireball_new(uint16 x, uint16 y, asint xvel, asint yvel);
/*
** Ages a given fireball, accelerating its burnout. A fireball may be
** destroyed (removed) by bumping its burnout by 0xFF. Calling this will also
** mark the fireball collided, temporarily inactivating it for fireball-sprite
** collisions.
*/
void fireball_age(auint id, auint age);
/*
** Retrieve a fireball structure for reading, possibly used for collisions,
** interactions between sprites. Returns nonzero if the fireball doesn't
** exist.
*/
auint fireball_get(auint id, physics_spr_t* dest);
/*
** Returns whether there is a fireball within a sprite. Returns the fireball's
** ID if there is any or FIREBALL_N if there is none. This only returns
** fireballs which aren't inactivated.
*/
auint fireball_getat(physics_spr_t const* spr);
/*
** Processes fireballs (only the physics, not collisions)
*/
void fireball_process(void);
/*
** Renders fireballs
*/
void fireball_render(void);
/*
** Generates a single burning fire, may be used for objects on fire. Age is
** the fire's age which should decrement once every render frame until burning
** out.
*/
void fireball_render_fire(uint16 x, uint16 y, auint age);
#endif