Fixed a unused result warning.
[cantaveria.git] / inner.c
blob871f418eba701898d955dbb883d8ef61f59209c7
1 #include <stdio.h>
2 #include <stdlib.h>
5 //#include <root.h>
7 #include <list.h>
8 #include <util.h>
10 #include <input.h>
11 //#include <entity.h>
12 #include <transfer.h>
13 #include <gameover.h>
15 #include <console.h>
17 #include <stage.h>
18 #include <camera.h>
19 #include <hud.h>
21 int cx = 0;
22 int cy = 0;
23 int cvx = 0;
24 int cvy = 0;
26 static void update(){
27 /*
28 update camera
29 update every entity in the update list
30 dispatch collision events
31 execute spawn and delete events
33 cx += cvx;
34 cy += cvy;
35 point_camera(cx, cy);
38 static void draw(){
39 stage_draw_bg(cx, cy);
40 //entity_draw_visible(cx, cy);
41 stage_draw_fg(cx, cy);
42 //hud_draw(cx, cy);
47 static void press(input in){
48 if(in.button == ESCAPE_KEY){
49 game_is_over();
50 return;
52 printf("press: %s\n", input_str(in));
54 switch(in.button){
55 case LEFT_BUTTON: cvx += -1; break;
56 case RIGHT_BUTTON: cvx += 1; break;
57 case UP_BUTTON: cvy += -1; break;
58 case DOWN_BUTTON: cvy += 1; break;
59 default: break;
63 send input events
67 static void release(input in){
68 printf("release: %s\n", input_str(in));
71 send input events
73 switch(in.button){
74 case LEFT_BUTTON: cvx -= -1; break;
75 case RIGHT_BUTTON: cvx -= 1; break;
76 case UP_BUTTON: cvy -= -1; break;
77 case DOWN_BUTTON: cvy -= 1; break;
78 default: break;
82 void setup_inner(){
83 /* create entities */
84 console_clear();
85 set_handler(update, draw, press, release);
88 unload_zone();
89 int x = load_zone("woods");
90 if(x < 0){
91 error_msg("inner: cannot load zone\n");
92 exit(-1);
94 else{
95 //print_zone(x);
97 //stage_debug();
98 //unload_zone();
99 switch_stage("base");
112 stage - the stage, collision with stage, stage events
113 entity - moving, colliding, active/inactive stuff
114 inner - update draw press release
118 this is the inner file
119 the starting point to the internal game workings
120 independent of i/o, game loops, or graphics details
122 draw - draw the current state of the game
123 use current camera pos to...
124 draw the stage, efficiently draws the tiles and background
125 draw visible entities
126 draw effects
127 draw foreground decorations
128 draw gui elements
130 update -
131 move entities / execute collision
132 update camera
133 deactivate certain entities
135 press -
136 do global actions like pause, open menu
137 do player specific actions
139 setup -