Advertisement

VB code

Started by September 03, 2002 07:28 AM
4 comments, last by XzAzX 22 years, 2 months ago
Ok, I'm trying to make a RPG game under Visual Basic 6.0. I have graphics, but its just that when I need to walk or so, The Only way i know of is to do that with moving imageboxes... Is there an better way to do this, and make the person walk smoother and nicer >???? BIG THX! [edited by - xzazx on September 3, 2002 8:29:24 AM]
You should really use a proper graphics API, like DirectDraw or the GDI. Look in the For Beginners and the Resources section, there''s tons of tutorials on it.

- JQ
Full Speed Games. Coming soon.
~phil
Advertisement
You have a total of 3 image box / picture box (I use). The player image, instead of having it another imagebox moving you blit or paste the player image ontop of the map/background/picturebox. Then to make it smooth with no flickering you make 2 picture boxes. You put the map onto one of the picture boxes and then put the hero onto this picture box with blit API and then put this entire picturebox to the other picture box. This is called double buffering and it removes flickering etc.

You will have:

pbDoubleBuffer (picture box)
pbScreen (picture box)
pbPlayerSprite (picture box)


Here is the BitBlit API. Put this in a module.

Public Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _                                            ByVal x As Long, _                                            ByVal y As Long, _                                            ByVal nWidth As Long, _                                            ByVal nHeight As Long, _                                            ByVal hSrcDC As Long, _                                            ByVal xSrc As Long, _                                            ByVal ySrc As Long, _                                            ByVal dwRop As Long) As Long  


And some sample code:

pbDoubleBuffer.picture = LoadPicture(App.path & "\map.bmp")pbPlayerSprite = LoadPicture(App.path & "\player.bmp")BitBlt (pbDoubleBuffer.hdc, 0, 0, Player_Sprite_Width, Player_Sprite_Height, pbPlayerSprite.hdc, 0, 0, vbSrcCopy) BitBlt (pbScreen.hdc, 0, 0, pbDoubleBuffer.ScaleWidth, pbDoubleBuffer.ScaleHeight, pbDoubleBuffer.hdc, 0, 0, vbSrcCopy) [edited by - Brandisco on September 3, 2002 8:44:39 AM]    
Moved to the beginner forum
I''d use DirectX Visual Basic will work with it no prob...
laziness is the foundation of efficiency | www.AdrianWalker.info | Adventures in Game Production | @zer0wolf - Twitter
Matter of fact, I was going to suggest using VB''s BitBlt function. I just discovered it, and it does the job really well. I suggest you go the site below, which has a really good tutorial for animation using BitBlt and backbuffering. There are some other good tutorials there as well.

VB Explorer

Grant Palin
Grant Palin

This topic is closed to new replies.

Advertisement