#include #include #include #include #include "SDL.h" #include "SDL_ttf.h" #include "config.h" #include "draw.h" #include "states.h" #include "menu.h" int main(int argc, char **argv) { // Initialize SDL and open up a screen SDL_Init(SDL_INIT_VIDEO); TTF_Init(); screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); menuFont = TTF_OpenFont("/usr/share/fonts/corefonts/verdana.ttf", 50); currentState = STATE_MAINMENU; // Initialize internal game state srand(time(NULL)); terrain = generateTerrain(150.0, 180.0); // Choose right state stateTable[currentState].drawFun(); stateTable[currentState].handleEventsFun(); // the main game loop while (currentState != STATE_EXIT) { // Check for events if (SDL_PollEvent(&event)) { // Make it possible to close the game window if (event.type == SDL_QUIT) currentState = STATE_EXIT; stateTable[currentState].handleEventsFun(); } // Draw the stuff on the screen and "flip" th the next frame SDL_FillRect(screen, NULL, 0x000000); stateTable[currentState].drawFun(); SDL_Flip(screen); } // Cleanup and quit free(terrain); SDL_Quit(); return 0; }