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)
SOLVED Collision help!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 33
- Joined: Tue Dec 10, 2013 7:08 pm
SOLVED Collision help!
- 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.
Re: Collision help!
You forgot height and width of the astroids. This is your code:
this is how it should be (I also reversed some of the comparisons):
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
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
Check out my blog on gamedev
Who is online
Users browsing this forum: No registered users and 1 guest