How to make my bullet goes form start of X axis to y axis randomized by +3 -3 pixels
public void UpdateBullets()
{
//For each bullet in our bulletlist: Update the movment and if the bulet hits side of the screen remove it form the list
foreach(Bullet bullet in bulletList)
{
//set movment for bullet
bullet.position.X = bullet.position.X + bullet.speed;
//if bullet hits side of screen, then make it visible to false
if (bullet.position.X >= 800)
bullet.isVisible = false;
}
//Go thru bulletList and see if any of the bullets are not visible, if they aren't then remove bullet form bullet list
for (int i = 0; i < bulletList.Count; i++)
{
if(!bulletList[i].isVisible)
{
bulletList.RemoveAt(i);
i--;
}
}
}
When i hold space bullets just go forwards and i want it to strafe little by Y axis as well.
Here is http://www.afrc.af.mil/shared/media/photodb/photos/070619-F-3849K-041.JPG to what i want to do.
Never to hit only in 1 spot. Just to randomize Y axis a bit. What i want to change is
//set movment for bullet
bullet.position.X = bullet.position.X + bullet.speed;
to something like
BUllet.position.X = Bullet.position.X + Bullet.random.next(-3,3).Y + bullet.speed.
Something like that.