Code: Select all
function CheckCollision(x1, y1, w1, h1, x2, y2, w2, h2)
if x1 > (x2 + w2) or (x1 + w1) < x2 then return false end
if y1 > (y2 + h2) or (y1 + h1) < y2 then return false end
return true
end
Code: Select all
function CheckCollision(x1, y1, w1, h1, x2, y2, w2, h2)
if x1 > (x2 + w2) or (x1 + w1) < x2 then return false end
if y1 > (y2 + h2) or (y1 + h1) < y2 then return false end
return true
end
The function detects the rectangle collision, it doesn't make them. Check the .love i attached, It shows how to use the function. I added some comments to clarify the code.Pigzo wrote:I Can Read this Codebut dunno where are the rectangles? xDCode: Select all
function CheckCollision(x1, y1, w1, h1, x2, y2, w2, h2) if x1 > (x2 + w2) or (x1 + w1) < x2 then return false end if y1 > (y2 + h2) or (y1 + h1) < y2 then return false end return true end
This can't be that hard to understand. The function takes 8 parameters.Pigzo wrote:Does it check automatically?
Code: Select all
function CheckCollision([b]x1, y1, w1, h1, x2, y2, w2, h2[/b])
if x1 > (x2 + w2) or (x1 + w1) < x2 then return false end
if y1 > (y2 + h2) or (y1 + h1) < y2 then return false end
return true
end
Try this: viewtopic.php?f=5&t=3605Pigzo wrote:Whats the Easiest Game i can made?
Users browsing this forum: No registered users and 3 guests