• entries
    743
  • comments
    1924
  • views
    580433

Polygons

Sign in to follow this  

69 views



I've added the feature to the map editor to allow you to define polygons with the mouse and they are now saved/loaded to and from the XCS level file.

It's a bit hacky - there's nothing to stop you defining non-convex polygons but I'm not really bothered.

It only actually took a couple of minutes to define the polygons around the solid shapes on the existing test level, so it is not going to add as much work to level designing as I thought it might.

When in "polygon" mode, you just left-click to define the points (snapped to the block-size grid) and right-click to complete the shape. When not defining a shape, right-clicking in an existing polygon selects it (it goes brighter green when selected) and you can delete the selected polygon from the Edit menu or with the delete key.

All ready to overhaul the map collision system in Pod to use these polygons rather than the polys generated from taking a map sample, which should mean that any sized object should now correctly collide with the map.

Updating Map to have this feature only took about 2-3 hours in the end which is pretty good, although I do feel I've lost control of Map as a project now. I've bolted on so many different features as I've needed them in the game and it's turned into a bit of a mess.

The next map editor I'll write will still be C++ and Win32 but will use GDI+ to make the drawing work easier and to add some visual features, but as long as I have a functional editor for me to use for the time being, there's no rush.

Hopefully the next map editor will stand as a solution in its own right and may be of use to other people as a tilemap editor. We'll see.

[LATER]

That was pretty trivial to implement it into Pod actually, as I was already collision checking against a std::vector based on a map sample. Just changed the vector in question to the new one populated by the polygons defined in the editor.

Next up, I need to have each shape generate a bounding rectangle for itself so I can early-out and avoid a SAT when two shape's AABBs don't intersect.

That will be easier than in the last project since shapes don't (currently) rotate. As long as GetAABB() or whatever is a method, if I do have rotating shapes I can regenerate the AABB when they rotate if I need to later.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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