Added entities. Rewrote stage, half 'working'.
[cantaveria.git] / inner.c
blobc80f8bb0873fa02c7bfbfb20004e6a4367626016
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 <stage.h>
12 #include <entity.h>
13 #include <transfer.h>
14 #include <gameover.h>
16 #include <console.h>
18 #include <camera.h>
19 #include <hud.h>
21 #include <video.h>
25 static void update(){
26 /*
27 update camera
28 update every entity in the update list
29 dispatch collision events
30 execute spawn and delete events
35 entity_master_simulate();
39 static void draw(){
40 stage_draw_bg(0, 0);
41 //entity_draw_visible(cx, cy);
42 stage_draw_fg(0, 0);
43 // draw_gfx(dummy_gfx,px,py,16,0,8,8);
44 // draw_player(pl);
45 //hud_draw(cx, cy);
46 draw_entities();
51 static void press(input in){
52 if(in.button == ESCAPE_KEY){
53 game_is_over();
54 return;
57 player_press(in.player, in.button);
60 static void release(input in){
61 player_release(in.player, in.button);
64 void setup_inner(){
65 /* create entities */
66 console_clear();
67 set_handler(update, draw, press, release);
70 setup_test_entities();
73 unload_zone();
74 int x = load_zone("woods");
75 if(x < 0){
76 error_msg("inner: cannot load zone\n");
77 exit(-1);
79 else{
80 //print_zone(x);
82 //stage_debug();
83 //unload_zone();
84 switch_stage("base");
97 stage - the stage, collision with stage, stage events
98 entity - moving, colliding, active/inactive stuff
99 inner - update draw press release
103 this is the inner file
104 the starting point to the internal game workings
105 independent of i/o, game loops, or graphics details
107 draw - draw the current state of the game
108 use current camera pos to...
109 draw the stage, efficiently draws the tiles and background
110 draw visible entities
111 draw effects
112 draw foreground decorations
113 draw gui elements
115 update -
116 move entities / execute collision
117 update camera
118 deactivate certain entities
120 press -
121 do global actions like pause, open menu
122 do player specific actions
124 setup -