Imported kball_final_src_16dec2004.tar.gz
[kball.git] / include / gkernel.h
blob3b91bd9c5a2b4b40617988a40c431efd33d3d117
1 // -----------------------------------------------
2 // gkernel.h
3 // -----------------------------------------------
4 // Game main loop and kernel
5 // -----------------------------------------------
6 // By Kronoman - July 2003
7 // Updated to C++ class in January 2004
8 // In loving memory of my father
9 // -----------------------------------------------
10 #ifndef GKERNEL_H
11 #define GKERNEL_H
13 #include <allegro.h>
14 #include "cball.h" // player ball
15 #include "tmap.h" // tile map
16 #include "cwdata.h" // datafile handler
17 #include "partmang.h" // particle manager
18 #include "backgbmp.h" // background manager
19 #include "mytracer.h" // this shit keeps crashing, I need to debug it... dammit!
20 #include "sound.h" // amazing sound system :o
21 #include "stats.h" // game statistics
22 #include "musiclvl.h" // music
24 // timer update ratio, in BPS
25 #define GKERNEL_FPSQ 30
27 // special flag for when the user aborts the game with ESC
28 #define GKERNEL_USER_FINISHED_GAME -666
31 // This class has the game kernel.
32 class CGameKernel
34 public:
35 CGameKernel();
36 ~CGameKernel();
38 // this are the prefered method to start and play a game session
39 int play_a_single_level(char *level_filename);
40 void play_a_full_campaign(char *level_filename);
42 // from here, stuff is almost internal only, because they are pretty 'low level'; altough may come handy
43 void init(); // initializes game (sets timers, loads data, etc)
44 void shutdown(); // shuts down game (unsets timers, unloads data, etc)
46 int game_loop(); // this is the main game loop; will return CBALL_IS_DEAD, or CBALL_EXIT_LEVEL (dead, or won level)
47 int update_logic(); // this updates 1 logic update of game ; will return CBALL_IS_DEAD, CBALL_IS_FINE, or CBALL_EXIT_LEVEL
49 void update_screen(); // this updates the screen
51 void load_level_file(const char *file); // loads a level from a file, and sets the game ready to play on that level -- *MUST* BE CALLED BEFORE STARTING THE GAME LOOP!
53 BITMAP *tile_bmp_to_screen_size(BITMAP *bmp); // tiles a bitmap to screen size, basically its purpose is to tile the level's background
55 CBall player_ball; // ball of the player, I need to touch this from 'outside' ; basically, set the live ammount before each game
57 CGameStats stats; // game statistics, I may need to touch them from 'outside'
59 private:
61 bool game_over; // game over?
62 CTMap game_map; // tile map loaded (with his own tile set)
63 CParticleManager particle_manager; // particle manager
64 CWDatafile main_data_file; // DATAFILE loaded
66 BITMAP *dbuffer; // doble buffer
67 BITMAP *backdropbmp; // background bitmap for current level
68 CBackground background_loader; // loader system for level's background from datafile
71 FONT *game_time_font; // font for showing time left on game
72 FONT *game_score_font; // font for showing score on game
73 FONT *game_messages_font; // font for showing messages on game
75 CSoundWrapper soundw; // sound system
76 CMusicLvl music_loader; // loader system for music from datafile
79 // current level file name (so we can reload it when player loses, etc)
80 char current_level_file_name[1024];
82 // for all the class data
83 static int timer_installed_count; // how many times we installed the timer; when this is 0, remove/install timers
85 // debug tracer
86 CMyTracer mtracer; // my tracer to debug this crap
89 #endif