How to create a smooth animation using C# Windows forms?

后端 未结 3 804
我在风中等你
我在风中等你 2021-01-05 09:30

due my school project I must create a game using Windows forms only..

I have decided to create a 2D racing game. So now I need to move the car image. To move it I tr

3条回答
  •  无人及你
    2021-01-05 10:04

    well you can make a movement-animation system

            int x = pictureBox1.Location.X;
            int y = pictureBox1.Location.Y;
            if (e.KeyCode == Keys.Right) x += 1;
            else if (e.KeyCode == Keys.Left) x -= 1;
            pictureBox1.Location = new Point(x, y);
    

    to make it faster change the x+=1 x-=1 and y+=1 y-=1; to bigger numbers like y x-=3; so in this cod you yous the arrow keys but only the right and left because you will be driving foward reapeatedly so you only move right and left

提交回复
热议问题