Results 1 to 2 of 2

Thread: Moving characters with forward key

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2016

    Moving characters with forward key

    Hey Guys

    I'm using VB Basic Express (2010) and I've got a pretty ambitious school project to do.

    I want to be able to move a character (picture box) around on the screen with arrow key, but in the way where one has to rotate in the direction they want to go in, and then press forward to move in that direction, similar to the game 'Evasive Maneuvers'. I also want to connect this rotation with a bunch of sprties, but I might know how to do this myself. I know this might a big ask from you guys, but is it possible in Visual Basic, and if so, how can I do it?


  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Southern Tier NY

    Re: Moving characters with forward key

    Rather than use a lot of images to represent rotation, you could rotate and draw an image.
    I have posted a number of example programs (not complete programs or games) on the forum.
    I'll post three of the examples here, and provide a link to the thread with the paperpuppet example, as there is extra code posted in that thread that extends the example.

    The 503_vb9.. example was in response to a thread on another forum. The image of the car was provided by the original poster. I demonstrated how that image could be rotated, and added some background graphic that moved so that the rotating image would appear to be moving across that background. The program became sort of a testbed for adding a large "gaming area", with a lot of other images scattered across it, and a mechanism for choosing the timing interval ans simulating speed based on the size of the car and how many pixels of movement is done.
    The program might have a lot of extra stuff compared to what you need, and likely to be overwhelming.
    The up arrow increases speed in the forward direction.
    The down arrow increases speed in the reverse direction.
    The left and right arrows turn the car left,right.
    The spacebar brakes the car.
    The speed in relative Miles Per Hour is displayed in the top left label. The timing interval can be changed, and the resulting Frames per Second is displayed in the right most label. These are not necessary, just added as part of the code experimentation and exploration.

    The TruckGame example (again the graphics were provided by the poster) was in response to a problem they had with implementing the rotation. In their case, there was a DPI issue with the type of bitmap file being used which was causing the problem, which took awhile to figure out.
    I just extended the example to not just rotate one item, but to rotate multiple items based on them being hooked together (not physically accurate, but entertaining non the less).
    This example doesn't use the arrow keys. Where you click and drag with the mouse determines where one end of the first link is, and all the other links are "dragged" along.

    The PapperPuppet example, was in response to this thread.
    The zip has controls for rotating the feet, but the drawing of the feet wasn't completed before I posted it. I had to leave for work, so posted what I had done before heading out. There are posts after the one with the zip file that add some extra code examples to the base example.
    This example doesn't use the arrow keys, or the mouse for moving and rotating.
    The rotating of parts (and the whole figure) are controlled by trackbars at the top of the form.
    But if you do drag with the mouse on the form, you can reposition the figure (using the left mouse button), and scale the drawing (using the right mouse button).

    I don't know if these examples will be helpful for your immediate needs, but perhaps they will be useful in the future as a starting point for future endeavors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width