When the game launches, once the bullet is going up.
What I want is the bullet should only be fired when the keys.up is pressed.(fighter rectangle also moves when the keys are pressed)
In the paint method, how can the bulletImage be drawn only when the fire method is called?
If someone can please help me correct my code.
Thanks
private void fire()
{
bulletRectangle.Y += bulletDirection;
bulletRectangle.Y += bulletSpeed;
bulletDirection = -1;
bulletSpeed = -5;
}
if(keyArgs != null)
{
switch (keyArgs.KeyCode)
{
case Keys.Up: fighterRectangle.Y -= ySpeed;
fire();
break;
case Keys.Down: fighterRectangle.Y += ySpeed;
break;
case Keys.Right: fighterRectangle.X += xSpeed;
break;
case Keys.Left: fighterRectangle.X -= xSpeed;
break;
default:
return;
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
g.DrawImage(bulletImage, bulletRectangle.X, bulletRectangle.Y);
}
This post has been edited by ho-ho: 04 May 2009 - 06:25 AM

New Topic/Question
Reply




MultiQuote





|