Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Adding a countdown timer into Dark Basic

Author
Message
Lalami1990
15
Years of Service
User Offline
Joined: 17th Jun 2009
Location:
Posted: 17th Jun 2009 16:01
Hi everyone, I have been using Dark basic for a few weeks now and I have learnt some of the basics. I created a game and I'd like to add a clock feature which would be placed on the corner of the screen counting down from a certain limit and once the clock reaches 0, the game will end but im unsure on how to use this. Any help will be much appreciated.

Thanks

BND IT Programmer
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 17th Jun 2009 17:26


LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 17th Jun 2009 18:25
If you place the CLS at the beginning of the do - loop, it should eliminate the annoying screen flicker. Also, if you move 'If CTVal = 0 then end' after the sync command, it will show 0 before it exits. You can easily position the text in the upper left corner by replacing "center text screen width()/2, screen height()/2, Str$(CTVal)" with text 0,0,Str$(CTVal).


So many games to code......so little time.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 17th Jun 2009 19:45
i know that all, but i had plenty of time and if you don't use cls, the pasted text goes all white

BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 19th Jun 2009 00:51
Quote: "i know that all, but i had plenty of time and if you don't use cls, the pasted text goes all white "

What?

Anyway, @Lalami: The timer() command is what you want. It returns the amount of time (in milliseconds) that the computer has been on. By recording the value of timer() when the game starts, you can determine how many seconds have passed since the game started by subtracting the recorded value of timer() from its current value and dividing that by 1000.



Diggsey: I have a spine and memory, but one memorable guy says he hates me. What am I?
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 19th Jun 2009 08:50
what i mean is this:

when you have this code, it works fine:



then you add screen fps after the timer print and then it goes all wrong



so you have to use the cls statement so it won't go white



or make a 3d object if you don't wanna use cls



i don't know why it can go all white, but well, it works now

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 19th Jun 2009 13:45
Actually, you don't have to make a 3D object, you can just turn the backdrop on instead.


So many games to code......so little time.
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 19th Jun 2009 15:02
o thanks, i didn't knew that!

Login to post a reply

Server time is: 2024-09-28 08:25:06
Your offset time is: 2024-09-28 08:25:06