I am trying to find time elapsed (in seconds) since execution of the program. Should I use zmg.time or zmg.ticks?
Also, I made this code:
Code:
It seems that the zmg.ticks function does not start at 0 when the program is run?
I get output starting around 6 million....
EDIT:
OK, this code ticks about once per second, but its still pretty fast. Are we sure that it really ticks every 1/64 of a second?
Code:
Also, I made this code:
Code:
print("Chess timer starting...")
--function variables
local drawRectFill = zmg.drawRectFill
local fastCopy = zmg.fastCopy
local makeColor = zmg.makeColor
local drawPoint = zmg.drawPoint
local keyMenuFast = zmg.keyMenuFast
local clear = zmg.clear
local drawText = zmg.drawText
local keyDirectPoll = zmg.keyDirectPoll
local keyDirect = zmg.keyDirect
local floor = math.floor
local random = math.random
local time = zmg.time
local ticks = zmg.ticks
--screen vars
local LCD_SCREEN_WIDTH = 384
local LCD_SCREEN_HEIGHT = 216
local exit = 0
--game variables
local key = {F1=79, F2=69, F3=59, F4=49, F5=39, F6=29, Alpha=77, Exit=47, Optn=68, Up=28, Down=37, Left=38, Right=27}
local chesstimer = {current=0}
local color = {bg=makeColor("white"), fg=makeColor("black")}
keyDirectPoll()
--main loop
while exit~=1 do
clear()
--keys
if keyDirect(key.Exit) > 0 then exit = 1 end
chesstimer.current = ticks()
--display
drawText(1, 1, chesstimer.current, color.fg, color.bg)
fastCopy()
keyDirectPoll()
end
It seems that the zmg.ticks function does not start at 0 when the program is run?
I get output starting around 6 million....
EDIT:
OK, this code ticks about once per second, but its still pretty fast. Are we sure that it really ticks every 1/64 of a second?
Code:
local fastCopy = zmg.fastCopy
local makeColor = zmg.makeColor
local clear = zmg.clear
local drawText = zmg.drawText
local floor = math.floor
local ticks = zmg.ticks
startTime = ticks()
--main loop
while exit~=1 do
chesstimer.current = ticks() - startTime
drawText(1, 1, floor(chesstimer.current/100), color.fg, color.bg)
fastCopy()
end