[Xbubble-commits] xbubble-sdl/src board.c, 1.3, 1.4 frame.c, 1.2,
1.3 frame.h, 1.1.1.1, 1.2 sprite.c, 1.1.1.1, 1.2 theme.c, 1.2,
1.3 utils.h, 1.2, 1.3 xbubble.c, 1.3, 1.4
Martin Quinson
mquinson at alioth.debian.org
Tue Sep 12 08:04:10 UTC 2006
- Previous message: [Xbubble-commits] xbubble-sdl/src board.c, 1.2, 1.3 board.h, 1.2,
1.3 bubble.c, 1.2, 1.3 bubble.h, 1.1.1.1, 1.2 cell.c, 1.2,
1.3 cell.h, 1.2, 1.3 frame.c, 1.1.1.1, 1.2 path_init.c, 1.2,
1.3 setting.h, 1.2, 1.3 theme.c, 1.1.1.1, 1.2 xbubble.c, 1.2, 1.3
- Next message: [Xbubble-commits] xbubble-sdl/src .cvsignore,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/xbubble/xbubble-sdl/src
In directory haydn:/tmp/cvs-serv12987
Modified Files:
board.c frame.c frame.h sprite.c theme.c utils.h xbubble.c
Log Message:
Back onto a stable state
Index: theme.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/theme.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- theme.c 11 Sep 2006 21:33:19 -0000 1.2
+++ theme.c 12 Sep 2006 08:04:08 -0000 1.3
@@ -98,10 +98,10 @@
theme->canon_a = set_new( NB_ANGLES );
frame = frame_load("canon.png",theme->name,zoom);
for ( i = -CANON_ANGLE_MAX; i <= CANON_ANGLE_MAX; i++ ) {
- set_add( theme->canon_a,
- frame_new(rotozoomSurface(frame->surf, -i*ANGLE_STEP, 1, 0),
- "canon", 0)
- );
+ frame_t toadd = frame_new_raw(rotozoomSurface(frame->surf, -i*ANGLE_STEP, 1, 1));
+ if (!toadd)
+ fail("Canon animation creation failed for frame %d (of %d)",i,CANON_ANGLE_MAX);
+ set_add( theme->canon_a, toadd);
}
frame_free(frame);
#ifdef FIXME
@@ -382,13 +382,3 @@
return res;
}
-
-#if 0
-Set theme_get_bubble_a(theme_t *theme,int color, int state) {
- return
-}
-
-SDL_Surface *theme_get_bg(theme_t *theme) {
- return theme->background;
-}
-#endif
Index: frame.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/frame.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- frame.h 11 Aug 2006 12:14:41 -0000 1.1.1.1
+++ frame.h 12 Sep 2006 08:04:08 -0000 1.2
@@ -20,7 +20,9 @@
*/
} * frame_t;
-
+/* New frame from unchanged surf */
+frame_t frame_new_raw ( SDL_Surface *surf );
+/* New alpha-optimized frame */
frame_t frame_new ( SDL_Surface *surf, const char *name, int free_src);
frame_t frame_load ( const char *file, const char *theme, double zoom );
void frame_free( frame_t frame );
Index: utils.h
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/utils.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- utils.h 11 Sep 2006 19:54:09 -0000 1.2
+++ utils.h 12 Sep 2006 08:04:08 -0000 1.3
@@ -34,6 +34,8 @@
void display_backtrace(void);
extern char *binary_name; /* main need to set this up for backtrace */
+#define xassert(cond,msg) if (!(cond)) {display_backtrace();fail(msg);}
+
Set set_new( int max_size );
void set_free( Set s );
void set_ref( Set s );
Index: frame.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/frame.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- frame.c 11 Sep 2006 21:33:19 -0000 1.2
+++ frame.c 12 Sep 2006 08:04:08 -0000 1.3
@@ -6,28 +6,35 @@
#include "graphic_utils.h"
#include "setting.h"
-frame_t frame_new ( SDL_Surface *surf, const char *name, int free_src) {
+frame_t frame_new_raw ( SDL_Surface *surf) {
frame_t frame = (frame_t) xmalloc( sizeof( struct _frame ));
- /* Optimize it */
- frame->surf=SDL_DisplayFormatAlpha(surf);
- if (!frame->surf) {
- warn(_("Unable to optimize the sprite %s: %s\n"),
- name, sdl_error);
- frame->surf = surf;
- /* FIXME: copy if not asked to free the source */
- } else {
- SDL_FreeSurface(surf);
- }
+ xassert(surf, "cannot make frame from null surf");
+ frame->surf=surf;
+ xassert(frame->surf, "FUCKcannot make frame from null surf");
/* default settings */
frame->delay = 40; /* default frame duration = 40 ms */
- frame->dim.x = frame->surf->w;
- frame->dim.y = frame->surf->h;
+ frame->dim.x = surf->w;
+ frame->dim.y = surf->h;
return frame;
}
+frame_t frame_new ( SDL_Surface *surf, const char *name, int free_src) {
+ SDL_Surface *optim = SDL_DisplayFormatAlpha(surf);
+
+ if (!optim) {
+ warn(_("Unable to optimize the sprite %s: %s\n"), name, sdl_error);
+ optim = surf;
+ /* FIXME: copy if not asked to free the source */
+ } else {
+ SDL_FreeSurface(surf);
+ }
+
+ return frame_new_raw(optim);
+}
+
frame_t frame_load ( const char *file, const char *theme, double zoom ) {
SDL_Surface *raw = IMG_Load(file_resolve_path(file,theme));
SDL_Surface *zoomed;
Index: xbubble.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/xbubble.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- xbubble.c 11 Sep 2006 21:33:19 -0000 1.3
+++ xbubble.c 12 Sep 2006 08:04:08 -0000 1.4
@@ -10,7 +10,7 @@
unsigned long frame_duration=20;
SDL_Surface *screen;
int main(int argc, char *argv[]) {
- int zoom = MAX_SCALE;
+ int zoom = DEFAULT_SCALE;
int MAX_X = game_win_width(zoom);
int MAX_Y = game_win_height(zoom);
Index: board.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/board.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- board.c 11 Sep 2006 21:33:19 -0000 1.3
+++ board.c 12 Sep 2006 08:04:08 -0000 1.4
@@ -170,8 +170,8 @@
board->canon_angle = 0;
board->canon_virtual_angle = 0.0;
board->canon_direction = 0;
- board->canon_sprite = sprite_new( CANON_LAYER, 30, theme->canon_a,
- board->canon_x, board->canon_y);
+ board->canon_sprite = sprite_new( CANON_LAYER, 30, theme->canon_a, 0, 0);
+ sprite_set_pos( board->canon_sprite, board->canon_x, board->canon_y);
sprite_pool_add( board->sprite_pool, board->canon_sprite );
canon_move( board, 0);
@@ -198,8 +198,6 @@
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;
@@ -465,10 +463,7 @@
/* move bubble */
bubble->x += dt*bubble->vx;
bubble->y += dt*bubble->vy;
- if ((bubble->vx || bubble->vy) && rnd(10)==1)
- 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 < board->left_border ) {
bubble->x = board->left_border;
@@ -805,7 +800,7 @@
}
void canon_move( board_t board, int dt ) {
- int frame, x, y;
+ int frame;
board->canon_virtual_angle += board->canon_direction*dt*CANON_ROTATING_SPEED*board->canon_speed;
board->canon_virtual_angle = clip( board->canon_virtual_angle,
-CANON_ANGLE_MAX, CANON_ANGLE_MAX );
@@ -813,10 +808,7 @@
frame = (board->canon_angle+
CANON_ANGLE_MAX)*board->theme->canon_a->size/NB_ANGLES;
/* compute canon center coordinates */
- // x = board->canon_x;
- // y = board->canon_y;
sprite_set_frame( board->canon_sprite, frame);
- sprite_set_pos( board->canon_sprite, board->canon_x, board->canon_y);
}
static void animate_alert( board_t board ) {
Index: sprite.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/sprite.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- sprite.c 11 Aug 2006 12:14:42 -0000 1.1.1.1
+++ sprite.c 12 Sep 2006 08:04:08 -0000 1.2
@@ -1,8 +1,10 @@
+#include <assert.h>
#include <string.h>
#include "sprite.h"
#include "SDL.h"
#include "theme.h"
#include "frame.h"
+#include "utils.h"
enum e_sprite_state {
SPIRIT_NEW,
@@ -136,8 +138,9 @@
if ( s->frame != frame ) {
old_frame = s->animation->element[s->frame];
new_frame = s->animation->element[frame];
- if (( old_frame->surf->pixels != new_frame->surf->pixels )
- &&( s->state == SPIRIT_UNCHANGED ))
+ if (!old_frame
+ || (( old_frame->surf->pixels != new_frame->surf->pixels )
+ &&( s->state == SPIRIT_UNCHANGED )))
s->state = SPIRIT_CHANGED;
s->frame = frame;
}
- Previous message: [Xbubble-commits] xbubble-sdl/src board.c, 1.2, 1.3 board.h, 1.2,
1.3 bubble.c, 1.2, 1.3 bubble.h, 1.1.1.1, 1.2 cell.c, 1.2,
1.3 cell.h, 1.2, 1.3 frame.c, 1.1.1.1, 1.2 path_init.c, 1.2,
1.3 setting.h, 1.2, 1.3 theme.c, 1.1.1.1, 1.2 xbubble.c, 1.2, 1.3
- Next message: [Xbubble-commits] xbubble-sdl/src .cvsignore,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Xbubble-commits
mailing list