Tennix 1.1 "Classic Championship Tour 2011" released
[tennix.git] / animation.h
blob1b50bd2e62cdb1daa540a4cbfa25c40ff97d59cb
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
22 **/
24 #ifndef __ANIMATION_H
25 #define __ANIMATION_H
27 #include "graphics.h"
29 enum {
30 ANIMATION_FADE_IN = 1<<0,
31 ANIMATION_FADE_OUT = 1<<1,
32 ANIMATION_FROM_BOTTOM = 1<<2,
33 ANIMATION_ZOOM_2X = 1<<3,
34 ANIMATION_SLIDE_LEFT = 1<<4,
35 ANIMATION_SLIDE_RIGHT = 1<<5
38 #define ANIMATION_INTRO_EFFECTS (ANIMATION_FADE_IN | ANIMATION_FADE_OUT | ANIMATION_ZOOM_2X)
40 /**
41 * How much time of the animation should be spent
42 * on fading (0.0..1.0) - usually 1/4 or so...
43 **/
44 #define ANIMATION_FADE_PART (0.25)
46 enum {
47 GRAVITY_TOPLEFT = 0,
48 GRAVITY_TOP,
49 GRAVITY_CENTER_SCREEN,
50 GRAVITY_CENTER_UPPERHALF,
51 GRAVITY_CENTER_BOTTOMHALF
54 struct _AnimationPart {
55 Uint32 start;
56 Uint32 end;
58 unsigned int effects;
60 int x;
61 int y;
62 int zindex;
64 SDL_Surface* surface;
65 unsigned char free_surface;
66 int pos;
67 int count;
69 unsigned int gravity;
71 struct _AnimationPart* prev;
72 struct _AnimationPart* next;
75 typedef struct _AnimationPart AnimationPart;
77 typedef struct {
78 AnimationPart *head;
79 AnimationPart *tail;
80 Uint32 duration;
81 } Animation;
83 typedef struct {
84 Animation* animation;
85 Uint32 started;
86 Uint32 current;
87 Uint32 ending;
88 } AnimationState;
91 Animation* animation_new();
92 Animation* animation_append(Animation*, AnimationPart*);
93 void animation_free(Animation*);
95 AnimationState* animation_state_new(Animation*);
96 void animation_state_run(AnimationState*, int);
97 int animation_state_update(AnimationState*);
98 void animation_state_free(AnimationState*);
100 AnimationPart* animation_part_new_from_surface(Uint32, Uint32, unsigned int,
101 int, int, int, unsigned int, SDL_Surface*, unsigned char, int, int);
103 AnimationPart* animation_part_new_text(Uint32, Uint32, unsigned int,
104 int, int, int, unsigned int, font_id, const char*, Uint8, Uint8,
105 Uint8);
107 void animation_part_display(AnimationPart*, AnimationState*);
108 void animation_part_free(AnimationPart*);
111 /* simplified function calls */
112 #define animation_part_new_from_surface_simple(start, end, effects, \
113 surface, free_surface) \
114 (animation_part_new_from_surface(start, end, effects, 0, 0, 0, \
115 GRAVITY_CENTER_SCREEN, surface, free_surface, 0, 1))
117 #define animation_part_new_text_simple(start, end, effects, id, text) \
118 (animation_part_new_text(start, end, effects, 0, 0, 0, \
119 GRAVITY_CENTER_SCREEN, id, text, 255, 255, 255))
122 /* available animations */
123 Animation* create_intro();
124 Animation* create_credits();
127 #endif