DSLua Community
Welcome, Guest. Please login or register.
May 21, 2012, 08:42:35 PM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Need Help?  |  Chronometre « previous next »
Pages: [1]
Author Topic: Chronometre  (Read 1323 times)
manu62300
Waxing Crescent
**
Posts: 89



« on: July 13, 2007, 02:29:32 PM »

I seek an example for to post with the screen a chronometre with the real time ...
It can be is necessary to be useful of DSLua.Hour() or DSLua.VBlankCount() etc... for to catch a real time and made Countdown visible with the screen .
I will test like this but if somebody has an existing example that it lets it to me know .

Or i put this but it s very speed
Code:
t = 0

while true do
t = t + 1
BGBotText:PrintXY( 0,1, "Time :" .. t )
end

Thanks... Wink
« Last Edit: July 13, 2007, 04:23:25 PM by manu62300 » Logged

XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
Jeremysr
First Quarter
***
Posts: 215



WWW
« Reply #1 on: July 13, 2007, 07:49:46 PM »

On the DS there's exactly 60 VBlanks in a second (60 VBlanks = 1 second). So try this code:

Code:
t = 0

while true do
t = t + 1
BGBotText:PrintXY( 0,1, "Time :" .. t )
for wait = 1, 60 do Screen.WaitForVBL() end
end
Logged
manu62300
Waxing Crescent
**
Posts: 89



« Reply #2 on: July 15, 2007, 02:45:26 AM »

Yep a good exemple for chronometre :
Code:
SCREEN_BOTTOM   = 0
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

s = 0
d = 0
m = 0
t = 0

while true do
s = s + 1
for wait = 1, 60 do Screen.WaitForVBL() end
if s > 9 then d = d + 1 s = 0 end
if d > 5 then m = m + 1 d = 0 end
if m > 9 then t = t + 1 m = 0 end
BGBotText:PrintXY( 3,1, ""..t )
BGBotText:PrintXY( 4,1, ""..m )
BGBotText:PrintXY( 5,1, ":" )
BGBotText:PrintXY( 6,1, ""..d )
BGBotText:PrintXY( 7,1, ""..s )
end
When i put this code ,my movement sprite is slows down  Embarrassed
« Last Edit: July 16, 2007, 06:23:58 AM by manu62300 » Logged

XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
manu62300
Waxing Crescent
**
Posts: 89



« Reply #3 on: July 17, 2007, 03:57:06 AM »

New idea :
Code:
SCREEN_BOTTOM   = 0
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

mon_compteur = 0;

while true do
      mon_compteur = mon_compteur + 1;
      secondes = mon_compteur/59.8;
      BGBotText:PrintXY( 7,2, ""..secondes )         -- my real seconde --
      BGBotText:PrintXY( 7,3, ""..DSLua.Sec() )      -- for verify --
      Screen.WaitForVBL()
end

Good synchronisation ,now my secondes are with decimals ex : x,xxxxxxxxx secondes ,I will not a decimal in my chrono  Undecided how to make a whole number?
« Last Edit: July 17, 2007, 10:05:31 AM by manu62300 » Logged

XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
manu62300
Waxing Crescent
**
Posts: 89



« Reply #4 on: July 18, 2007, 09:17:05 AM »

and this :
Code:
SCREEN_BOTTOM   = 0
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

Timer = DSLua

function Timer.Do()
      mon_compteur = mon_compteur + 1
      secondes = mon_compteur/59.8
      Screen.WaitForVBL()
end

mon_compteur = 0
t = 0

while true do
t = t + 1
BGBotText:PrintXY( 0,1, "Time :" .. t )
for wait = 1, 60 do Timer.Do() end
end
Logged

XtreamLua.com
La Référence en programmation sur PSP & DS
xtreamlua.miniville.fr
Bon dev...;
Pages: [1]
« previous next »
    Jump to: