Fixed function prototypes.
[cantaveria.git] / inner.c
blobc64642f0c7fdcbea537ca2ad9e5a348e79bff08b
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 #include <video.h>
23 #include <testplayer.h>
25 //typedef struct player player;
26 static player* pl = NULL;
28 static void update(){
29 /*
30 update camera
31 update every entity in the update list
32 dispatch collision events
33 execute spawn and delete events
36 int xx;
37 int yy;
39 int x0 = pl->x;
40 int y0 = pl->y;
41 int x1;
42 int y1;
44 update_player(pl);
45 x1 = pl->x;
46 y1 = pl->y;
48 if(stage_xcollide(x0, y0, pl->w, pl->h, x1-x0, &xx)){
49 collide_x(pl, xx);
50 x1 = pl->x;
53 if(stage_ycollide(x1, y0, pl->w, pl->h, y1-y0, &yy)){
54 collide_y(pl, yy);
59 static void draw(){
60 stage_draw_bg(0, 0);
61 //entity_draw_visible(cx, cy);
62 stage_draw_fg(0, 0);
63 // draw_gfx(dummy_gfx,px,py,16,0,8,8);
64 draw_player(pl);
65 //hud_draw(cx, cy);
70 static void press(input in){
71 if(in.button == ESCAPE_KEY){
72 game_is_over();
73 return;
76 player_press(pl, in.button);
79 static void release(input in){
80 player_release(pl, in.button);
83 void setup_inner(){
84 /* create entities */
85 console_clear();
86 set_handler(update, draw, press, release);
88 pl = mk_test_player(16*3,4*16);
90 unload_zone();
91 int x = load_zone("woods");
92 if(x < 0){
93 error_msg("inner: cannot load zone\n");
94 exit(-1);
96 else{
97 //print_zone(x);
99 //stage_debug();
100 //unload_zone();
101 switch_stage("base");
114 stage - the stage, collision with stage, stage events
115 entity - moving, colliding, active/inactive stuff
116 inner - update draw press release
120 this is the inner file
121 the starting point to the internal game workings
122 independent of i/o, game loops, or graphics details
124 draw - draw the current state of the game
125 use current camera pos to...
126 draw the stage, efficiently draws the tiles and background
127 draw visible entities
128 draw effects
129 draw foreground decorations
130 draw gui elements
132 update -
133 move entities / execute collision
134 update camera
135 deactivate certain entities
137 press -
138 do global actions like pause, open menu
139 do player specific actions
141 setup -