(If you know one of the answers that’s fine, any help is
appreciated)
a) I found the function [ void Projectiles::draw(void) ] does
not complete(it does for a while, even if bullets are spawned,
but seemingly randomly wont work). Do you see anything that
could cause a segfault?
b)
Can a debugger show me the line and the data used when the
program crashes?
c)
Also, what happens when the SDL parachute is deployed(after a
segfault)? Do I end up with memory that is used up untill I
reboot (for win32) or does it clean my mess up?
Here’s my code
void Projectiles::draw(void)
{
vector::iterator iter=projectile_list.begin();
while(iter != projectile_list.end())
{
pixel_set(screen, (int)iter->x, (int)iter->y, COLOR_BLACK);
pixel_set(screen, (int)iter->x+1, (int)iter->y,
COLOR_BLACK);
pixel_set(screen, (int)iter->x, (int)iter->y+1,
COLOR_BLACK);
pixel_set(screen, (int)iter->x+1, (int)iter->y+1,
COLOR_BLACK);
iter++;
}
}
//color black was set right before the main loop starts:
COLOR_BLACK = SDL_MapRGB(screen->format, 0,0,0);
void pixel_set(SDL_Surface *surface, int x, int y, Uint32 pixel)
{
//I didn’t create this function, I’m pretty sure its from SDL
docs
int bpp = surface->format->BytesPerPixel;
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x *
bpp;
switch(bpp) {
case 1:
*p = pixel;
break;
case 2:
*(Uint16 *)p = pixel;
break;
case 3:
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
p[0] = (pixel >> 16) & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = pixel & 0xff;
}
else {
p[0] = pixel & 0xff;
p[1] = (pixel >> 8) & 0xff;
p[2] = (pixel >> 16) & 0xff;
}
break;
case 4:
*(Uint32 *)p = pixel;
break;
}
}
struct Projectile
{
float x;
float y;
double rotation;
Vector velocity;
};
–jake__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.