Dynamic level editor (I post here too much)

letmethink

  • *
  • Posts: 2547
I have previously been able to create a level editor for my games. It isn't posted but uses a method very similar to how the collisions are generated in 'Greenie 2'. However, that method isn't fast enough to use while platforming. What I am attempting to create is a game where you can edit the terrain while still being able to run and jump.

I rewrote my collision system so instead of drawing all the edges it now draws the biggest rectangle it can. However I changed this to the widest rectangle (size is second factor) as I wanted the surface you walk on to be one shape (so you don't get caught walking on the edge of tiles).

Once the program has found the biggest rectangle it removes the rectangle it found and does it again. It does this until there are no tiles left and then draws the rectangles. I did originally attempt to edit the level editor I already had from Greenie 2, but it still wasn't fast enough. I tried making it so that it only recalculated around the tiles added/remove.

This is something I plan on adding sometime in the future with this dynamic editor as with many shapes on my bad netbook it becomes laggy (something I am trying to avoid).

Here is what I have so far - click on a tile to remove it, click where there isn't a tile to add it. z to enable/disable debug draw. Arrows or wasd to move.

<a href="http://lmtproductions.weebly.com/uploads/2/0/7/9/20793336/level_editor_thingy.swf" target="_blank" class="new_win">http://lmtproductions.weebly.com/uploads/2/0/7/9/20793336/level_editor_thingy.swf</a>
~Letmethink

mdotedot

  • *
  • Posts: 1492
Hi LMT,

This is really cool!

I thought from reading the text that it would be harder, but at the moment you don't have to align the actions and it is quite enjoyable.
I see a lot of potential from this mechanism! Keep it up!

Best regards from
M.E.
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Rimrook

  • *
  • Posts: 251
Really cool indeed. Smart to order the collisions the way you did. I ended up rounding the corners of most of my actors so they have a sort of minimum step height for small collisions and snags.

I'm curious how far this will go.

letmethink

  • *
  • Posts: 2547
When you add a lot of collisions with the old method (even with the different generation) it gets slower. Therefore I now present you with my idea of generating collision tiles around actors and only around actors that will collide with the floors (only the floor below the player will be generated as it moves).

<a href="http://static.stencyl.com/games/29332-0.swf" target="_blank" class="new_win">http://static.stencyl.com/games/29332-0.swf</a>
(same controls as before)

It still needs tweeking and a couple of bugs need to be fixed, but it is feeling much nicer than before - generating max 9*objects rather than 768.
~Letmethink

Alexin

  • *
  • Posts: 3132
A really smart idea that actually works. Nicely done.
"Find the fun"
alexin@stencyl.com

Photon

  • Posts: 2697
This is sick.

I noticed something though about the second method. If you take a single tile out of the top and fall into the hole, sometimes there is a very severe amount of lag while falling into the hole. Some toying around seems to reveal that tight spaces (with sporadic tiling?) makes things stutter pretty badly.

I think its worth pointing out to that this method could be worse for performance if there is a significant number of actors generating collisions on the fly. I suppose it also depends on whether you are adding shapes to and from Box2D at a frequent rate or just running custom collision code. I guess I don't know enough about either to say for sure. Nonetheless, seeing it in action is really cool.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

WayneAdams

  • Posts: 79

letmethink

  • *
  • Posts: 2547
I was working on this a bit recently and decided to dump box2d and built in physics because they didn't have the speeds to modify that I wanted.

I built my own physics engine that I will probably post at some point today. This one works fine with multiple objects

I need to work a bit on object -> object collisions for it to be more interesting.
~Letmethink

1MrPaul1

  • *
  • Posts: 1265
Built you own physics? it is very hard probably....

letmethink

  • *
  • Posts: 2547
Just for square collisions currently so it wasn't that difficult. You have to do 3 things currently. Detect if a collision will occur. Decide what will happen. Move everything so it happens.
~Letmethink

letmethink

  • *
  • Posts: 2547
Some nice progress happened:

<a href="http://lmtproductions.weebly.com/uploads/2/0/7/9/20793336/level_editor_thing.swf" target="_blank" class="new_win">http://lmtproductions.weebly.com/uploads/2/0/7/9/20793336/level_editor_thing.swf</a>

I made tiles snap nicely and ended up writing a program to arrange and create tiles from me using only 5 initial tiles
~Letmethink

1MrPaul1

  • *
  • Posts: 1265
Amazing!
Very well done letmethink!
It is almost ready meatboy :)

1MrPaul1

  • *
  • Posts: 1265
But when I making more than 20-30 new tiles, while "hero" is jumping fps drops down till 3-10 sometimes. May be because the page contains several flash windows

Alexin

  • *
  • Posts: 3132
"Find the fun"
alexin@stencyl.com

JohnyRocket

  • Posts: 29
That is magnificent! Very easy to control, and the pieces snap together rather nicely. Can't wait to see what other improvements you make  8)