comparison libmlk-rpg/mlk/rpg/walksprite.h @ 434:4e78f045e8c0

rpg: cleanup hierarchy
author David Demelier <markand@malikania.fr>
date Sat, 15 Oct 2022 21:24:17 +0200
parents src/libmlk-rpg/rpg/walksprite.h@8f59201dc76b
children 773a082f0b91
comparison
equal deleted inserted replaced
433:862b15c3a3ae 434:4e78f045e8c0
1 /*
2 * walksprite.h -- sprite designed for walking entities
3 *
4 * Copyright (c) 2020-2022 David Demelier <markand@malikania.fr>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef MLK_RPG_WALKSPRITE_H
20 #define MLK_RPG_WALKSPRITE_H
21
22 #include <mlk/core/core.h>
23
24 struct sprite;
25
26 /**
27 * \brief Sprite designed for walking entities.
28 *
29 * This structure works with sprite images that are defined as using the
30 * following conventions:
31 *
32 * ```
33 * 7 0 1
34 * ↖ ↑ ↗
35 * 6 ← → 2
36 * ↙ ↓ ↘
37 * 5 4 3
38 * ```
39 *
40 * Where numbers define row in the sprite according to the character
41 * orientation. In other terms, your image sprite should look like this:
42 *
43 * ```
44 * row columns in your image
45 * ---|---------------------
46 * 0 | ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
47 * 1 | ↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗↗
48 * 2 | →→→→→→→→→→→→→→→→→→→→
49 * 3 | ↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘↘
50 * 4 | ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
51 * 5 | ↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙↙
52 * 6 | ←←←←←←←←←←←←←←←←←←←←
53 * 7 | ↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖↖
54 * ```
55 */
56 struct walksprite {
57 struct sprite *sprite;
58 unsigned int delay;
59 unsigned int index;
60 unsigned int elapsed;
61 };
62
63 CORE_BEGIN_DECLS
64
65 void
66 walksprite_init(struct walksprite *, struct sprite *, unsigned int);
67
68 void
69 walksprite_reset(struct walksprite *);
70
71 void
72 walksprite_update(struct walksprite *, unsigned int);
73
74 void
75 walksprite_draw(const struct walksprite *, unsigned int, int, int);
76
77 CORE_END_DECLS
78
79 #endif /* !MLK_RPG_WALKSPRITE_H */