Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I need some help with timers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ziozio123




PostPosted: Thu Jan 08, 2009 11:21 am   Post subject: I need some help with timers

My game is about half done right now, Basically its a timed quiz that you race against predetermined times to score 1st place - In otherwords you need to answer the questions correctly and try your best to get the best speed. Now I understand that there are only 2 questions being displayed on images right now but that really isnt the issue. I need to figure out a way to have a timer running in the background of the game, that lets the game go as it would normally but ends right when you answer the last question - then that time would be recorded and posted on a leaderboard ;]


Quote:


setscreen ("graphics:640:480")
var font : int
var x: int := 1
var name2 : string
var total : real := 0
var input, input2, input3, input4, input5, input6, input7, input8, input9, input10 : int


proc music
Music.PlayFile ("Prodigy_-_10_-_You_Will_Be_Under_My_Wheels.MP3")
end music

proc game
drawfill (0, 0, 255, 20)
Pic.ScreenLoad ("Question2.JPG", 50, 2, picCopy)
get input
if input = 2 then
cls
Pic.ScreenLoad ("Question1.JPG", 50, 50, picCopy)
else
Pic.ScreenLoad ("crash1.JPG", 1, -40, picCopy)
delay (5000)
cls
Pic.ScreenLoad ("Question1.JPG", 50, 2, picCopy)
end if
get input2
if input2 = 4 then
cls
Pic.ScreenLoad ("Question3.JPG", 50, 2, picCopy)
else
Pic.ScreenLoad ("crash1.JPG", 1, -40, picCopy)
delay (5000)
cls
Pic.ScreenLoad ("Question3.JPG", 50, 2, picCopy)
end if



end game

proc help2
drawfill (0, 0, 255, 20)
Pic.ScreenLoad ("help#2.JPG", 50, 0, picCopy)
loop
var x, y, button : int
Mouse.Where (x, y, button)
if x >= 500 and x <= 640 and y >= 0 and y <= 200 and button = 1 then
game
end if
end loop
end help2

proc help1
drawfill (0, 0, 255, 20)
Pic.ScreenLoad ("help#1.JPG", 15, 0, picCopy)
loop
var x, y, button : int
Mouse.Where (x, y, button)
if x >= 550 and x <= 640 and y >= 0 and y <= 80 and button = 1 then
help2
end if
end loop
end help1


proc intro
%The intro screen
drawfill (0, 0, 255, 20)
Pic.ScreenLoad ("car1.JPG", 0, 100, picCopy)
font := Font.New ("Arial:40")
Font.Draw ("Click HERE to start!", 100, 10, font, 0)

%The mouse where command
loop
var x, y, button : int
Mouse.Where (x, y, button)
exit when x >= 200 and x <= 450 and y >= 10 and y <= 90 and button = 1
end loop
end intro

proc name
var font2 : int
font2 := Font.New ("Arial:30")
cls
drawfill (0, 0, 0, 20)
Pic.ScreenLoad ("namee.JPG", 11, 0, picCopy)
locatexy (maxx div 2, maxy div 2)
colorback (black)
color (white)
get name2
end name

proc mainpage
var font3 : int
font3 := Font.New ("Arial:30")
cls
drawfill (0, 0, 255, 20)
Pic.ScreenLoad ("mainpage1.JPG", 0, 20, picCopy)
loop
var x, y, button : int
Mouse.Where (x, y, button)
if x >= 300 and x <= 630 and y >= 10 and y <= 100 and button = 1 then
cls
game
elsif x >= 10 and x <= 200 and y >= 330 and y <= 400 and button = 1 then
cls
help1
end if
end loop
end mainpage

intro
name
mainpage

Sponsor
Sponsor
Sponsor
sponsor
andrew.




PostPosted: Thu Jan 08, 2009 4:41 pm   Post subject: RE:I need some help with timers

Look up Time.Elapsed. Time.Elapsed returns and integer with the amount of milliseconds the program has been running for. Just divide it by 1000 to get the number of seconds.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: