使元素移动

时间:2017-02-06 18:52:01

标签: c# visual-studio

我正在制作迷你游戏。我有一个在背景上移动的圆圈。但是我需要点击右边的例子,圈子应该放置另一个圈子,我的意思是如果圈子是例如x,如果我再次点击x - 1,它应该圈出x - 2。< / p>

for (int i = Snake.Count - 1; i >= 0; i--)
{
    if (Input.KeyPressed(Keys.Right))
    {
        Settings.direction = Direction.Right;
        Snake[i].X++;
    }
    else if (Input.KeyPressed(Keys.Left))
    {
        Settings.direction = Direction.Left;
        Snake[i].X--;
    }
    else if (Input.KeyPressed(Keys.Up))
    {
        Settings.direction = Direction.Up;
        Snake[i].Y--;
    }
    else if (Input.KeyPressed(Keys.Down))
    {
        Settings.direction = Direction.Down;
        Snake[i].Y++;
    }
}
PaintBox1.Invalidate();
//snake is a list of circles

0 个答案:

没有答案