如何使我的子弹从 X 轴的开始到 y 轴随机化 +3 -3 像素
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--;
}
}
}
当我拿着太空子弹向前走时,我希望它也能在 Y 轴上一点点扫射。
这是我想做的http://www.afrc.af.mil/shared/media/photodb/photos/070619-F-3849K-041.JPG 。
永远不要只击中 1 个点。只是为了稍微随机化 Y 轴。我想要改变的是
//set movment for bullet
bullet.position.X = bullet.position.X + bullet.speed;
类似于
BUllet.position.X = Bullet.position.X + Bullet.random.next(-3,3).Y + bullet.speed.
类似的东西。