Knoton |
Posted - May 29 2006 : 5:10:11 PM 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 |
Almar |
Posted - Jun 03 2006 : 09:32:28 AM 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. |
Knoton |
Posted - Jun 01 2006 : 10:17:49 PM 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. |
PW7962 |
Posted - Jun 01 2006 : 2:25:29 PM 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 |
Knoton |
Posted - Jun 01 2006 : 06:07:17 AM Ok, makes sense. But when any of my sprites go offscreen part way the program freezes. How do I stop this from happening? |
dxgame |
Posted - Jun 01 2006 : 02:38:38 AM 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. ;) |
Knoton |
Posted - May 31 2006 : 5:59:47 PM I guess I forgot to mention I am using directdraw |
PW7962 |
Posted - May 31 2006 : 3:23:16 PM 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. |
Knoton |
Posted - May 31 2006 : 10:40:54 AM 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 |