constricting movement

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Posts: 55
Joined: Tue May 19, 2009 1:14 am

constricting movement

Post by ac3raven » Thu May 21, 2009 3:45 am

I have a box image, and I want to constrict the players movement to the boundries of that box. How do I do this?

More specifically, I'd like some tutorials on level design in LOVE. is it just a matter of using the draw function to put png's and gifs into the map, or what?

the game I'm attempting to make is top down. below is an image of the map I want to make in LOVE:
lvl1.png (4.42 KiB) Viewed 830 times

User avatar
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands

Re: constricting movement

Post by bartbes » Thu May 21, 2009 6:33 am

Well, it all depends on how you do it, if you're using Box2D expect a lot of work, if you aren't you just have to check if there is supposed to be something in the direction of movement (like a boundary) and just don't update the movement (so it stops). About the graphical part it's just drawing the obstacles, but it's best to have collision and images at the same positions.
If you're using Box2D, you have to update Box2D each frame (makes sense)and for every update you have you have to create a shape. (the docs are most helpful on this, I can't explain any better)

User avatar
Posts: 67
Joined: Mon Mar 02, 2009 6:00 pm
Location: England

Re: constricting movement

Post by CR4SH3D » Thu May 21, 2009 9:34 pm

the way i constricted the movement (and wrapped it) was to check if the player coordinates were greater than the game size (you use the size of the box)
for instance:

Code: Select all

if player:getX() > box:getWidth then
that wraps the movement so the player appears on the other side of the screen (like the later versions of snake on mobiles)

Posts: 35
Joined: Wed Apr 22, 2009 8:33 pm

Re: constricting movement

Post by paclito » Mon May 25, 2009 8:28 pm

you can view this post:

and see how i make the level, with mappy and tolua.lua export utility.

the boxes to constrict movement are done with the level size...

it's ok for you?

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests