SOLVED Collision help!

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
MysticPing2
Prole
Posts: 33
Joined: Tue Dec 10, 2013 7:08 pm

SOLVED Collision help!

Post by MysticPing2 »

So i am trying to make something happen when this spaceship hits an asteroid (and make asteroids kill eachother if they hit eachother) But to do this i need to detect colissions, and i have tried this, many, many times in different ways. Now i give up.

The current method of collision is in src/Starship.lua
(which does not work properly at all)
Attachments
As'Destroyeds.love
(45.68 KiB) Downloaded 118 times
Last edited by MysticPing2 on Sun Jan 12, 2014 1:50 pm, edited 1 time in total.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Collision help!

Post by micha »

You forgot height and width of the astroids. This is your code:

Code: Select all

if starship.x <= v.x and v.x >= starship.x + starship.width and starship.y >= v.y and v.y <= starship.y + starship.height then
this is how it should be (I also reversed some of the comparisons):

Code: Select all

if starship.x <= v.x + v.width and v.x <= starship.x + starship.width and starship.y <= v.y + v.height and v.y <= starship.y + starship.height then
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest