I’m currently working on my first space shooter, and I’m in the process of making my ship shoot some bullets/lasers. Unfortunately, I’m having a hard time getting the bullets to fly vertically. I’m a total noob when it comes to this so you might have a hard time understanding my code
// Position Bullet Function
projectilex = x + 17;
projectiley = y + -20;
if(keystates[SDLK_SPACE])
{
alive = true;
}
And here’s my show function
if(alive)
{
if(frame == 2)
{
frame = 0;
}
apply_surface(projectilex,projectiley,ShootStuff,screen,&lazers[frame]);
frame++;
projectiley + 1;
}
I’m trying to get the bullet to fly vertically… and I have no clue how to do that. I’ve tried messing with the y coordinate but that makes things worse. The laser/bullet just follows the ship
How would I get it to fire at the starting position and keep going in a vertical line without it following the ship?
Thanks for your help!