Jump to content
  • Advertisement
  • entries
  • comments
  • views

Level Editor

Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

'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:

#enum { mid begin end }

#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

Share this comment

Link to comment
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:

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.

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!