Pages

Thursday, August 11, 2011

car race in 3D with C#

Yesterday I was looking at the demo I published in my last article, the asteroid demo, it had a good acceptance because it was made in a very simple way and today I will do the same. This article is a simple straightforward car race game trying to contain the minimum amount of lines of code (LOC). There are 3 cars that begin in a start line, they random change their speeds on the race and the race ends on an end line, quite simple. The user can follow the race with the keys W(forward) S(backward)  and can change the camera takes. At the end of the race a message is shown telling which car was the winner and you are able to reset the race and start over again. The car race is a simulation and the user can’t take control over any car.
Any suggestions to the code let me know, here is the download link
http://fbe.am/3BS

12 comments:

  1. can I get the source somewhere? thanks!

    ReplyDelete
  2. http://fbe.am/3BS I updated the post

    ReplyDelete
  3. Hello, what is the role of the class Winapi, what does it exaclty do?and the lines inside it like :
    [DllImport("GDI32.dll")]
    public static extern void SwapBuffers(uint hdc);

    Thanks

    ReplyDelete
  4. Hello
    The class Winapi its to communicate .NET with windows API

    [DllImport("GDI32.dll")]
    public static extern void SwapBuffers(uint hdc);

    This function calls SwapBuffers contained in GDI32.dll this is unmanaged code. The interop namespace handles this task.
    About SwapBuffers OpenGL doesnt draws directly on the screen instead it draws to a buffer and then SwapBuffers brings it to the screen. This is a techique used to avoid flickering
    If you have any further question please dont hesitate to ask.
    BTW it will be helpful if you become a follower of my blog :)

    ReplyDelete
  5. Hi Vasily,

    I want to ask if the tao.openGl reference is a customized library?.

    i am a new programmer and i want to learn things like this so much but i dont know where to start. I really want to know how to make graphics and make like world.cs ,cars.cs etc. THank you

    ReplyDelete
  6. Hi Vasily

    I want to ask if the tao.openGl is a customized library?

    is sort of get how the other stuff works but what i dont get all the time is the how these things are drawn.
    Thanks,

    ReplyDelete
    Replies
    1. Tao.Opengl is an OpenGL wrapper it allows programers to call opengl functions from .NET

      Delete
  7. Hi there,
    excellent work. But I have problem when I load my own 3DS model to your project as "Invalid magic in 3ds file header: 0x00002023" at ContentManager.LoadModels(); in mainForm.cs. What could be the reason? thanks and regards.
    NK

    ReplyDelete
  8. The problem is that the 3DS loader checks for a numbre to see if is loading a valid 3DS file if not it shows that error
    if you like you can send me the 3DS file

    ReplyDelete
  9. hi Vasily;
    i would like to upload a 3D human model by remplacing the Asteroid model but does not work please to help me;
    i need to animate upper limb for human model
    my email: zabatmahdi@gmail.com

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. Hi, how can I increase the no:of cars?

    ReplyDelete