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
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!
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:-
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.
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