From 2812e9eef33570e415c99e382f8eaf2fe2f6af60 Mon Sep 17 00:00:00 2001 From: Dado Sutter Date: Sun, 8 Nov 2009 01:03:37 +0000 Subject: [PATCH] Randomize seed on start now depends on user time delay Longer screen power off delay at the end --- romfs/pong.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/romfs/pong.lua b/romfs/pong.lua index 242dcdc9..00a9fda8 100644 --- a/romfs/pong.lua +++ b/romfs/pong.lua @@ -243,10 +243,9 @@ upload_items() lm3s.disp.init( 1000000 ) tmr.start( tmr_id ) ---menu() -math.randomseed( tmr.read( tmr_id ) ) -- If you use the menu function, the time will be used as a seed to the random function ---tmr.stop( tmr_id ) - +lm3s.disp.print( "Pls press SELECT -->", 0, 34, 12 ) +while not kit.btn_pressed( kit.BTN_SELECT ) do end -- Random init delay to randomsee +math.randomseed( tmr.read( tmr_id ) ) collectgarbage( "collect" ) -- GAME START @@ -272,6 +271,7 @@ repeat draw_wall( canvas.x ) draw_paddle( paddle.y, 11, 0 ) + local stop_playing = true while ( true ) do for i = 0, 1 do update_paddle_pos() @@ -316,14 +316,12 @@ repeat lm3s.disp.print( "Your score was "..tostring( score ), 15, 40, 11 ) lm3s.disp.print( "Highscore: "..tostring( highscore ), 15, 50, 11 ) lm3s.disp.print( "SELECT to restart", 6, 70, 11 ) - enough = true - for i=1, 100000 do + for i=1, 1000000 do if kit.btn_pressed( kit.BTN_SELECT ) then - enough = false + stop_playing = false break end end -until ( enough ) +until (stop_playing) lm3s.disp.off() -lm3s.disp.init( 1000000 )