Added sound system.
[cantaveria.git] / backend.h
blobf64ba49d4d75682728698237ddec722705e7096e
1 /*
2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 Evan Rinehart
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to
18 The Free Software Foundation, Inc.
19 51 Franklin Street, Fifth Floor
20 Boston, MA 02110-1301, USA
23 enum {
24 ESCAPE_KEY,
25 PAUSE_KEY,
27 LEFT_KEY,
28 RIGHT_KEY,
29 UP_KEY,
30 DOWN_KEY,
32 FIRE_KEY,
33 JUMP_KEY,
34 INVENTORY_KEY,
35 SPECIAL_KEY,
37 L_KEY,
38 R_KEY,
39 START_KEY,
40 SELECT_KEY
43 enum{
44 FIRE_BUTTON,
45 JUMP_BUTTON,
46 INVENTORY_BUTTON,
47 SPECIAL_BUTTON,
48 L_BUTTON,
49 R_BUTTON,
50 START_BUTTON,
51 SELECT_BUTTON
54 enum{
55 KEYUP,
56 KEYDOWN,
57 JOYMOVEX,
58 JOYMOVEY,
59 JOYPRESS,
60 JOYRELEASE,
61 FOOBAR
64 #define JOY_MAX 32767
65 #define JOY_MIN -32768
67 #define MAX_PLAYERS 6
69 #define dt 10
70 #define DELAY_AMOUNT 1
72 #define SCREEN_W 320
73 #define SCREEN_H 240
75 #define MAX_GFX 256
76 #define MAX_SPRITES 256
77 #define MAX_ANIMATIONS 256
79 #define COLOR_KEY 0x000000
82 #define SAMPLE_RATE 44100
83 #define BUFFER_SIZE 1024
85 struct frame{
86 int x, y;
87 double x0, y0, x1, y1;
90 typedef struct sprite sprite;
91 struct sprite {
92 int number;
93 int frame_counter;
94 int current_frame;
95 struct frame frame;
96 int gfxid;
97 int anim;
98 int x, y, w, h, vx, vy;
99 void (*update)(sprite*, void* ud);
100 void* userdata;
103 typedef struct {
104 int w, h;
105 int loop_mode;/*0 stopped, 1 once, 2 repeat, 3 pingpong, 4 evaporate*/
106 int gfxid;
107 int frame_count;
108 short* frame_lens;
109 struct frame* frames;
110 } animation;
114 void backend_init(int argc, char* argv[]);
115 void backend_quit();
117 void input(); /* pump event system */
118 void draw(); /* draw all active graphics */
121 int since(); /* ms since last time since() was called */
122 void delay(int ms); /* wait ms ms */
124 int keynum(int name); /* get key number for key name */
125 int butnum(int joy, int name); /* get button number for button name */
126 void control(int type, int par1, int par2); /* automatic control */
128 int load_gfx(char* filename);
129 int load_sprite(char* filename, int id);
130 sprite* enable_sprite(int sprnum);
131 void disable_sprite(sprite* spr);
132 sprite* copy_sprite(sprite* spr);
135 int load_sound(char* filename);
136 void play_sound(int id);
137 int load_music(char* filename);
138 int play_music(int id);
141 void load_map(char* filename);
142 void unload_map();
144 void point_camera(int x, int y);
146 void animate_sprites();