|
-
Mar 18th, 2003, 02:56 PM
#1
Thread Starter
Addicted Member
Guess the hDC
I'm making a psuedo game engine with bitblt. I'm storing the source hdc and destination hdc in a type (SPRIT) as longs. The source doesn't change but the destination (the bufferer picture) does change its hdc (i think when I cls it). How can I either store the picBUFFER.hDC or do I have to change the long in the sprite type everytime picBUFFER.hDC changes?
Thanks!
NOMAD
ps: if its not possible I will just blit a background each time and not cls it... thanks y'all!
-
Mar 18th, 2003, 06:38 PM
#2
PowerPoster
Um.. cls is slow and bad but if you really want to use it - i recommend just to re-get the DC after clearing.. or since you're only flipping once a frame you can get it there each time.. that won't slow down anything.
-
Mar 18th, 2003, 08:17 PM
#3
Lively Member
don't cls it. my sprite engine uses a backbuffer whose hdc never changes and i'm blitting all over it. i just save the area under any moving sprites, so when they move, just the area that got changed needs to be redrawn, here is the pseudo code:
save the tile under the first destination
draw the sprite
draw the saved tile
move the sprite
save the tile under the next location
draw the sprite
use classes, makes life easier
-
Mar 18th, 2003, 08:32 PM
#4
PowerPoster
This technique is incredible slow if you're using a full-screen game where everything can be animated or moves out of the screen. This means for any jump'n'run, shoot'em'up, even top-down RPGs and everything. Since you have to redraw the whole environment in each frame (because the screen moved or it's just animated) there's no reason to use this backup technique.. However you don't need clearing with any of these methods, in fact as long as your game runs fullscreen (or full-buffer) you don't need clearing.
And as golgo said, if you need a static background and just some moving sprites you can still backup and overdraw the moving parts.. Or just use DX for whatever you wanna do
-
Mar 19th, 2003, 02:20 PM
#5
Thread Starter
Addicted Member
thanks guys, DX is my next project
NOMAD
-
Mar 20th, 2003, 11:29 AM
#6
Hyperactive Member
Just draw the background terrain once to a backbuffer stored in memory, since the terrain never changes. If you wanted the terrain to change or be animated, just animate a sprite that blends in with it, not the entire terrain again.
I'm suggesting using layers. Layer(0) would be the terrain (grass, desert, etc.) and would be drawn first to a backbuffer in memory, and when you need to scroll or whatever, just blit it from the backbuffer starting at the X and Y offsets, and the width and height of the display area. Although this may be a bad idea if you have huge maps, it's a good direction to take if your maps are fairly small.
Back to layers... you would draw Layer(0) once, and then loop through Layer(1) (maybe buildings?) to Layer(2) (sprites?) and then Layer(3) (items/doors?), starting from the top of the screen to the bottom left to right. Your code may look like this:
VB Code:
Blit Layer(0)
Do
For i = 1 to LayerCount - 1
Blit Layer(i)
Next i
DoEvents
Loop
Anymore questions, just ask.
[vbcode]
' comment
Rem remark
[/vbcode]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|