[Tux4kids-commits] [SCM] tuxhistory - Educational history game branch, master, updated. 47936cdf26e0110a6a80bb3e6bc7e77d0964f242

julio (none) julio at julio-desktop.
Wed Jun 16 06:59:05 UTC 2010


The following commit has been merged in the master branch:
commit 47936cdf26e0110a6a80bb3e6bc7e77d0964f242
Author: julio <julio at julio-desktop.(none)>
Date:   Wed Jun 16 01:58:08 2010 -0500

    Minor game.c changes and some experimentation

diff --git a/src/game.c b/src/game.c
index acfd671..fccd89a 100644
--- a/src/game.c
+++ b/src/game.c
@@ -66,6 +66,9 @@ static SDL_Surface* scaled_bkgd = NULL; //native resolution (fullscreen)
 
 /********** Static functions definitions *********/
 
+static int game_init(void);
+
+static void game_draw(void);
 static void game_handle_user_events(void);
 static int game_mouse_event(SDL_Event event);
 
@@ -80,6 +83,28 @@ static SDL_Surface* current_bkgd()
     return screen->flags & SDL_FULLSCREEN ? scaled_bkgd : bkgd; 
 }
 
+static int game_init(void)
+{
+    SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
+    SDL_Flip(screen);
+    quit = 0;
+
+    left_pressed = 0;
+    right_pressed = 0;
+    up_pressed = 0;
+    shift_pressed = 0;
+    shoot_pressed = 0;
+
+    game_status = 0;
+    paused = 0;
+    user_quit_received = 0;
+    SDL_quit_received = 0;
+    escape_received = 0;
+
+    return 1;
+}
+
+
 int game(void)
 {
     Uint32 last_time, now_time;
@@ -92,12 +117,20 @@ int game(void)
         ;//SwitchScreenMode();  //Huh??
     }
 
+    if(!game_init())
+    {
+        DEBUGMSG(debug_game, "Error loading game using game_init()\n");
+        return -1;
+    }
+
     while(game_status == GAME_IN_PROGRESS)
     {
         last_time = SDL_GetTicks();
         
         game_handle_user_events();
         game_status = check_exit_conditions();
+        game_draw();
+        SDL_Flip(screen);
 
         if(paused)
         {
@@ -118,6 +151,23 @@ int game(void)
     game_over(game_status);
 }
 
+static void game_draw(void)
+{
+    SDL_Surface* surf;
+    SDL_Rect dest;
+    
+    dest.x = 200;
+    dest.y = 200;
+
+    SDL_BlitSurface(terrain[TUNDRA_CENTER_1], NULL, screen, &dest);
+
+    dest.x = (screen->w - images[IMG_STOP]->w - 5);
+    dest.y = glyph_offset;
+    SDL_BlitSurface(images[IMG_STOP], NULL, screen, &dest);
+ 
+    
+}
+
 static int pause_game(void)
 {
   /* NOTE - done and quit changed to pause_done and pause_quit */
@@ -416,7 +466,7 @@ static int game_mouse_event(SDL_Event event)
     /* now can proceed as if keyboard was used */
     //game_key_event(key);
     return key;
-  }
+  
 }
 
 
diff --git a/src/tuxhistory.c b/src/tuxhistory.c
index ea7e97e..aeabe03 100644
--- a/src/tuxhistory.c
+++ b/src/tuxhistory.c
@@ -1,5 +1,5 @@
 /*
-  tuxmath.c
+  tuxhistory.c
 
   Main function for TuxHistory 
   Calls functions in other modules (eg, "setup", "title", "game", etc.)

-- 
tuxhistory - Educational history game



More information about the Tux4kids-commits mailing list