Stage drawing routine.
[cantaveria.git] / editor.c
blobf3bd8d9bad52726dcbe05195605bef5e09d152a8
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 #include <stdio.h>
25 #include "util.h"
26 #include "game.h"
27 #include "backend.h"
28 #include "loader.h"
29 #include "graphics.h"
30 #include "text.h"
38 void edit_keydown(int key){
39 printf("you pressed key %d\n",key);
40 if(key == ESCAPE_KEY){
41 game.end = 1;
45 void edit_keyup(int key){
46 printf("you release key %d\n",key);
49 void edit_joymovex(int joy, int x){
50 printf("you moved joystick %d x axis to %d\n",joy,x);
53 void edit_joymovey(int joy, int y){
54 printf("you moved joystick %d y axis to %d\n",joy,y);
57 void edit_joypress(int joy, int button){
58 printf("you pressed joystick %d button %d\n",joy,button);
61 void edit_joyrelease(int joy, int button){
62 printf("you released joystick %d button %d\n",joy,button);
65 struct handler edit_handler = {
66 edit_keydown, edit_keyup, edit_joymovex,
67 edit_joymovey, edit_joypress, edit_joyrelease
70 void main_init(int argc, char* argv[]){
71 backend_init(argc, argv);
72 loader_init();
73 graphics_init();
74 text_init();
76 game.handler = edit_handler;
77 game.update = NULL;
80 char** list = loader_readdir("zones");
81 for(int i=0; list[i]; i++){
82 printf("loading zone \"%s\"\n",list[i]);
83 load_zone(list[i]);
85 loader_freedirlist(list);
87 enable_stage(1);
91 void update(){
96 void main_quit(){
97 loader_quit();
98 backend_quit();
101 void main_loop(){
102 since();
103 int T = 0;
104 while(1){
105 T += since();
106 for(int i=0; i<T/dt; i++){
107 input();
108 update();
110 if(T/dt > 0){
111 draw();
112 T %= dt;
114 if(game.end){break;}
115 delay(DELAY_AMOUNT);
119 int main(int argc, char* argv[]){
121 main_init(argc, argv);
122 main_loop();
123 main_quit();
125 return 0;