Mercurial > molko
comparison src/libmlk-rpg/rpg/walksprite.h @ 320:8f9937403749
misc: improve loading of data
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 01 Oct 2021 20:30:00 +0200 |
parents | libmlk-rpg/rpg/walksprite.h@d01e83210ca2 |
children | 19782ea1cf4a |
comparison
equal
deleted
inserted
replaced
319:b843eef4cc35 | 320:8f9937403749 |
---|---|
1 /* | |
2 * walksprite.h -- sprite designed for walking entities | |
3 * | |
4 * Copyright (c) 2020-2021 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 MOLKO_RPG_WALKSPRITE_H | |
20 #define MOLKO_RPG_WALKSPRITE_H | |
21 | |
22 #include <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 /* !MOLKO_RPG_WALKSPRITE_H */ |