Collision (Need 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.
User avatar
Hexenhammer
Party member
Posts: 175
Joined: Sun Feb 17, 2013 8:19 am

Re: Collision (Need Help)

Post by Hexenhammer »

TheScriptan wrote:Here is .love file, maybe you can find out what is wrong with if, because still can't find it, i used rectangle object only in game.lua :(
Okay, found it (as promised! :) ).

Just change the beginning of game.lua to this:

Code: Select all

rectangle = {
		{x = 0, y = 0, w = 128, h = 128},
		{x = 400, y = 300, w = 128, h = 128}
	}

function game_load()
 -- definition of rectangle used to be here
end
I don't have time to analyze what exactly went wrong here but my spontaneous guess is that Lua thought "rectangle" is no longer needed and thus garbage collected it. I am not familiar with the garbage collection rules for globals.. because I never use them. Seriously, globals are evil, vicious beasts. Slay 'em all! :halloween:
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

What can I say, YOU ARE MY HERO! :awesome:
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

After changing that, I got another problem, I don't know how to make that rectangle a wall, what code I need to put in that If statement? :huh:
User avatar
Pash
Prole
Posts: 43
Joined: Sun Dec 30, 2012 8:04 am

Re: Collision (Need Help)

Post by Pash »

What do you mean you want to make that rectangle a wall?

I cant see your source at work but I'm assuming you are performing simple bounding boxes collision detection. There are two elements to collision detection 1) Detection (check) 2) Resolution (not sure if checked).

ie. Player is moving, check if collision is true, if true perform action:-

Code: Select all

if Check_Collision(args) then
list actions
end
An action might be to set Player.x to Player.x - 1 or something.
Sagan Interactive - Looking forward to a creative 2013.
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

What I need to do when I collide, here is my answer, when I did that player.x = player.x - 1 and for Y it just glitched out :?
User avatar
Pash
Prole
Posts: 43
Joined: Sun Dec 30, 2012 8:04 am

Re: Collision (Need Help)

Post by Pash »

Thats not an answer. You are using the example detection Resolution I gave you. Not what your desired effect is.

You need to think about these elements:-

1) What will collide with your wall.
2) What you want to happen on detection of a collision with that wall to that object.

Ohh, and telling us something has "glitched out", isnt very helpful. Post your code you have modified and even the .love file. Im still at work so I cant open the love files but still, i could take a look later if someone else doesnt.

Cheers,

Pash
Sagan Interactive - Looking forward to a creative 2013.
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

So, I made a basic collision but it is very glitchy, when i collide with the wall its start flickering and movement dont work as usual then collide, here is .love file :huh:
Attachments
Invaders Must Die.love
Hate Collision
(2.72 KiB) Downloaded 110 times
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Collision (Need Help)

Post by Zeliarden »

You should test your .love file before posting it. A .love is a renamed .zip not .rar
Last edited by Zeliarden on Fri Mar 08, 2013 10:31 pm, edited 1 time in total.
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

Tested it, same problem, and what do you mean, rar or zip. Is there any difference to compress somehow? :shock:
TheScriptan
Citizen
Posts: 56
Joined: Wed Feb 27, 2013 7:53 pm

Re: Collision (Need Help)

Post by TheScriptan »

Ohhh, I see that there is a differencem thanks for noticing that, i will readd that file right now. :crazy:
Attachments
Invaders Must Die.love
Heare
(2.92 KiB) Downloaded 76 times
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests