]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_sprite.h
c2a1d30164fc9f806f32d62d0f3ad38e0561cf1e
[16.git] / src / lib / 16_sprite.h
1 /* Project 16 Source Code~
2  * Copyright (C) 2012-2016 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
3  *
4  * This file is part of Project 16.
5  *
6  * Project 16 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Project 16 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,
19  * Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22 #ifndef __16_SPRI__
23 #define __16_SPRI__
24
25 #include "src/lib/16_vrs.h"
26 #include "src/lib/typdefst.h"
27
28 struct sprite
29 {
30         // VRS container from which we will extract animation and image data
31         struct vrs_container *spritesheet;
32         // Current sprite id
33         int curr_spri_id;
34         // Index of a current sprite in an animation sequence
35         int curr_anim_spri;
36         // Current animation sequence
37         struct vrs_animation_list_entry_t *curr_anim_list;
38         // Index of current animation in relevant VRS offsets table
39         int curr_anim;
40         // Delay in time units untill we should change sprite
41         int delay;
42         // Position of sprite on screen
43         int x, y;
44 };
45
46 /* Retrive current animation name of sprite
47 * In:
48 * + struct sprite *spri - sprite to retrive current animation sequence name from
49 * Out:
50 * + char* - animation sequence name
51 */
52 char* get_curr_anim_name(struct sprite *spri);
53
54 /* Change sprite's current animation to the one given by id
55  * In:
56  * struct sprite *spri - sprite to manipulate on
57  * int id - id of a new animation sequence of th sprite
58  * Out:
59  * int - 0 on success, -1 on error
60  */
61 int set_anim_by_id(struct sprite *spri, int id);
62
63 /* Animate sprite, triggering any events and changing indices if necessary
64  * NB: if you want to change animation sequence after a specific sprite is shown, you should call animate_spri first
65  * In:
66  * + struct sprite *spri - sprite to animate
67  */
68 void animate_spri(struct sprite *spri);
69
70 void print_anim_ids(struct sprite *spri);
71
72 #endif