none
visual c# car moving

    Question

  • hello:)
    Im making a game, now im at this point where i move a label with the arrow keys.
    Up moves the label up and left moves it left etc.
    Now I want the label to act like a car.
    So when I would press the up key the car moves forward, If I press left or right the car will rotate so it can go in any direction...if u know what I mean (gta 2 style).
    Any tips...I have no Idea how to do that
    thanks
    Sunday, October 30, 2011 10:24 AM

Answers


  • Now I follow what you are after. 
     
    To do that you would do most of the work in the form's paint handler.  You need to apply a transform when calling Graphics.DrawImage, to draw the track image or vectors, depending on how you are storing the track data.
     
    Bob Powell has a site with great examples for what you are trying to do.  His site is: http://www.bobpowell.net/faqmain.aspx
     
    As for my being abusive, if that was what your comment meant, I did not mean to be.  I just came at your question from a perspective that was different from what you were after.  I never understood you were talking about a "top down" driving game.  In fact you wrote gta 2 style, which I took to mean driver perspective. 

    --
    Mike
    Sunday, October 30, 2011 4:39 PM

All replies


  • Typically in a car game, the surrounding changes, but the car dash does not.  Can you explain what you want when you say the label will move forward or backward?  Perhaps you mean changing the size as you move closer or farther away.

    --
    Mike
    Sunday, October 30, 2011 11:26 AM
  • Yes my car is allways in the center of the screen and everything around it moves.

    So the up arrow key is for aceleration, the down arrow is for braking.

    If I would to press the left arrow key the map would rotate left, the background would rotate as long as the left button is pressed, so you can drive hard left of a just little left, do a 360 turn, 90, 45... 

    I think i need something that would rotate the whole background and it would just rotate as I would press a arrow key.

    Was this helpfull? :P

    Sunday, October 30, 2011 3:40 PM

  • You need to change the way you are thinking about the problem.  What you had, moving the label around is a simple problem.  What you are trying to do now involves rendering an image of what is in front of the car.  In order to render a string of text that is in front of the car, you have to have a size of the text, and the distance away.  Based on the distance and height of the characters, you have a size that it appears. 
     
    Think of the text as a three meter tall tree.  Whan the tree is twenty five meters away, the tree is fairly small relative to everything else.  Driving forward, when the distance to the tree is five meters, the tree takes over the entire picture.
     
    Accelerating, turning, etc all pertain to the view that needs rendering.

    --
    Mike
    Sunday, October 30, 2011 3:51 PM
  • your talking about perspective and 3d right?

    Im making this in 2d.

     

    Sunday, October 30, 2011 3:53 PM

  • Yes, I am talking about 3d.  If you are only working in 2d, then what role does acceleration/decelaration play?

    --
    Mike
    Sunday, October 30, 2011 4:01 PM
  • Found a simmilar thing.

    http://geoquake.jp/en/webgame/DrivingSimulatorGM/


    Only that this one has the car rotating and not the map.

    I want the car to be in the center and when you turn the map would rotate and not the car, so the car is always standing still.

    edit: abusive?
    • Edited by mr.sofa Sunday, October 30, 2011 4:21 PM
    Sunday, October 30, 2011 4:12 PM
  • Why did it get reported as abusive?
    Sunday, October 30, 2011 4:34 PM

  • Now I follow what you are after. 
     
    To do that you would do most of the work in the form's paint handler.  You need to apply a transform when calling Graphics.DrawImage, to draw the track image or vectors, depending on how you are storing the track data.
     
    Bob Powell has a site with great examples for what you are trying to do.  His site is: http://www.bobpowell.net/faqmain.aspx
     
    As for my being abusive, if that was what your comment meant, I did not mean to be.  I just came at your question from a perspective that was different from what you were after.  I never understood you were talking about a "top down" driving game.  In fact you wrote gta 2 style, which I took to mean driver perspective. 

    --
    Mike
    Sunday, October 30, 2011 4:39 PM
  • I have no idea who reported either of our posts as abusive.
     
    ???

    --
    Mike
    Sunday, October 30, 2011 4:43 PM
  • THanks :)

    Ill look at the tutorials and see what I can do.

    Sunday, October 30, 2011 4:45 PM