1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
void Bullet::BulletMove(int bVelY, int bVelX, int bullet_x, int bullet_y, Player getLocal)
{
//players location (creates the bullet wherever the player is)
bullet_x = getLocal.x;
bullet_y = getLocal.y + 10;
//bullets velocity
bVelY = 3;
bVelX = 0;
//moves the bullet
bullet_y -= bVelY;
if( bullet_y <= 0 || bullet_y >= SCREEN_HEIGHT )
{
BulletShowHide( false ) ;
}
//else if( /*detects collision*/)
else
BulletShowHide( true );
}
void Bullet::BulletShowHide( bool onScreen )
{
if( onScreen == true )
{
apply_surface( bullet_x, bullet_y, bullet, screen, NULL );
}
if( onScreen == false )
{
SDL_FreeSurface (bullet);
}
}
void Bullet::BulletFired(int bVelY, int bVelX, int bullet_x, int bullet_y, Player getLocal, bool onScreen)
{
BulletMove(bVelY, bVelX, bullet_x, bullet_y, getLocal);
BulletShowHide(onScreen);
}
|