Sign in to follow this  

Level Editor in VB 6.0

This topic is 4746 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For making grids you'll probably want to look into the ScaleLeft and ScaleTop properties of whatever control contains the grid

Changing these values is like changing the origin of the form, so if you subtract 10 from the scaleLeft the origin would not be the top left anymore it would be (-10, 0)

However, changing the scaleleft does not change the position of any of the controls on the form and so in order to get it to do this you have to store the position of each control before modifying the scaleleft, then modify scaleleft, and then set the positions of each control back to what they were

I just finished a 2D editor myself, also in VB 6, and this worked well for me
I wrote it to be extremely generic so that I could use it in more than one game
It reads in an XML file which defines what kinds of things it can allow and the format of the output etc.

Share this post


Link to post
Share on other sites
Why people use XML files for gametype stuff is beyond me, as it just is not very efficient.. But that's another subject..

Why you would bother with scaleleft and scaletop is also a mystery for me.

What kind of grid are we talking about? and how much is your knowledge of VB? what kind of 2d side-scrolled game are we talking about, is the format know you have to write to known?

(I've written a long time ago a 2d sidescroller level editor (and some other gamefile editor stuff) in Borland pascal 7 (i also wrote the windowhandling stuff as it was still for dos and using Vesa, so no nice window stuff was really available), always had the intention of converting it to VB.. it supported parallax scrolling and some other stuff (like path editing etc.). I wrote the gameengine itself in assembly as back then it was easier to write it in assembly (Without the 16K segment stuff)..

Share this post


Link to post
Share on other sites
Xml isn't about efficiency and speed, it's about flexibility and extensibility. Very easy to maintain and read. Data files do not need to be extremely efficient in terms of loading as it only happens once.

~Graham

Share this post


Link to post
Share on other sites
It's been a while since I wrote a 2D/tile based level editor in VB6, but back in my learning days I got so practiced with them I could pull one out in under 30mins [grin].

This is what I'd do...

First off, I'll simplify it by making the whole thing editable on one screen. Just shout if you want some ideas about a scrolling editor.

Second, some numbers. I typically designed mine with 16x16 tiles, and a number such as 20x20 (320x320 pixels in total). Work out these numbers before you start...

Set your host form to be scalemode=pixels; then create a picturebox of the correct size (e.g. 320px h/w) - compensate by +4 height/width if you use borderstyles. Set it to Autoredraw=true, set its backcolor to black.

Now comes the trick, set the scaleWidth and scaleHeight to the number of tiles you have. e.g. '20' from my above example. VB6 will now be nice enough to manage the size of tiles for you. it divides your drawable area into nice 16x16 pixel squares.

When it comes to render, use "PaintPicture" (search MSDN for the parameters). Do a nested for loop, but with the scalewidth/height set as mentioned, you can just pass the loop indicies in without worrying about translating to pixels. VB6 will handle lining stuff up for you.... Autoredraw makes sure you only need to redraw when something changes.

Then, on the mouseDown and mouseMove events for the picturebox, you can cast the incoming coordinates to integers and use them as array indicies for checking/altering the tile at a given point.

All clean and easy [wink].

PaintPicture redrawing is a bit slow for large levels, so you might want to investigate BitBlt() from the WinAPI, however you'll have to managed the explicity tile->pixel coordinate conversions.

hth
Jack

Share this post


Link to post
Share on other sites
Quote:
Original post by SuperDre
Why people use XML files for gametype stuff is beyond me, as it just is not very efficient.. But that's another subject..

Why you would bother with scaleleft and scaletop is also a mystery for me.


I used scaleleft and scaletop so that moving the 'camera' around would not change the values for the position of any of the controls... I also used the scalewidth/height for zooming in/out as mentioned by jollyjeffers

And as for using Xml I prefer to spend more time writing game code rather than fixing bugs with my parser, but to each is his own

Share this post


Link to post
Share on other sites

This topic is 4746 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this