Timer and detecting collision? Help pls
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 1
- Joined: Tue Jul 01, 2014 10:00 am
- Location: United Kingdom
Timer and detecting collision? Help pls
So I'm making a game where you control a block and gravity changes every time love.update updates 5000 times because I don't know how to make a proper timer. Also the score is supposed to go up when the player touches a specific object. I have found some collision code but the score goes up whenever the player touches any object. My project so far is attached below, any help will be appreciated
- Attachments
-
- main.lua
- (9.67 KiB) Downloaded 117 times
Re: Timer and detecting collision? Help pls
Here is how you make a timer:
The doSomeAction()-function is called every five seconds.
Code: Select all
function love.load()
timer = 0
delayTime = 5
end
function love.update(dt)
timer = timer + dt
if timer > delayTime then
timer = timer - delayTime
doSomeAction()
end
end
Check out my blog on gamedev
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Timer and detecting collision? Help pls
You can also use a timer library like Cron to make timers easier to understand and use.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 5 guests