Results 1 to 5 of 5

Thread: [Question] How to make a movable character in vB

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    2

    Question [Question] How to make a movable character in vB

    Hi, I was planning on making a pokemon-esque "game" where I am able to move a retro styled character (sprite ripped from pokemon). I have about 16 or so different images that would be used for the walk cycles and such and was wondering how I would get this mapped to arrow keys so that when the buttons are pressed, the character image moves and the walk cycle commences. I would appreciate a fully mapped out code so I have something to work with. I was also curious as to how I could involve collision detection, since I want it so that when the character image bumps into a machine, a dialogue box comes up and asks if they want another form to pop up.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [Question] How to make a movable character in vB

    Moved From The CodeBank (which is for sharing code rather than posting questions )

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: [Question] How to make a movable character in vB

    What kind of technology are you thinking of using, and which language? I guess you did say VB, and I would guess that you mean VB.NET, so will this be just using GDI, or will it be using something like XNA? If you haven't decided, the key question you have to decide on is this: How many total sprites will there be on the screen at one time?

    GDI is VERY simple to get up and running with, but the performance will be horrible if you are drawing lots of sprites, or very large sprites, and doing so quite often. If you have one solid background image that doesn't change, or changes only very rarely, and the walking sprite you talk about is not HUGE (as it probably is not), then GDI would be easier, and should work fine. If you have a busy scene full of dynamic items that can change periodically, then GDI is probably going to make the result very laggy. I was working on a project that had up to about 200 rectangles drawn on the screen. The user could zoom in or out, which required redrawing many, or all, of the rectangles. The rectangles, themselves, were kind of complicated to draw, and the performance under GDI was horrible. In this case, I created all the images at each zoom level on startup, and swapped in the proper image when the user zoomed, which turned out to work pretty well, so just drawing the images wasn't bad, but composing the images was.

    Recently, I reworked the interface using XNA. XNA was originally C# only, and virtually all examples will be in C#, as will all the templates, currently. I have it working in VB, so it is possible, but it's an odd animal. Getting it going wasn't too hard, though I still have some questions about it, so I haven't posted the code I used to get it going. All the code was based on examples that I linked to in other threads here in the gaming forum (and I have only about two threads, so they shouldn't be hard to find), and tutorials I found that really didn't apply to what I was doing, which involved using XNA to draw individual controls on a Windows form. The result was this: XNA is so much faster than GDI that I was able to drop the pre-rendering of all the images. Instead, when the user zooms, XNA composes and draws the 200 images on the screen as fast as I could ask for. So you pay in complexity and lack of examples, but you gain considerably in performance.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2012
    Posts
    2

    Re: [Question] How to make a movable character in vB

    http://i.imgur.com/7rv44.png This is the background I want to use.

    http://i.imgur.com/KFat4.png This is the sheet (composed of 12 different sprites) that i split up hoping to piece together with the code..


    I am a beginner programmer and this code is for visual basic 2008 express edition. I will not be using Direct X or any of the things you mentioned, i'm looking to only use the core program along with a couple lines of simple code. I am having trouble finding good code online. I have attempted to figure it out by myself, but I can not find worthy code that would allow spirtes chaning upon key press, and then collision detecting setting off another form popping up. Any idea what i can do? Really appreciate it if you helped me get started.. This is for a project.

  5. #5
    Lively Member mikorians's Avatar
    Join Date
    Jun 2010
    Location
    In a fog
    Posts
    83

    Re: [Question] How to make a movable character in vB

    Simple? In VB6, I used to do this all the time with the loadpicture and paintpicture functions. Perhaps VB2008 has similar functions?
    Use a picturebox's keydown event to collect the keypress and update the display at that time.
    Use sets of coordinate arrays to track where the boxes are, and if the intersect, make the other form visible with formn.visible=true
    That's at least the way folks used to do it waaaaaayyy back then...
    I'm a rusty old antique. Ha.

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