Metalines

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

Metalines

Post by naughty »

I've been experimenting with pixeleffect based metalines for a roguelike game I'm working on.

The attached love file is a test bed for the metalines. The controls are printed in the top left.

It was originally based on the metaballs demo (enormous thanks to the author of that) but there's quite a few things added:
  • There's a simple macro expander for creating the pixeleffect based on http://lua-users.org/wiki/SimpleLuaPreprocessor
  • In an attempt to be more efficient and support many metalines the rendering strategy is quite different. It renders the metalines to a canvas in batches then uses the canvas as a texture for a final full window pass that adds the colour.
  • To try and minimise overdraw there's three different batching strategies; simple, Bounded Interval Hierarchy (BIH) and minarea which is loosely based on r-trees.
EDIT: Now the number of metalines drawn per batch can be changed with the left and right arrow keys.

Here's some screen shots:
gOC9q.png
gOC9q.png (92.5 KiB) Viewed 416 times
lhNIu.png
lhNIu.png (104.22 KiB) Viewed 416 times
f85tv.png
f85tv.png (102.9 KiB) Viewed 416 times
Attachments
metaline.love
(6.82 KiB) Downloaded 279 times
User avatar
ncarlson
Prole
Posts: 35
Joined: Wed Jul 20, 2011 4:00 pm

Re: Metalines

Post by ncarlson »

This is a seriously awesome demo! Thanks for sharing.
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

Re: Metalines

Post by naughty »

You're welcome.

I was surprised by some of the results while testing with this. It works by rendering batches of lines additively to a background canvas (you can change the size of the batches with the left and right arrow keys) but it always seems to be faster with smaller batches even though that require more drawing to the canvas.
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: Metalines

Post by timmeh42 »

I'd love to know how you apply this to roguelikes - unless that gives away any trade-secrets?
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

Re: Metalines

Post by naughty »

It's not a trade secret, once I've got the basics of the roguelike working I'll be posting it up here :^)

Short answer: in the screenshots above the red is the floor, the white is the walls and the blue is the solid rock the dungeon is carved out of. The thin white lines are what your @ can walk along.

Long answer: Most roguelikes take place on a grid with either 8-way or 4-way movement. There's also some 6-way hexgrid based ones and even a crazy hyperbolic plane roguelike.

I thought it would be cool to be able to do n-way movement, though I've limited it to a max of 8-way so that the usual roguelike movement controls work (hjklyubn and numpad keys). The easiest solution I could think of was a 2D graph where the points are 'tiles' and the edges between them are routes you can travel. The test data in the metalines demo, the lines in the screenshots above, are a generated level from the very early stages of coding the roguelike.

While playing around with level generation it became obvious that just looking at points and lines is a bit boring. A little green circle isn't as good as a grass tile, a bunch of blue lines doesn't look like a lake, even ASCII based roguelikes look prettier. So I needed to draw walls and floors somehow.

I had two choices either do something mesh based like Voronoi diagrams or something pixel based like metaballs/metalines. The voronoi based solution requires creating lots of extra points around the level to make the walls of the dungeon work correctly which is a pain to do well. So I started playing around with efficiently rendering metalines instead and wrote the demo in the above post.
User avatar
timmeh42
Citizen
Posts: 90
Joined: Wed Mar 07, 2012 7:32 pm
Location: Cape Town, South Africa

Re: Metalines

Post by timmeh42 »

It is a very interesting way to do rooms, but why do you need to use metalines? Surely you can just draw thick lines normally - unless you require the rounded corners?
EDIT: Must say it does give a very organic look that would be great for caves.
naughty
Prole
Posts: 8
Joined: Mon Apr 09, 2012 2:30 pm

Re: Metalines

Post by naughty »

It just looks nicer really, also having the per-pixel distance data allows for some nice effects like a lapping shoreline on a body of water.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest