]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_sprit.h
a93838ace685a54dd0c4aab65acbb50b0a79424b
[16.git] / src / lib / 16_sprit.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         // Container for a vrl sprite
33         struct vrl_container *sprite_vrl_cont;
34         // Current sprite id
35         int curr_spri_id;
36         // Index of a current sprite in an animation sequence
37         int curr_anim_spri;
38         // Current animation sequence
39         struct vrs_animation_list_entry_t *curr_anim_list;
40         // Index of current animation in relevant VRS offsets table
41         int curr_anim;
42         // Delay in time units untill we should change sprite
43         int delay;
44         // Position of sprite on screen
45         int x, y;
46 };
47
48 /* Retrive current animation name of sprite
49 * In:
50 * + struct sprite *spri - sprite to retrive current animation sequence name from
51 * Out:
52 * + char* - animation sequence name
53 */
54 char* get_curr_anim_name(struct sprite *spri);
55
56 /* Change sprite's current animation to the one given by id
57  * In:
58  * struct sprite *spri - sprite to manipulate on
59  * int id - id of a new animation sequence of th sprite
60  * Out:
61  * int - 0 on success, -1 on error
62  */
63 int set_anim_by_id(struct sprite *spri, int id);
64
65 /* Animate sprite, triggering any events and changing indices if necessary
66  * NB: if you want to change animation sequence after a specific sprite is shown, you should call animate_spri first
67  * In:
68  * + struct sprite *spri - sprite to animate
69  */
70 void animate_spri(struct sprite *spri);
71
72 void print_anim_ids(struct sprite *spri);
73
74 #endif