[Xbubble-commits] xbubble-sdl/src board.c, 1.8, 1.9 board.h, 1.5, 1.6 game.c, 1.7, 1.8

Martin Quinson mquinson at alioth.debian.org
Thu Sep 14 19:53:52 UTC 2006


Update of /cvsroot/xbubble/xbubble-sdl/src
In directory haydn:/tmp/cvs-serv24079

Modified Files:
	board.c board.h game.c 
Log Message:
cleanups; initiate a replay mechanisme; fix a bug in board lowering (scale was ignored)

Index: game.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/game.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- game.c	14 Sep 2006 09:05:27 -0000	1.7
+++ game.c	14 Sep 2006 19:53:50 -0000	1.8
@@ -32,9 +32,6 @@
 #include "sprite.h"
 #include "board.h"
 #include "opponent.h"
-//#include "controls.h" FIXME
-//#include "dialog.h"
-//#include "timer.h"
 #include "game.h"
 #include "cell.h"
 
@@ -98,31 +95,6 @@
   { PLAYER1_TAG, COMPUTER_TAG },
   { DEMO_TAG, DEMO_TAG }};
 
-/* When the timer is running, sleep up to ms time, or until a key gets pressed.
- * To be called when the timer is running.
- * Returns: whether it was interrupted. */
-static int interupted_sleep(long ms,game_t game) {
-#ifdef FIXME
-  long i;
-
-  block_timer();
-  if (game->state != game_state_finished && game->state != game_state_stopped) 
-     fail("interupted_sleep works only when the game is finished or stopped, it's %d\n",game->state);
-  game->key_pressed = 0;
-  for ( i = ms/50; i > 0; i-- ) {
-     if (game->key_pressed) {
-	unblock_timer();
-	return 1;
-     }
-     unblock_timer();
-     timer_sleep(50);
-     block_timer();
-  }
-  unblock_timer();
-#endif
-  return 0;
-}
-
 static void display_cups( game_t game, int n, int on ) {
   
 #ifdef FIXME
@@ -236,29 +208,6 @@
 				   get_pixel( menufont_color[0], menufont_color[1], 
 				    menufont_color[2] ), 0, 1.0 );
     */
-#ifdef FIXME
-    /* make board background (position dependant) */
-    game->board_bg[i] = XCreatePixmap( display, root, bw, bh, depth );
-    /* first draw window background */
-    XSetFillStyle( display, gc1, FillTiled );
-    XSetTile( display, gc1, win_bg );
-    XSetTSOrigin( display, gc1, -game->board_x[i], -game->board_y[i] );
-    XFillRectangle( display, game->board_bg[i], gc1, 0, 0, bw, bh );
-    /* then draw decoration */
-    XSetClipMask( display, gc2, board_decoration_mask );
-    XSetClipOrigin( display, gc2, 0, 0 );
-    XCopyArea( display, board_decoration, game->board_bg[i], gc2,
-	       0, 0, bw, bh, 0, 0 );
-
-    draw_sprite_pool( get_board_sprite_pool(game->board[i]), 
-		      game->board_pixmap[i],
-		      game->board_bg[i], bw, bh );
-
-    XSelectInput( display, game->board_window[i], ExposureMask );
-    XSetWindowBackgroundPixmap( display, game->board_window[i], None );
-    XMapWindow( display, game->board_window[i] );
-    XMapWindow( display, game->cup_box[i] );
-#endif
   }
 
   return game;
@@ -504,7 +453,7 @@
   }
 }
 
-static void frame_update(game_t game) {
+static void game_update(game_t game) {
   int i;
   int lost1;
   int lost2;
@@ -685,7 +634,7 @@
   do {
     game_get_cmds(game);
     /* Update the game */
-    frame_update(game);
+    game_update(game);
     SDL_Flip(screen);
 
     /* keep the fps constant */

Index: board.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/board.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- board.h	14 Sep 2006 09:53:02 -0000	1.5
+++ board.h	14 Sep 2006 19:53:50 -0000	1.6
@@ -115,8 +115,8 @@
 int board_empty( board_t board );
 
 enum e_board_cmd {
-   canon_left,
-   canon_stop,
+   canon_left=0,
+   canon_stop=1,
    canon_right,
    canon_fire
 };

Index: board.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/board.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- board.c	14 Sep 2006 09:53:02 -0000	1.8
+++ board.c	14 Sep 2006 19:53:50 -0000	1.9
@@ -231,14 +231,14 @@
      cell_array_is_overflow(board->array);
 }
 
-static void switch_alert_on( board_t board ) {
-  sprite_set_frame( board->alert, 1);
-  board->alert_on = 1;
-}
-
-static void switch_alert_off( board_t board ) {
-  sprite_set_frame( board->alert, 0);
-  board->alert_on = 0;
+static void board_alert_set( board_t board, int on ) {
+  if (on) {  
+     sprite_set_frame( board->alert, 1);
+     board->alert_on = 1;
+  } else {
+     sprite_set_frame( board->alert, 0);
+     board->alert_on = 0;
+  }      
 }
 
 void board_draw( board_t board ) {
@@ -732,7 +732,7 @@
    board->empty = cell_array_is_empty( board->array );
 }
 
-static void lower_board(board_t board) {
+static void board_lower(board_t board) {
   int i, color;
   bubble_t bubble;
 
@@ -740,7 +740,7 @@
   for ( i = 0; i < board->bubbles->size; i++ ) {
     bubble = board->bubbles->element[i];
     if ( bubble->state == STUCK ) 
-      bubble_set_pos( bubble, board, bubble->x, bubble->y+ROW_HEIGHT );
+      bubble_set_pos( bubble, board, bubble->x, bubble->y+ROW_HEIGHT*board->scale );
     /* update cell record, avoiding overflow */
     if (bubble->cell + COLS < NB_CELLS) {
        bubble->cell += COLS;
@@ -806,9 +806,9 @@
     blinking = ( board->launch_count >= board->period )?
       FAST_BLINKING : SLOW_BLINKING;
     if (( board->alert_on )&&(( board->clock/blinking ) % 2 ))
-      switch_alert_off(board);
+      board_alert_set(board, 0);
     if (( ! board->alert_on )&&(( board->clock/blinking ) % 2 == 0 ))
-      switch_alert_on(board);
+      board_alert_set(board, 1);
   }
 }
 
@@ -829,9 +829,9 @@
     }
     /* lower all bubbles if enough were launched */
     if ( board->launch_count > board->period ) {
-      lower_board(board);
+      board_lower(board);
       board->launch_count = 0;
-      switch_alert_off(board);
+      board_alert_set(board, 0);
       board->was_lowered = 1;
     }
     if ( board_overflow(board) ) {
@@ -859,8 +859,11 @@
   }
   board->launch_requested = 0;
 }
-
-void board_cmd(board_t board, enum e_board_cmd cmd) {
+static const char *cmd_names[4]= {"left","stop","right","fire"};
+   
+void board_cmd(board_t board, enum e_board_cmd cmd) {   
+   printf("%s %u\n", cmd_names[cmd], board->clock);
+	    
    switch(cmd) {
     case canon_left:
       if (board->canon_direction == canon_to_left)




More information about the Xbubble-commits mailing list