Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 Sprite Sheets and side scrolling
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Knoton
Squire

USA
10 Posts

Posted - May 29 2006 :  5:10:11 PM  Show Profile  Reply with Quote
How would I go about using a sprite sheet as an anaimation? Also how can I choose just a section of a long bitmap to place on a surface, I would guess it is effectively the same thing as choosing the area on a sprite sheet to put on a surface. Is there a better way of doing side scrolling? Here's my code so far if it helps.

Download Attachment: DxMario.zip
156.55 KB

Knoton
Squire

USA
10 Posts

Posted - May 31 2006 :  10:40:54 AM  Show Profile  Reply with Quote
Just an updated project, now right, left and jump works in both directions. You just need to change the paths for your computer to the resources folder which is included. Now all I need to progress is the ability to add a background and scroll it. What are some good methods for doing this?

Download Attachment: DxMario.zip
166.77 KB

Go to Top of Page

PW7962
Squire

USA
33 Posts

Posted - May 31 2006 :  3:23:16 PM  Show Profile  Visit PW7962's Homepage  Send PW7962 an AOL message  Reply with Quote
well I don't have vb.net but in VB6 with bitblt there is 2 parameters that say xsrc and ysrc. If you have a picture bigger than the screen then you could scroll it like this:
bitblt someplace, 0, 0, 300, 300, backgroundpic, player.x, player.y, vbsrccopy

of course you should play around with it, because it can get a little buggy if you aren't sure what to do, but it is fairly simple to do and looks pretty good. Now if vb.net works the same way with graphics then this should work for you if not then idk.

Star Fantasy Unlimited Programmer

http://starfantasy.forumer.com
Go to Top of Page

Knoton
Squire

USA
10 Posts

Posted - May 31 2006 :  5:59:47 PM  Show Profile  Reply with Quote
I guess I forgot to mention I am using directdraw
Go to Top of Page

dxgame
Knave

USA
73 Posts

Posted - Jun 01 2006 :  02:38:38 AM  Show Profile  Visit dxgame's Homepage  Reply with Quote
Hi Knoton - I'm not a vb.net guy but the usual way to do side scrolling in typical classic arcade games like Super Mario, Gradius, etc, is to build your background out of smaller tiles, creating a 2D map, and then simply blitting those tiles to the screen each frame update. The key thing is to place as many of those tiles on one surface.

You "could" create a large single surface but in DirectDraw you run into compatibility problems because some video cards can't have surfaces wider or taller than the defined screen device. The advantage of using tiles to build your background map instead of a full bit map background is, memory usage is lower, plus you can do realtime dynamically changing tiles, etc.

If you get a VB6 build, I'd love to take a look. ;)
Go to Top of Page

Knoton
Squire

USA
10 Posts

Posted - Jun 01 2006 :  06:07:17 AM  Show Profile  Reply with Quote
Ok, makes sense. But when any of my sprites go offscreen part way the program freezes. How do I stop this from happening?
Go to Top of Page

PW7962
Squire

USA
33 Posts

Posted - Jun 01 2006 :  2:25:29 PM  Show Profile  Visit PW7962's Homepage  Send PW7962 an AOL message  Reply with Quote
Don't have them go offscreen ;)

If you use scrolling try to keep the player in the middle of the screen and then have something that makes sure that they stop before the end of the screen/map


Star Fantasy Unlimited Programmer

http://starfantasy.forumer.com
Go to Top of Page

Knoton
Squire

USA
10 Posts

Posted - Jun 01 2006 :  10:17:49 PM  Show Profile  Reply with Quote
Well, if the background is a Directdraw surface and I don't know how to have it display only the section of image I want then I need to have it go off the screen which then crashes... So I need either A: A way to apply a portion of an image to a directdraw surface or B: a way to keep it from freezing if a surface goes off screen.
Go to Top of Page

Almar
Moderator

Netherlands
192 Posts

Posted - Jun 03 2006 :  09:32:28 AM  Show Profile  Visit Almar's Homepage  Send Almar an ICQ Message  Reply with Quote
Determine how much the image off at the side, and blit the image width: width - amountofinvisiblepixels. That's the common trick back in the day. Normally the sprite would be completely invisible if it went out of the window bounds.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
VBGamer © Go To Top Of Page
This page was generated in 0.12 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.