Question about walking

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
sn0wex
Prole
Posts: 4
Joined: Sat Oct 01, 2011 10:44 pm

Question about walking

Post by sn0wex »

Hai :) Started with Löve some hours ago.

Got a question. I've made a map picture with Inkscape. Now I want to ask you, how should i make the thing to be able to walk on.

It is a side scroll map, near to Maple Story's design.

Lets say we got 2 images. One is the white/violet one, the other one is the full map image, with mixed colors. If I would put the white/violet image behind the full map one, would it be possible to make the violet color something like not passable(able to walk on)? It saves a lot of work i think.

It would take a lot of time to do it with boxes and make their locations on the right spots imo... or?

any help is welcome :)
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Question about walking

Post by Taehl »

While it's possible to do that, calculating collision based on a mask (the white/violet image) would be quite slow unless you used a few crafty tricks (which I can suggest, if you like). It would be a lot faster if you made a list of line segments (which describe the shape of your terrain) and checked against them, instead. It'd be possible to automatically generate such a list of line segments from the mask image (say, when loading the level, or better yet, before distributing your game), but it'd require some rather cunning code (presumably, something along the lines of turning the mask into a point cloud, then running a convex hull algorithm over it). I guess if you didn't want to make your own physics, you could use Box2D (Love's built-in physics system) and make a complex body which has a similar shape to your terrain.

TL;DR: It's doable, but tricky.

Oh, and welcome to the forums.

EDIT) Also, it looks like Maple Story uses tiles, not a fully drawn level. Using a tile-based system is a very good idea, but it does mean your terrain can't be an arbitrary shape.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
sn0wex
Prole
Posts: 4
Joined: Sat Oct 01, 2011 10:44 pm

Re: Question about walking

Post by sn0wex »

Thanks :awesome:
User avatar
sn0wex
Prole
Posts: 4
Joined: Sat Oct 01, 2011 10:44 pm

Re: Question about walking

Post by sn0wex »

Now i've succeed at drawing multiple lines.

Those 2 are my lines:

Code: Select all

love.graphics.line(100,400, 300,400)
love.graphics.line(300,300, 400,300)
How to make them to be able to walk on? The player should be able to jump from line to line.

That's my code for the rectangle shaped part of the ground, which is on the bottom of the map. I just don't have any idea, how i should do it for lines :death:

Code: Select all

        objects.ground = {}
	objects.ground.body = love.physics.newBody(world, 800/2, 600, 0, 0)
	objects.ground.shape = love.physics.newRectangleShape(objects.ground.body, 0, 0, 800, 50, 0)
Picture:
efplV.png
efplV.png (6.3 KiB) Viewed 299 times
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Question about walking

Post by Taehl »

I see you're going the Box2D route. I'm not too well-versed with it, but if I'm not mistaken, what you need to do is create a shape that has the same size and location as each of your platforms. Then you'll need some code that moves your circle around when you press the arrow keys (or WADS, or whatever you want your controls to be). This tutorial should help you with that.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests