Level Editor

Published December 22, 2006
Advertisement
Level editor is starting to come along quite nicely now. Because I'm now using a three layer map, I needed to figure out how to do transparency with the Win32 API's BitBlt.

In case anyone ever struggles, this provides an excellent explanation.

Although they are being a bit naughty with the first code section on that page. I was reading the other day that when you create a device context, it does actually have a default bitmap selected into it so you do actually need to save the old bitmap when you select one in and ensure you select it back in before you delete the DC.

The code should really have been:

    HBITMAP Old=(HBITMAP)SelectObject(hdcMem, g_hbmMask);    BitBlt(hdc, 0, 0, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCAND);    SelectObject(hdcMem, g_hbmBall);    BitBlt(hdc, 0, bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCPAINT);    SelectObject(hdcMem, Old);    // okay to DeleteDC(hdcMem) now


or I think you get a resource leak.

I struggle to find any definitive information on resource leaks these days so I play it as safe as possible. You can test Win32 GDI stuff for resource leaks with Task Manager by going to Processes then doing View -> Columns and selecting GDI Objects.

You can then run your app, note the number used, perform an operation and check it against the total shown in Task Manager.

I know it is less of a problem from Win2000 onwards but it feels icky to not be thinking about things like that.

Mad-obsessive-rant ends.
Previous Entry Last day at work
Next Entry Orc - new level
0 likes 2 comments

Comments

Jotaf
'Bout your previous post:

I just loved this idea of a 'virtual assembler', never thought of that, but like you said, it should be tremendously useful! I just had another idea though: what about if you could provide a basic definition like this, and use it aftwards with named variables:

#byte
#enum { mid begin end }

#double
#struct waypoint {x y byte:flag=mid } //default value for "flag"

#waypoint 10 20 begin
#waypoint 12 50
//another way
#waypoint x=10 y=70
#waypoint flag=end x=40 y=20
December 22, 2006 05:56 PM
Aardvajk
That's a very interesting idea. One of the problems I have with using it for level files is that the script ends up full of lines like:


4
0 0 1 0 2
0 1 0 0 2
3 4 0 1 2
0 4 0 0 0


which unless I laboriously comment can be quite hard to remember what they mean. I'm actually quite interested now in being able to do:


#struct block
{
    ID Bank=1 Frame Layer Attr
}

#block{ ID=10 Frame=2 }
#block{ Frame=5 Layer=2 Attr=1 }


or something similar as it forces self documentation, removes the need to restate common parameters and means you could state parameter values in any order you wanted.

Thanks for the idea. I'll have to have a look at doing this at some point.
December 23, 2006 05:22 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement