Collision? How?!

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.
Pigzo
Prole
Posts: 17
Joined: Mon Apr 09, 2012 8:49 pm

Collision? How?!

Post 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?
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Collision? How?!

Post 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?
Pigzo
Prole
Posts: 17
Joined: Mon Apr 09, 2012 8:49 pm

Re: Collision? How?!

Post by Pigzo »

Here's what i made;
Attachments
Test.love
(1.43 KiB) Downloaded 173 times
User avatar
mickeyjm
Party member
Posts: 237
Joined: Thu Dec 29, 2011 11:41 am

Re: Collision? How?!

Post 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]
Your screen is very zoomed in...
Pigzo
Prole
Posts: 17
Joined: Mon Apr 09, 2012 8:49 pm

Re: Collision? How?!

Post by Pigzo »

This is to Complicated :/ Can i Give You the Source Code and you add this for me pls? :(
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Collision? How?!

Post 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... ;)
"Docendo discimus" - Lucius Annaeus Seneca
Pigzo
Prole
Posts: 17
Joined: Mon Apr 09, 2012 8:49 pm

Re: Collision? How?!

Post by Pigzo »

._. Why i can't understand Lua/Love2D ?
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Collision? How?!

Post 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. :)
Attachments
Test.love
Basic collision example
(1.98 KiB) Downloaded 144 times
"Docendo discimus" - Lucius Annaeus Seneca
Pigzo
Prole
Posts: 17
Joined: Mon Apr 09, 2012 8:49 pm

Re: Collision? How?!

Post by Pigzo »

How can i see the code?
User avatar
Petunien
Party member
Posts: 191
Joined: Fri Feb 03, 2012 8:02 pm
Location: South Tyrol (Italy)

Re: Collision? How?!

Post 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".
"Docendo discimus" - Lucius Annaeus Seneca
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests