debug := $(if $(DEBUG),1,0)
ldflags := $(shell sdl-config --libs) -lSDL_image -lSDL_mixer
-cflags := $(shell sdl-config --cflags) -Wall -DDEBUG=$(debug)
+cflags := $(shell sdl-config --cflags) -Wall -DDEBUG=$(debug) -ggdb
my_objects := file.o score.o shape.o sound.o main.o $(if $(DEBUG),debug.o)
libs := SFont.o
char topline[1024];
char *initerror = "";
+struct shape shipshape;
float shipx,shipy = 240.0; // X position, 0..XSIZE
float shipdx,shipdy; // Change in X position per tick.
float rockrate,rockspeed;
// Load the spaceship graphic.
NULLERROR(temp = IMG_Load(add_path("sprites/ship.png")));
NULLERROR(surf_ship = SDL_DisplayFormat(temp));
+ get_shape(surf_ship, &shipshape);
// Load the life indicator (small ship) graphic.
NULLERROR(temp = IMG_Load(add_path("indicators/life.png")));
}
if(!gameover && state == GAMEPLAY) {
+ for(i=0; i<MAXROCKS; i++) {
+ if(rock[i].active) {
+ if(collide(shipx-rock[i].x, shipy-rock[i].y, rock[i].shape, &shipshape))
+ bang = 1;
+ }
+ }
+ /*
SDL_LockSurface(surf_screen);
raw_pixels = (Uint16 *) surf_screen->pixels;
// Check that the black points on the ship are
}
}
SDL_UnlockSurface(surf_screen);
+ */
}
// Draw all the little ships
rockptr->dy = rnd()-0.5;
rockptr->type_number = random() % NROCKS;
rockptr->image = surf_rock[rockptr->type_number];// [random()%NROCKS];
+ rockptr->shape = &rock_shapes[rockptr->type_number];
rockptr->active = 1;
rockptr->y = rnd()*(YSIZE + rockptr->image->h);
}
int xov, yov;
if(xdiff >= 0) xov = max(min(r->w-xdiff, s->w), 0);
- else xov = -max(min(s->w+xdiff, r->w), 0);
+ else xov = min(-min(s->w+xdiff, r->w), 0);
if(ydiff >= 0) yov = max(min(r->h-ydiff, s->h), 0);
- else yov = -max(min(s->h+ydiff, r->h), 0);
+ else yov = min(-min(s->h+ydiff, r->h), 0);
- if(xov == 0 && yov == 0) return 0;
-
- return 0;
+ if(xov == 0 || yov == 0) return 0; // bboxes hit?
+ else return 1;
}