2 Cantaveria - action adventure platform game
3 Copyright (C) 2009 2010 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
22 evanrinehart@gmail.com
41 int game_over
= false;
47 void (*press
)(input in
);
48 void (*release
)(input in
);
52 static void terminate(){
58 static void press(input in
){ handler
.press(in
); }
59 static void release(input in
){ handler
.release(in
); }
61 void dispatch_error(const char* msg
){
62 error_msg("kernel.c dispatch_input: %s\n", msg
);
65 static void dispatch_input(){
66 input in
= get_input();
67 while(in
.type
!= NO_INPUT
){
69 case BUTTON_PRESS
: press(in
); break;
70 case BUTTON_RELEASE
: release(in
); break;
71 case END_OF_PROGRAM
: game_is_over(); break;
72 case SKIP_INPUT
: dispatch_error("SKIP_INPUT is not supposed to come from generator"); break;
73 case INVALID_INPUT
: dispatch_error("INVALID_INPUT produced in generator"); break;
74 case NO_INPUT
: dispatch_error("NO_INPUT is impossible here"); break;
80 void initialize(int argc
, char* argv
[]){
81 video_init(argc
, argv
);
87 rand_reset(RANDOM_SEED
);
117 void (*press
)(input in
),
118 void (*release
)(input in
)
120 handler
.update
= update
;
122 handler
.press
= press
;
123 handler
.release
= release
;