Forgot to add new files.
[cantaveria.git] / inner.c
blob2d52723f8ef2989b5f8a3949b82a5d65ec5dec53
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 static void update(){
22 /*
23 update camera
24 update every entity in the update list
25 dispatch collision events
26 execute spawn and delete events
30 static void draw(){
31 int cx = camera_x();
32 int cy = camera_y();
33 //stage_draw_bg(cx, cy);
34 //entity_draw_visible(cx, cy);
35 //stage_draw_fg(cx, cy);
36 hud_draw(cx, cy);
39 static void press(input in){
40 if(in.button == ESCAPE_KEY){
41 game_is_over();
42 return;
44 printf("press: %s\n", input_str(in));
47 send input events
51 static void release(input in){
52 printf("release: %s\n", input_str(in));
55 send input events
59 void setup_inner(){
60 /* create entities */
61 console_clear();
62 set_handler(update, draw, press, release);
65 unload_zone();
66 int x = load_zone("3ztest/");
67 if(x < 0){
68 error_msg("inner: cannot load zone\n");
69 exit(-1);
71 else{
72 //print_zone(x);
73 unload_zone();
86 stage - the stage, collision with stage, stage events
87 entity - moving, colliding, active/inactive stuff
88 inner - update draw press release
92 this is the inner file
93 the starting point to the internal game workings
94 independent of i/o, game loops, or graphics details
96 draw - draw the current state of the game
97 use current camera pos to...
98 draw the stage, efficiently draws the tiles and background
99 draw visible entities
100 draw effects
101 draw foreground decorations
102 draw gui elements
104 update -
105 move entities / execute collision
106 update camera
107 deactivate certain entities
109 press -
110 do global actions like pause, open menu
111 do player specific actions
113 setup -