X-Git-Url: https://jasonwoof.com/gitweb/?p=vor.git;a=blobdiff_plain;f=sprite.c;h=6a20442a4080d993ca30e2aa52112f044f1461e0;hp=447e4827525329005a673f07b098d5115227d902;hb=3079660eb1f60a861b677b746da581c4c0e6c3dd;hpb=9a9572d121946fef90a24ea5514a0c3ca33b1ae5 diff --git a/sprite.c b/sprite.c index 447e482..6a20442 100644 --- a/sprite.c +++ b/sprite.c @@ -48,7 +48,7 @@ get_shape(Sprite *s) exit(1); } - SDL_LockSurface(s->image); + if(SDL_MUSTLOCK(s->image)) { SDL_LockSurface(s->image); } px = s->image->pixels; transp = s->image->format->colorkey; p = s->mask; @@ -62,7 +62,7 @@ get_shape(Sprite *s) } px = (uint16_t *) ((uint8_t *) px + s->image->pitch - 2*s->image->w); } - SDL_UnlockSurface(s->image); + if(SDL_MUSTLOCK(s->image)) { SDL_UnlockSurface(s->image); } } @@ -128,11 +128,11 @@ reset_sprites(void) } void -move_sprite(Sprite *s) +move_sprite(Sprite *s, float ticks) { if(s->flags & MOVE) { - s->x += (s->dx - screendx)*t_frame; - s->y += (s->dy - screendy)*t_frame; + s->x += (s->dx - screendx)*ticks; + s->y += (s->dy - screendy)*ticks; } } @@ -148,7 +148,7 @@ sort_sprite(Sprite *s) } void -move_sprites(void) +move_sprites(float ticks) { int sq; Sprite **head; @@ -158,7 +158,7 @@ move_sprites(void) head=&sprites[set][sq]; while(*head) { Sprite *s = remove_sprite(head); - move_sprite(s); sort_sprite(s); + move_sprite(s, ticks); sort_sprite(s); } } set = 1-set; // switch to other set of sprites.