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
ac3raven
Citizen
Posts: 60
Joined: Tue May 19, 2009 1:14 am

constricting movement

Post by ac3raven »

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:
Attachments
lvl1.png
lvl1.png (4.42 KiB) Viewed 2222 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: constricting movement

Post by bartbes »

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
CR4SH3D
Citizen
Posts: 67
Joined: Mon Mar 02, 2009 6:00 pm
Location: England
Contact:

Re: constricting movement

Post by CR4SH3D »

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
player:setX(0)
end
that wraps the movement so the player appears on the other side of the screen (like the later versions of snake on mobiles)
paclito
Prole
Posts: 35
Joined: Wed Apr 22, 2009 8:33 pm

Re: constricting movement

Post by paclito »

you can view this post:

http://love2d.org/forum/viewtopic.php?f=5&t=715

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: Bing [Bot], DOMINOSRULZ and 91 guests