문제

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 tried to animate the car with the KeyDown event, however the animation is really Faltering.. So is there any other way to create animation? or is it possible to soomth it somehow? (For the car I use a PictureBox that Docked to the form and in its paint event im redrawing the car in the right window positions.)

도움이 되었습니까?

해결책

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.

다른 팁

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.

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top