Efficiency of moving sprites? (BitBlt and image controls)
Hi everybody. I'm working on a space shooter with a pile of enemies, bullets, etc. As of now they're all image controls but I'm going to use BitBlt, and custom data types to create non-existent controls (so I can just set some variables to be the top, left, height and/or width etc) and then blit a sprite to the correct location.
Anyway, I have the main game form and a form full of image controls containing a repository of picture boxes holding all the images needed for the game (a way around LoadPicture before I discovered 'AppPath'). I've got four options (see the poll please), which do you think will provide the best performance and efficiency?
Re: Efficiency of moving sprites? (BitBlt and image controls)
Don't use any controls.
I have an "LoadPictureToDC" function (at home), which loads the image straight from disk, and into a device context. When I get home I'll show you it (around 7 hours time).
Re: Efficiency of moving sprites? (BitBlt and image controls)
You should load all your pictures into dc's and then use those dc's to build the final picture in another dc.
And you don't need a dc for each object in the game.
There may be a million bullets but you can use a single dc for the bullet picture.
You then tell all these bullets to use that dc as their picture source.
Re: Efficiency of moving sprites? (BitBlt and image controls)
Thanks all.
I've found a LoadImgDC type function myself, on a tutorial. Methinks I'll use that. Saves on RAM.
One small problem... well, quite sizeable really... I've made a BitBlt tester and it refuses to work. (It's just a black screen - picture box - and when you press enter an image is supposed to appear.) Everything's done right, y'know, no typos, the properties are good, etc. I checked it 3 gazillion times before I noticed something...
It does work when I put in an error. If I comment out a Dim statement, when running, it throws me 'Variable not defined' as usual, then once I fix it, it returns to the program with the image appearing. If the program is left correct and run, it doesn't work. :\
I've tried removing and reinstalling VB (6.0 Professional if anyone's curious) and it didn't cure the problem. D'you think it's my laptop, something weird with the program, or what? The examples I've got from tutorials work fine.
Re: Efficiency of moving sprites? (BitBlt and image controls)
@singularis: Thanks. Here's the project in its entirety, see the zip file. There's a lot of commented-out lines of code that I'm switching between as I test the thing. I just tested it on another computer, and it behaved the same way as it does on my laptop.
@chemicalNova: Yah, that's the one I've got, although with slightly different names.
Re: Efficiency of moving sprites? (BitBlt and image controls)
Separate forms? Hmm. It still doesn't work with only using one picture box, or blitting to the form, or even using CreateCompatibleDC for a buffer that only exists in the computer's imagination. I'll try it anyway. Thanks.