[Xbubble-commits] xbubble-sdl/src Makefile.am, 1.1.1.1, 1.2 Makefile.in, 1.1.1.1, 1.2 board.c, 1.1.1.1, 1.2 board.h, 1.1.1.1, 1.2 bubble.c, 1.1.1.1, 1.2 cell.c, 1.1.1.1, 1.2 cell.h, 1.1.1.1, 1.2 config.h.in, 1.1.1.1, 1.2 path_init.c, 1.1.1.1, 1.2 setting.h, 1.1.1.1, 1.2 utils.h, 1.1.1.1, 1.2 xbubble.c, 1.1.1.1, 1.2

Martin Quinson mquinson at alioth.debian.org
Mon Sep 11 19:54:11 UTC 2006


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

Modified Files:
	Makefile.am Makefile.in board.c board.h bubble.c cell.c cell.h 
	config.h.in path_init.c setting.h utils.h xbubble.c 
Log Message:
Current state. Still not working

Index: config.h.in
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/config.h.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- config.h.in	11 Aug 2006 12:14:44 -0000	1.1.1.1
+++ config.h.in	11 Sep 2006 19:54:09 -0000	1.2
@@ -1,5 +1,8 @@
 /* src/config.h.in.  Generated from configure.ac by autoheader.  */
 
+/* Path to the addr2line tool */
+#undef ADDR2LINE
+
 /* Where to put the graphics and such */
 #undef DATADIR
 
@@ -19,6 +22,9 @@
    */
 #undef HAVE_DCGETTEXT
 
+/* Define to 1 if you have the <execinfo.h> header file. */
+#undef HAVE_EXECINFO_H
+
 /* Define if the GNU gettext() function is already present or preinstalled. */
 #undef HAVE_GETTEXT
 
@@ -28,9 +34,15 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
+/* Define to 1 if you have the `popen' function. */
+#undef HAVE_POPEN
+
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
@@ -46,6 +58,9 @@
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 

Index: utils.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/utils.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- utils.h	11 Aug 2006 12:14:44 -0000	1.1.1.1
+++ utils.h	11 Sep 2006 19:54:09 -0000	1.2
@@ -31,6 +31,9 @@
 #define DEBUG(fmt,...) warn("%s:%d " fmt,__FILE__,__LINE__,__VA_ARGS__)
 void dbg( const char * fmt, ... );
 
+void display_backtrace(void);
+extern char *binary_name; /* main need to set this up for backtrace */
+
 Set set_new( int max_size );
 void set_free( Set s );
 void set_ref( Set s );

Index: Makefile.in
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/Makefile.in,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.in	11 Aug 2006 12:14:45 -0000	1.1.1.1
+++ Makefile.in	11 Sep 2006 19:54:09 -0000	1.2
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,8 +14,6 @@
 
 @SET_MAKE@
 
-SOURCES = $(pathinit_SOURCES) $(xbubble_SOURCES)
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -57,10 +55,11 @@
 am_pathinit_OBJECTS = path_init.$(OBJEXT)
 pathinit_OBJECTS = $(am_pathinit_OBJECTS)
 pathinit_DEPENDENCIES = utils.o cell.o
-am_xbubble_OBJECTS = utils.$(OBJEXT) graphic_utils.$(OBJEXT) \
-	levels.$(OBJEXT) theme.$(OBJEXT) cell.$(OBJEXT) \
-	frame.$(OBJEXT) sprite.$(OBJEXT) bubble.$(OBJEXT) \
-	board.$(OBJEXT) game.$(OBJEXT) xbubble.$(OBJEXT)
+am_xbubble_OBJECTS = utils.$(OBJEXT) backtrace.$(OBJEXT) \
+	graphic_utils.$(OBJEXT) levels.$(OBJEXT) theme.$(OBJEXT) \
+	cell.$(OBJEXT) frame.$(OBJEXT) sprite.$(OBJEXT) \
+	bubble.$(OBJEXT) board.$(OBJEXT) game.$(OBJEXT) \
+	xbubble.$(OBJEXT)
 xbubble_OBJECTS = $(am_xbubble_OBJECTS)
 xbubble_DEPENDENCIES = path_generated.o
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
@@ -76,6 +75,7 @@
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
+ADDR2LINE = @ADDR2LINE@
 AMDEP_FALSE = @AMDEP_FALSE@
 AMDEP_TRUE = @AMDEP_TRUE@
 AMTAR = @AMTAR@
