Page 1 of 2

Collision? How?!

Posted: Wed Apr 11, 2012 2:14 pm
by Pigzo
Hey Guys im new at Love and i wanna make a Game but now; How Can i make a Collision between a Rectangle and the Player? So that the Player can't go over the Rectangle?

Re: Collision? How?!

Posted: Wed Apr 11, 2012 2:20 pm
by kraftman
to do this, you need to check if the objects overlap, or will overlap. how much of the code have you got so far? do you have the players movement sorted out?

Re: Collision? How?!

Posted: Wed Apr 11, 2012 2:35 pm
by Pigzo
Here's what i made;

Re: Collision? How?!

Posted: Wed Apr 11, 2012 2:48 pm
by mickeyjm
Assuming the player is rectangular (or an image, which in this case can be considered the same) and grid aligned (cant rotate) try this: Derp, didnt see the download, the tutorial is what you are looking for

[url]htttp://love2d.org/wiki/Tutorial:Gridlocked_Player#Adding_collision[/url]

Re: Collision? How?!

Posted: Wed Apr 11, 2012 3:14 pm
by Pigzo
This is to Complicated :/ Can i Give You the Source Code and you add this for me pls? :(

Re: Collision? How?!

Posted: Wed Apr 11, 2012 3:30 pm
by Petunien
Are you familiar with the basics of programming/lua?
If not, just check out some tutorials and get familiarer. Then Löve2D is much easier to learn and use.

http://www.lua.org/manual/5.1/
http://lua.lickert.net/index_en.html
http://www.youtube.com/user/DevHQLesson ... ?query=lua
http://lua.gts-stolberg.de/en/index.php

Otherwise:
https://love2d.org/wiki/BoundingBox.lua

It is also complicated, I warned you. ^^

Edit: Oh, and we have the sourcecode already... ;)

Re: Collision? How?!

Posted: Wed Apr 11, 2012 3:41 pm
by Pigzo
._. Why i can't understand Lua/Love2D ?

Re: Collision? How?!

Posted: Wed Apr 11, 2012 4:03 pm
by Petunien
Study and try all. Spend time. That's it.

... I added a new rectangle. If you collide with it, a message appear. This should explain how basic collision works.
All code is commented, I hope it helps. :)

Re: Collision? How?!

Posted: Wed Apr 11, 2012 4:05 pm
by Pigzo
How can i see the code?

Re: Collision? How?!

Posted: Wed Apr 11, 2012 4:07 pm
by Petunien
Rename the "Test.love" into "Test.zip", open it with a zip-programm of your choice like WinRar, WinZip or 7-Zip and open "main.lua".