Yes it is.Zitat:
Zitat von Glynnder
Printable View
Yes it is.Zitat:
Zitat von Glynnder
i cant display it on the screen tho.. i dunno what the variable is called, i dont really understand the linkZitat:
Zitat von head_54us
Blah = Timer.new() -- Creates a new timer object called Blah. Starts from 0
Blah:start() -- Starts the timer
NumberOfMs = Blah:time() -- Gets the number of milliseconds from the timer since the timer started + the start value
NumberOfSec = math.floor(NumberOfMs /1000) -- Converts from Ms to Secs rounded down.
thanx, so i use number of sec as the variable? and does it stop at 0?Zitat:
Zitat von head_54us
Don't copy and paste that code into your program. I only wrote it to describe how to call and use the functions. You have to apply that knowledge to your code.
timer dont count down:
Code:levelTimer = Timer.new(100000)
levelTimer:start()
red = Color.new(255,0,0)
background = Image.load("cloud.png")
smiley = Image.load("smile.png")
sad = Image.load("sad.png")
math.randomseed(os.time())
rx = math.random(0,442)
ry = math.random(0,234)
boost = 1000
score = 0
x = 0
y = 5
NumberOfMs = levelTimer:time()
NumberOfSec = math.floor(NumberOfMs/1000)
function booster()
if boost < 1 then
boost = 0
end
boost = boost - 1
end
function CheckBoxCollisionHack()
if ((x + 36) > rx) and (x < (rx + 36)) then
if ((y + 36) > ry) and (y < (ry + 36)) then
return true
end
end
return false
end
while true do
screen:clear()
screen:blit(0,0,background)
screen:print(0,263,"Press X for SPEED BOOST",red)
screen:print(0,0,"Boost Left: "..boost ,red)
screen:print(0,7,"Time: "..NumberOfSec,red)
screen:blit(x, y, smiley)
screen:blit(rx, ry, sad)
They count up. These two lines are also incorrect in terms of where you put them in your code
Code:NumberOfMs = levelTimer:time()
NumberOfSec = math.floor(NumberOfMs/1000)
how the hell do i get it to count down? i got it to count up now...Zitat:
Zitat von head_54us
Seriously, these are really simple abstract problems that you should be able to solve yourself.Code:TotalTimeLimit = 100000
-- Later on in your code
NumberOfMs = levelTimer:time()
NumberOfSec = math.floor(NumberOfMs/1000)
TimeLeft = TotalTimeLimit - NumberOfSecs
total time limit has to be 200, 10000 makes the time go to 9999 and count down.Zitat:
Zitat von head_54us
i wanted it at 100 and down
problem i solved myself :P