@@ -189,6 +189,7 @@
 
 xbubble_SOURCES = \
 	utils.c		utils.h		\
+	backtrace.c			\
 	graphic_utils.c graphic_utils.h \
 	levels.c 	levels.h	\
 	theme.c		theme.h		\
@@ -294,6 +295,7 @@
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/backtrace.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/board.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/bubble.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cell.Po at am__quote@

Index: bubble.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/bubble.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- bubble.c	11 Aug 2006 12:14:40 -0000	1.1.1.1
+++ bubble.c	11 Sep 2006 19:54:09 -0000	1.2
@@ -65,14 +65,12 @@
        (int)scale_x(bubble->x, board->scale),
        (int)scale_y(bubble->y, board->scale) );
   */   
-  sprite_set_pos( bubble->sprite, 
-		  (int)scale_x(bubble->x, board->scale),
-		  (int)scale_y(bubble->y, board->scale) );
+  sprite_set_pos( bubble->sprite, board2screen(bubble->x, bubble->y, board));
 }
 
 void bubble_set_pos( bubble_t bubble, board_t board, double x, double y ) {
-  bubble->x = x+board->offset.x;
-  bubble->y = y+board->offset.y;
+  bubble->x = x;
+  bubble->y = y;
   /*
   DEBUG("bubble %p of board %p (sprite=%p) go to %f %f corrected to %f %f (off=%d %d)",
 	bubble,board,bubble->sprite,

Index: xbubble.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/xbubble.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- xbubble.c	11 Aug 2006 12:14:44 -0000	1.1.1.1
+++ xbubble.c	11 Sep 2006 19:54:09 -0000	1.2
@@ -1,4 +1,5 @@
 
+#include <string.h>
 #include <stdlib.h>
 #include "graphic_utils.h"
 #include "theme.h"
@@ -12,9 +13,14 @@
   int zoom = DEFAULT_SCALE;
   int MAX_X = game_win_width(zoom);
   int MAX_Y = game_win_height(zoom);
+   
+  /* setup backtraces */
+  binary_name = strdup(argv[0]);
+   
   screen = window_make(MAX_X,MAX_Y);
+  DEBUG("MAX_X=%d MAX_Y=%d",MAX_X,MAX_Y);
   theme_t *theme = theme_init("small",zoom);
-  levels_t levels = levels_load("levels.txt");
+  levels_t levels = levels_load("levels_empty.txt");
   ruleset_t ruleset = DEFAULT_RULE_SET;
   game_t game = game_new(game_mode_single, &ruleset, theme, zoom, 
 			 levels_get_colors(levels, 1),
@@ -25,114 +31,3 @@
 
   return 0;
 }
-
-
-#ifdef KILLME
-#define ROW_HEIGHT     0.8660254037844386 /* sqrt(3)/2 */
-
-int MAX_X,MAX_Y;
-
-sprite_t *bubbles;
-
-static void fake_move (sprite_t bubble) {
-  int x,y,dx,dy,w,h;
-  sprite_get_pos(bubble, &x,&y);
-  sprite_get_dim(bubble,&w,&h);
-  sprite_get_mov(bubble,&dx,&dy);
-
-  x += dx;
-  y += dy;
-  if (x > MAX_X - w/* - SIDE_WIDTH*/) {
-    x = MAX_X - w/* - SIDE_WIDTH*/;
-    dx = rnd(20)-10;
-    dy = rnd(20)-10;
-  }
-  if (/*SIDE_WIDTH*/0>x) {
-    x = 0/*SIDE_WIDTH*/;
-    dx = rnd(20)-10;
-    dy = rnd(20)-10;
-  }
-  if (y>MAX_Y - h) {
-    y = MAX_Y - h;
-    dx = rnd(20)-10;
-    dy = rnd(20)-10;
-  }
-  if (0>y) {
-    y = 0;
-    dx = rnd(20)-10;
-    dy = rnd(20)-10;
-  }
-  sprite_set_pos(bubble,x,y);
-  sprite_set_mov(bubble,dx,dy);
-}
-
-#define NB_BUBBLES 20
-static int other_main(int argc, char*argv[]) {
-  int i;
-  int done=0;
-  SDL_Event event;
-  theme_t *theme;
-  SDL_Surface *screen;
-  Uint32 clock;
-  short fps=0, sec=0;
-  int zoom = DEFAULT_SCALE;
-  SDL_Rect bg_offset;
-
-  sprite_pool_t sp;
-  bg_offset.x = bg_offset.y = 0;
-  bubbles = xmalloc(sizeof(sprite_t*)*NB_BUBBLES);
-
-  MAX_X = board_win_width(zoom);
-  MAX_Y = board_win_height(zoom);
-
-  screen = window_make(MAX_X,MAX_Y);
-  theme = theme_init("small",zoom);
-  sp = sprite_pool_new( NB_BUBBLES, NB_BUBBLES, theme);
-
-  for (i=0; i<NB_BUBBLES; i++) {
-    bubbles[i]=sprite_new_bubble(1,0, theme, i%NB_COLORS, 1);
-    sprite_pool_add(sp, bubbles[i]);
-    sprite_set_pos(bubbles[i], rnd(MAX_X-30), rnd(MAX_Y-30));
-    sprite_set_mov(bubbles[i],rnd(40)-20,rnd(40)-20);
-  }
-
-  clock = SDL_GetTicks();
-
-  while (!done) {
-    fps++;
-    while(SDL_PollEvent(&event)){
-      if (event.type == SDL_KEYDOWN) {
-	if (event.key.keysym.sym == SDLK_q) {
-	  SDL_Quit();
-	  exit(0);
-	}
-	if (event.key.keysym.sym == SDLK_f)
-	  SDL_WM_ToggleFullScreen(screen);
-      } else if (event.type == SDL_QUIT) {
-	SDL_Quit();
-	exit(0);
-      }
-    }
-
-    Uint32 now=SDL_GetTicks();
-    for (i=0; i<NB_BUBBLES; i++) {
-      fake_move(bubbles[i]);
-      sprite_inc_clock(bubbles[i],now-clock);
-    }
-    if (now / 1000 == sec+1) {
-      printf("%d fps\n",fps);
-      fps=0;
-      sec++;
-    }
-    if (frame_duration > now-clock) 
-      SDL_Delay(frame_duration - now + clock);
-    clock=now;
-    
-    /* display it */
-    sprite_pool_redraw(sp, screen, 1, &bg_offset);
-    SDL_Flip(screen);
-  }
-  return 0;
-}
-#endif
-

Index: cell.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/cell.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cell.c	11 Aug 2006 12:14:41 -0000	1.1.1.1
+++ cell.c	11 Sep 2006 19:54:09 -0000	1.2
@@ -87,9 +87,10 @@
  */
 
 /* prototypes */
-static void cell_array_neighbor_recompute(CellArray ca);
+static void cell_array_recompute(CellArray ca);
 
-CellArray cell_array_new( int moving_ceiling ) {
+CellArray cell_array_new( int moving_ceiling, 
+			  double scale, double offx, double offy ) {
   int i;
   CellArray ca;
   ca = (CellArray) xmalloc( sizeof( struct _CellArray ));
@@ -99,9 +100,15 @@
   ca->moving_ceiling = moving_ceiling;
   for ( i = 0; i < NB_CELLS; i++ )
     ca->cell[i] = EMPTY_CELL;
+
   ca->list1 = vector_new( NB_CELLS );
   ca->list2 = vector_new( NB_CELLS );
-  cell_array_neighbor_recompute(ca);
+  
+  ca->scale = scale;
+  ca->offx = offx;
+  ca->offy = offy;
+
+  cell_array_recompute(ca);
   return ca;
 }
    
@@ -139,7 +146,7 @@
     if ( ca->moving_ceiling )
       ca->first_row++;
   }
-  cell_array_neighbor_recompute(ca);
+  cell_array_recompute(ca);
 }
 
 int cell_array_is_overflow( CellArray ca ) {
@@ -159,7 +166,7 @@
   return COLS*row + column;
 }
 
