WARNING EXTREMELY NEW AND NEEDS HELP ON A BASIC PLATFORMER
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Thu Jun 28, 2018 9:20 pm
WARNING EXTREMELY NEW AND NEEDS HELP ON A BASIC PLATFORMER
So i'm trying to make a small program that's like the platformer in the Tutorial. But there is a drawn square in the corner and when the player square touches it an image pops up like a jumpscare. Any help towards what to do?
- BruceTheGoose
- Citizen
- Posts: 76
- Joined: Sat Sep 20, 2014 2:54 pm
Re: WARNING EXTREMELY NEW AND NEEDS HELP ON A BASIC PLATFORMER
A simple way is to check AABB collision between the player and the square.
Here is a simple general purpose AABB function you can use
Here is a simple general purpose AABB function you can use
Code: Select all
checkCollision = function(x1,y1,w1,h1,x2,y2,w2,h2)
return (x1 + w1 > x2) and (x1 < x2 + w2) and (y1 + h1 > y2) and (y1 < y2 + h2)
end
-- Here is how you would use it
if(checkCollision(...)) then
-- SCARE
end
Last edited by BruceTheGoose on Sun Jul 01, 2018 1:18 am, edited 2 times in total.
"I don't know."
-
- Prole
- Posts: 2
- Joined: Thu Jun 28, 2018 9:20 pm
Re: WARNING EXTREMELY NEW AND NEEDS HELP ON A BASIC PLATFORMER
thank you for showing me that script can you also help me with a script to make an image appear thank you
- BruceTheGoose
- Citizen
- Posts: 76
- Joined: Sat Sep 20, 2014 2:54 pm
Re: WARNING EXTREMELY NEW AND NEEDS HELP ON A BASIC PLATFORMER
Sure but I would have to see how your game is structured. Anyway, It would look something along the lines of this.tyrone8104 wrote: ↑Sun Jul 01, 2018 12:32 am thank you for showing me that script can you also help me with a script to make an image appear thank you
Code: Select all
function love.load()
scary = love.graphics.newImage("source here")
end
function love.draw()
if(checkCollision(...)) then
love.graphics.draw(scary)
end
end
checkCollision = function(x1,y1,w1,h1,x2,y2,w2,h2)
return (x1 + w1 > x2) and (x1 < x2 + w2) and (y1 + h1 > y2) and (y1 < y2 + h2)
end
"I don't know."
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 6 guests