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

后端 未结 3 766
我在风中等你
我在风中等你 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

    0 讨论(0)
  • 2021-01-05 10:07

    This post should solve your issues: simple-animation-using-c-windows-forms

    He details how he went around coding animation in a windows form and covers some of your questions.

    If that doesn't solve it, look up using some XNA libraries as Freeman said.

    0 讨论(0)
  • 2021-01-05 10:14

    From the details you provided, i can say this, if you wish to create a mini-game i would recommend you use WPF with some XNA libraries, because WinForms is not really cut out to enable a very impresive graphic experience, but rather it favours the creation simple GUI tools. Sometimes not even double buffering helps much.

    0 讨论(0)
提交回复
热议问题