-static void cell_array_neighbor_recompute(CellArray ca) {
+static void cell_array_recompute(CellArray ca) {
   int cell;
   for ( cell = 0; cell < NB_CELLS; cell++ ) {
      int column, row, shift;
@@ -175,30 +182,14 @@
      
      ca->neighbor[cell][NORTH_WEST] = cellCL( ca, row-1, column+shift-1 );
      ca->neighbor[cell][SOUTH_WEST] = cellCL( ca, row+1, column+shift-1 );
+
+     ca->sx[cell] = (column + 0.5*(1 - row_start(ca, row))) * ca->scale + ca->offx;
+     ca->sy[cell] = (row*ROW_HEIGHT + 0.5) * ca->scale + ca->offy;
   }
 }
 
 #define neighbor_cell(ca,cell,quadrant) (ca->neighbor[cell][quadrant])
    
-#if 0
-int neighbor_cell( CellArray ca, int cell, Quadrant quadrant ) {
-  int column, row, shift;
-  row = cell / COLS;
-  column = cell % COLS;
-  shift = 1 - row_start( ca, row);
-
-  switch ( quadrant ) {
-  case EAST: column++; break;
-  case WEST: column--; break;
-  case NORTH_EAST: column += shift; row--; break;
-  case SOUTH_EAST: column += shift; row++; break;
-  case NORTH_WEST: column += shift-1; row--; break;
-  case SOUTH_WEST: column += shift-1; row++; break;
-  }
-  return cellCL( ca, row, column );
-}
-#endif
-
 void cell_center( CellArray ca, int cell, double *x, double *y) {
   int column, row;
   row = cell / COLS;
@@ -207,6 +198,11 @@
   *y = (row*ROW_HEIGHT + 0.5) * DEFAULT_SCALE;
 }
 
+void cell_screen_coord( CellArray ca, int cell, double *x, double *y) {
+  *x = ca->sx[cell];
+  *y = ca->sy[cell];
+}
+
 int floating_cell( CellArray ca, int cell ) {
   Quadrant q;
   for ( q = 0; q <= 5; q++ )

Index: board.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/board.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- board.h	11 Aug 2006 12:14:40 -0000	1.1.1.1
+++ board.h	11 Sep 2006 19:54:09 -0000	1.2
@@ -8,12 +8,12 @@
 typedef struct {
   int malus_top;      /* true if malus balls should take the highest free pos, 
 			 false if they should stick on the lowest possible pos */
-  int max_fire_delay; /* in second */
+  int max_fire_delay; /* in milisecond */
   int chainreaction;  /* boolean */
   int single;         /* single player? (ie, new bubble color must be already there */
 } ruleset_t;
 
-#define DEFAULT_RULE_SET { 1, 5, 1, 1 }
+#define DEFAULT_RULE_SET { 1, 5000, 1, 1 }
 
 enum e_board_state {
   board_state_waiting_for_canon,
@@ -79,6 +79,12 @@
   Vector placed_balls; /* temp for place_received_bubble() placed here to 
 			  avoid mallocation at each call 
 			  without going into trouble due to parallelism */
+
+  /* sprite locations */
+  double new_x,new_y;     /* Ball newly created */
+  double alert_x,alert_y; /* alert sign */
+  double canon_x,canon_y; /* canon */
+  double countdown_x,countdown_y;
 };
 
 

Index: setting.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/setting.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- setting.h	11 Aug 2006 12:14:42 -0000	1.1.1.1
+++ setting.h	11 Sep 2006 19:54:09 -0000	1.2
@@ -21,25 +21,23 @@
 #define BOARD_HEIGHT         ( ROWS*ROW_HEIGHT + DEAD_ZONE_HEIGHT )
 #define OFFSET_X             ( 1.0*SIDE_WIDTH/MAX_SCALE )
 #define OFFSET_Y             ( 1.0*FRAME_HEIGHT/MAX_SCALE )
-#define scale_x(X,S)         (( X + OFFSET_X )*(S) )
-#define scale_y(Y,S)         (( Y + OFFSET_Y )*(S) )
-#define board_win_width(S)   scale_x( OFFSET_X + BOARD_WIDTH, S ) 
-#define board_win_height(S)  scale_y( BOARD_HEIGHT, S )
+
+//#define board2screen_x(X,board) (X+OFFSET_X)*(board->scale)+board->offset.x
+//#define board2screen_y(Y,board) (Y+OFFSET_Y)*(board->scale)+board->offset.y
+#define board2screen_x(X,board) (X)*(board->scale)+board->offset.x
+#define board2screen_y(Y,board) (Y)*(board->scale)+board->offset.y
+#define board2screen(X,Y,board) board2screen_x(X,board), board2screen_y(Y,board)
+
+#define board_win_width(S)   (2 * OFFSET_X + BOARD_WIDTH) * S
+#define board_win_height(S)  (OFFSET_Y + BOARD_HEIGHT) * S
 #define board_spacing(S)     (S)
 #define game_win_width(S)    ((int)(2*board_win_width(S) + 3*board_spacing(S)))
 #define game_win_height(S)   ((int)( board_win_height(S) + 3*board_spacing(S)))
 
 /* sprite locations */
-#define ALERT_X              ( BOARD_WIDTH*0.5 )
-#define ALERT_Y              ( -OFFSET_Y*0.5 )
-#define NEW_X                1.0
-#define NEW_Y                ( BOARD_HEIGHT - 0.75 )
-#define COUNTDOWN_X          1.3
-#define COUNTDOWN_Y          ( NEW_Y - 1.3 )
+#define NEW_CELL             34 /* Cell in which balls are created */
 
 /* canon */
-#define CANON_X              ( BOARD_WIDTH*0.5 )
-#define CANON_Y              ( ROWS*ROW_HEIGHT + 0.5 )
 #define CANON_CX             220
 #define CANON_CY             220
 #define CANON_ANGLE_MAX      100

Index: cell.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/cell.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- cell.h	11 Aug 2006 12:14:41 -0000	1.1.1.1
+++ cell.h	11 Sep 2006 19:54:09 -0000	1.2
@@ -21,12 +21,23 @@
 
 
 struct _CellArray {
-  bubble_t cell[NB_CELLS];
-  int tagged[NB_CELLS];
-  int neighbor[NB_CELLS][SOUTH_EAST+1];
+  /* Invariant description of this cellarray */
+  int moving_ceiling;
   int first_row;
   int parity;
-  int moving_ceiling;
+
+  double scale, offx, offy; /* to precompute the screen coordinates */
+
+  /* To be recomputed each time that we lower the thing */
+  int neighbor[NB_CELLS][SOUTH_EAST+1];
+  double sx[NB_CELLS]; /* X coordinate on screen of each cell */
+  double sy[NB_CELLS]; /* Y coordinate on screen of each cell */
+
+  /* Current state of the cellarray */
+  bubble_t cell[NB_CELLS];
+
+  /* "globals" for recursive treatments */
+  int tagged[NB_CELLS];
   Vector list1;
   Vector list2;
 };
@@ -38,19 +49,20 @@
 #define cell_y(C)         (( (C)/COLS )*ROW_HEIGHT + 0.5 )
 #define cell_not_empty(A,C) (( C != OUT_OF_BOUNDS )&&( A->cell[C] != EMPTY_CELL))
 
-CellArray cell_array_new( int moving_ceiling );
+CellArray cell_array_new( int moving_ceiling, 
+			  double scale, double offx, double offy );
 void cell_array_free( CellArray ca );
 void cell_array_empty( CellArray ca );
 int  cell_array_is_empty( CellArray ca );
 void cell_array_lower( CellArray ca );
 int  cell_array_is_overflow( CellArray ca );
 
-//int neighbor_cell( CellArray ca, int cell, Quadrant quadrant );
 #define neighbor_cell(ca,cell,quadrant) (ca->neighbor[cell][quadrant])
 
 int cellCL( CellArray ca, int row, int col );
 int floating_cell( CellArray ca, int c );
 void cell_center( CellArray ca, int cell, double *x, double *y);
+void cell_screen_coord( CellArray ca, int cell, double *x, double *y);
 int find_target_cell( CellArray ca, 
 		      int angle, 
 		      double * target_y,

Index: path_init.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/path_init.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- path_init.c	11 Aug 2006 12:14:47 -0000	1.1.1.1
+++ path_init.c	11 Sep 2006 19:54:09 -0000	1.2
@@ -125,7 +125,7 @@
 
   neighbor = vector_new(25);
   position = vector_new(25);
-  ca=cell_array_new(1);
+  ca=cell_array_new(1, 1, 0, 0);
     
   /* for each parity */
   for (parity=0;parity<2;parity++){
@@ -165,8 +165,9 @@
 
 	half_range = sqrt( 1 + vx*vx/vy/vy );
 	bouncing=1;
-	xb=CANON_X;
-	yb=CANON_Y;
+	/* Keep the following in sync with the def in board.c */
+	xb=BOARD_WIDTH*0.5 ;//CANON_X;
+	yb=ROWS*ROW_HEIGHT + 0.5;//CANON_Y;
 	v2 = vx*vx + vy*vy;
 	
 	while (bouncing) {

Index: Makefile.am
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/Makefile.am,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Makefile.am	11 Aug 2006 12:14:44 -0000	1.1.1.1
+++ Makefile.am	11 Sep 2006 19:54:09 -0000	1.2
@@ -25,6 +25,7 @@
 
 xbubble_SOURCES = 			\
 	utils.c		utils.h		\
+	backtrace.c			\
 	graphic_utils.c graphic_utils.h \
 	levels.c 	levels.h	\
 	theme.c		theme.h		\

Index: board.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/board.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- board.c	11 Aug 2006 12:14:40 -0000	1.1.1.1
+++ board.c	11 Sep 2006 19:54:09 -0000	1.2
@@ -40,17 +40,15 @@
 };
 
 
-void stick_bubble( board_t board, bubble_t bubble, int target);
+void board_stick_bubble( board_t board, bubble_t bubble, int target);
 void drop_bubbles(board_t board);
 void place_received_bubbles( board_t board );
 
 
 
 static bubble_t board_new_bubble( board_t board, int color ) {
-  DEBUG("new bubble at %f %f (BOARD_HEIGHT=%f;",
-	NEW_X,NEW_Y,BOARD_HEIGHT);
   bubble_t bubble = bubble_new(color, 
-			       NEW_X,NEW_Y, 
+			       board->new_x,board->new_y,
 			       MEDIUM_LAYER, 
 			       board);
   bubble_set_state( bubble, NEW, MEDIUM_LAYER, 0);
@@ -102,7 +100,8 @@
   bubble_t bubble;
 
   board_t board = (board_t) xmalloc( sizeof( struct _board ));
-  board->array = cell_array_new( mov_ceiling );
+  board->array = cell_array_new( mov_ceiling, board->scale,
+				 board->offset.x, board->offset.y );
   board->bubbles = set_new( 2*NB_CELLS );
   board->tmpset = set_new( 2*NB_CELLS );
   board->sprite_pool = sprite_pool_new( TOP_LAYER+1, 2*NB_CELLS, theme );
@@ -124,11 +123,31 @@
   board->nb_rising_bubbles = 0;
   board->placed_balls = vector_new( 10 );
 
+  /* sprite locations */
+  //#define ALERT_X              ( BOARD_WIDTH*0.5 )
+  //#define ALERT_Y              ( -OFFSET_Y*0.5 )
+  //#define NEW_X                1.0
+  //#define NEW_Y                ( BOARD_HEIGHT - 0.75 )
+  //#define CANON_X              ( BOARD_WIDTH*0.5 )
+  //#define CANON_Y              ( ROWS*ROW_HEIGHT + 0.5 )
+  //#define COUNTDOWN_X          1.3
+  //#define COUNTDOWN_Y          ( NEW_Y - 1.3 )
+  board->new_x = board2screen_x( 1.0                   ,board);
+  board->new_y = board2screen_y( BOARD_HEIGHT - 0.75   ,board);
+
+  board->alert_x=board2screen_x( BOARD_WIDTH*0.5       ,board);
+  board->alert_y=board2screen_y( -OFFSET_Y*0.5         ,board);
+
+  /* Keep the following in sync with the def in path_init.c */
+  board->canon_x=board2screen_x( BOARD_WIDTH*0.5       ,board);
+  board->canon_y=board2screen_y( ROWS*ROW_HEIGHT + 0.5 ,board);
+
+  board->countdown_x=board2screen_x( 1.3, board);
+  board->countdown_y=board->new_y - 1.3*board->scale;
+
   /* alert blinking light */
   board->alert = sprite_new( BOTTOM_LAYER, 30, theme->alert_a, 0, 0);
-  sprite_set_pos( board->alert, 
-		  scale_x( ALERT_X, board->scale )+board->offset.x,
-		  scale_y( ALERT_Y, board->scale )+board->offset.y);
+  sprite_set_pos( board->alert, board->alert_x, board->alert_y );
   sprite_pool_add( board->sprite_pool, board->alert );
   board->alert_on = 0;
   board->clock = 0;
@@ -137,8 +156,7 @@
   board->countdown_sprite = sprite_new( BOTTOM_LAYER, 30, theme->countdown_a,
 					0, 0);
   sprite_set_pos( board->countdown_sprite, 
-		  scale_x( COUNTDOWN_X, board->scale ),
-		  scale_y( COUNTDOWN_Y, board->scale ));
+		  board->countdown_x, board->countdown_y);
   board->countdown_state = INACTIVE;
 
   /* canon */
@@ -165,16 +183,23 @@
     if (( colors[cell] > 0 )&&
 	( cell % COLS >= row_start( board->array, cell/COLS ))) {
       bubble = board_new_bubble( board, colors[cell]-1 );
-      stick_bubble( board, bubble, cell);
+      board_stick_bubble( board, bubble, cell);
     }    
   cellarray_dump(board->array);
 
   /* start with a new bubble */
   board->color = bubble_next_color( board );
   board_new_bubble( board, board->color );
+
+  display_backtrace();
+
   board->canon_empty = 1;
   
   board->state = board_state_waiting_for_canon;
+
+  DEBUG("board->new=%f;%f canon=%f;%f",
+	board->new_x,board->new_y,
+	board->canon_x,board->canon_y);
   return board;
 }
 
@@ -226,6 +251,7 @@
 /************************** countdown functions ***************************/
 
 static void start_countdown( board_t board ) {
+  warn("Set count to %d",board->ruleset->max_fire_delay);
   board->count = board->ruleset->max_fire_delay;
   board->countdown_state = ACTIVE;
 }
@@ -247,10 +273,11 @@
   board->count -= dt;
   switch ( board->countdown_state ) {
   case ACTIVE:
-    if ( board->count <= 0 )
+    if ( board->count <= 0 ) {
       /* launch bubble automatically after timeout */
+      warn("launch bubble automatically after timeout");
       board->launch_requested = 1;
-    else
+    } else
       if ( board->count <= COUNTDOWN ) {
 	sprite_pool_add( board->sprite_pool, board->countdown_sprite );
 	sprite_set_frame( board->countdown_sprite, 1+board->count/1000 ); 
@@ -314,7 +341,7 @@
   board->state = board_state_won;
 }
 
-void stick_bubble( board_t board, bubble_t bubble, int target) {
+void board_stick_bubble( board_t board, bubble_t bubble, int target) {
   double x, y;
   cell_center( board->array, target, &x, &y );
   bubble_set_state( bubble, STUCK, BOTTOM_LAYER, 0);
@@ -361,24 +388,32 @@
     switch ( bubble->state ) {
 
     case NEW:
+      DEBUG("New bubble: %p (%s) clock=%d/%d pos=%.2f %.2f speed=%.2f %.2f",bubble,
+	    ((board->canon_empty)?"canon empty":"canon full"),
+	    bubble->clock,CANON_LOAD_TIME,
+	    bubble->x,bubble->y,bubble->vx,bubble->vy);
       sprite_inc_clock( bubble->sprite, dt );
       if ( board->canon_empty ) {
 	/* compute new position of bubble */
-	t = M_PI * bubble->clock/2/CANON_LOAD_TIME;
-	/* elliptic trajectory */
-	x = CANON_X - ( CANON_X - NEW_X )*cos(t);
-	y = NEW_Y + ( CANON_Y - NEW_Y )*sin(t);
+	t = bubble->clock/CANON_LOAD_TIME;
+	/* FIXME: elliptic trajectory to fixup
+       	x = board->canon_x - ( board->canon_x - board->new_x ) * cos(t*M_PI/2);
+	y = board->new_y + ( board->canon_y - board->new_y )*sin(t*M_PI/2);
+	For now, linear trajectory
+	*/
+	x = board->canon_x + ( board->canon_x - board->new_x ) * t;
+	y = board->canon_y + ( board->canon_y - board->new_y ) * t;
 	bubble_set_pos( bubble, board, x, y );
 	bubble->clock += dt;
 	
 	/* if bubble has reached canon then we're ready to fire */
 	if ( bubble->clock > CANON_LOAD_TIME ) {
 	  bubble_set_state( bubble, READY, MEDIUM_LAYER, 0 );
-	  bubble_set_pos( bubble, board, CANON_X, CANON_Y );
+	  bubble_set_pos( bubble, board, board->canon_x, board->canon_y );
 	  board->canon_empty = 0;
 	  /* add a new bubble */
 	  board->next_color = bubble_next_color( board );
-	  board_new_bubble( board, board->next_color );
+	  //	  board_new_bubble( board, board->next_color );
 	  start_countdown(board);
 	}
       }
@@ -396,6 +431,7 @@
       if (( board->launch_requested )&&
 	  ( board->state == board_state_ready_to_fire )&&( transition_allowed )) {
 	/* launch bubble */
+	DEBUG("Launch the bubble %p",bubble);
 	bubble_set_state( bubble, LAUNCHED, MEDIUM_LAYER, 0);
 	bubble->vx = board->vx[ board->canon_angle + CANON_ANGLE_MAX ];
 	bubble->vy = board->vy[ board->canon_angle + CANON_ANGLE_MAX ];
@@ -403,6 +439,7 @@
 	bubble->cell = find_target_cell( board->array, 
 					 board->canon_angle+CANON_ANGLE_MAX, 
 					 &bubble->target_y,NULL );
+	bubble->target_y = board2screen_y(bubble->target_y,board);
 	transition_allowed = 0;
 	board->state = board_state_rebound;
 	board->launch_count++;
@@ -418,6 +455,10 @@
       /* move bubble */
       bubble->x += dt*bubble->vx;
       bubble->y += dt*bubble->vy;
+      if (bubble->vx || bubble->vy) 
+	DEBUG("bubble->x=%f ; bubble->y=%f <> %f (target=%d->y=%f)", 
+	      bubble->x, bubble->y, 0.5*board->scale + board->offset.y,
+	      bubble->cell,bubble->target_y);
       /* bounce bubble against walls */
       if ( bubble_x(bubble,board) < 0.5 ) {
 //	bubble_set_x(bubble,board,
@@ -434,7 +475,7 @@
       /* check if bubble has reached its target cell */
       /* both ->y and ->target_y are offseted, no need for extra trick */
       if ( bubble->y <= bubble->target_y ) {
-	stick_bubble( board, bubble, bubble->cell);
+	board_stick_bubble( board, bubble, bubble->cell);
 	
 	/* check if bubble triggers an explosion */
 	if ( (count=count_explosive_bubbles( board->array,
@@ -548,7 +589,7 @@
       sprite_inc_clock( bubble->sprite, dt );
       /* check if bubble has reached its target cell */
       if ( bubble_y(bubble,board) <= cell_y( bubble->cell )) {
-	stick_bubble( board, bubble, bubble->cell);
+	board_stick_bubble( board, bubble, bubble->cell);
 	bubble_set_state( bubble, STUCK, TOP_LAYER, 0 );
 	board->nb_rising_bubbles--;
 	 
@@ -646,7 +687,7 @@
      bubble_free( bubble );
   }
   while (board->malus_indicators10->size < board->input->size / 10) {
-     bubble = bubble_new( 1, NEW_X, NEW_Y, TOP_LAYER, board);
+     bubble = bubble_new( 1, board->new_x, board->new_y, TOP_LAYER, board);
      bubble_set_state( bubble, NEW, TOP_LAYER, 0);
      sprite_pool_add( board->sprite_pool, bubble->sprite );
      set_add( board->malus_indicators10, bubble );
@@ -659,7 +700,7 @@
      bubble_free( bubble );
   }
   while (board->malus_indicators->size < board->input->size % 10) {
-     bubble = bubble_new( 2, NEW_X, NEW_Y, TOP_LAYER, board );
+     bubble = bubble_new( 2, board->new_x, board->new_y, TOP_LAYER, board );
      bubble_set_state( bubble, NEW, TOP_LAYER, 0);
      sprite_pool_add( board->sprite_pool, bubble->sprite );
      set_add( board->malus_indicators, bubble);
@@ -726,13 +767,13 @@
     for ( i = row_start( board->array, 0); i < COLS; i++ ) {
       color = bubble_next_color( board );
       bubble = board_new_bubble( board, color);
-      stick_bubble( board, bubble, i );
+      board_stick_bubble( board, bubble, i );
     }
   }
-  else /* lower alert light */
-    sprite_set_pos( board->alert, scale_x( ALERT_X, board->scale ),
-		     scale_y( ALERT_Y+board->array->first_row*ROW_HEIGHT,
-			     board->scale ));
+  else { /* lower alert light */
+    board->alert_y += board->array->first_row*ROW_HEIGHT; /* FIXME: must be wrong */
+    sprite_set_pos( board->alert, board->alert_x, board->alert_y);
+  }
 }
 
 static void kill_board( board_t board ) {
@@ -766,8 +807,8 @@
   frame = (board->canon_angle+
 	   CANON_ANGLE_MAX)*board->theme->canon_a->size/NB_ANGLES;
   /* compute canon center coordinates */
-  x = scale_x( CANON_X, board->scale )*DEFAULT_SCALE + board->offset.x;
-  y = scale_y( CANON_Y, board->scale )*DEFAULT_SCALE + board->offset.y;
+  x = board->canon_x;
+  y = board->canon_y;
   sprite_set_frame( board->canon_sprite, frame);
   sprite_set_pos( board->canon_sprite, x, y);
 }
@@ -855,6 +896,7 @@
 }
 
 void canon_fire(board_t board) {
+  warn("Fire");
   board->launch_requested = 1;
   canon_stop(board);
 }




More information about the Xbubble-commits mailing list