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
40 int game_over
= false;
46 void (*press
)(input in
);
47 void (*release
)(input in
);
51 static void terminate(){
57 static void press(input in
){ handler
.press(in
); }
58 static void release(input in
){ handler
.release(in
); }
60 void dispatch_error(const char* msg
){
61 report_error("kernel.c dispatch_input: %s\n", msg
);
64 static void dispatch_input(){
65 input in
= get_input();
66 while(in
.type
!= NO_INPUT
){
68 case BUTTON_PRESS
: press(in
); break;
69 case BUTTON_RELEASE
: release(in
); break;
70 case END_OF_PROGRAM
: game_is_over(); break;
71 case SKIP_INPUT
: dispatch_error("SKIP_INPUT is not supposed to come from generator"); break;
72 case INVALID_INPUT
: dispatch_error("INVALID_INPUT produced in generator"); break;
73 case NO_INPUT
: dispatch_error("NO_INPUT is impossible here"); break;
79 void initialize(int argc
, char* argv
[]){
80 video_init(argc
, argv
);
86 rand_reset(RANDOM_SEED
);
116 void (*press
)(input in
),
117 void (*release
)(input in
)
119 handler
.update
= update
;
121 handler
.press
= press
;
122 handler
.release
= release
;