From WiiLi
//BUTTON RACE GAME [by marsuten @gmail.com]
//2 players (or 1). Push fast your button to win. Enable volume
//Enjoy!
**********************************************************************
var.time = 5 //Time in seconds
**********************************************************************
var.1plyr = wiimote1.A //Button player 1
var.2plyr = wiimote2.A //Button player 2
**********************************************************************
//Start and Reset
if var.begin= false then
var.count1=0
var.count2=0
var.1plyr=false
var.2plyr=false
var.top="none"
var.end2=false
var.race=0
var.1pcount=0
var.2pcount=0
var.waitcount=0
var.end=0
var.say=0
wiimote2.leds=0
wiimote1.leds=0
debug='press Enter or A'
endif
//Countdown to start
if (key.enter or wiimote1.A or wiimote2.A) and var.begin=false then
var.begin= true
say "3!"
wiimote1.Leds=7
wiimote2.Leds=7
debug="{O} {O} {O}"
wait 1 s
say "2!"
wiimote1.Leds=3
wiimote2.Leds=3
debug="{O} {O}"
wait 1 s
say "1!"
wiimote1.Leds=1
wiimote2.Leds=1
debug="{O}"
wait 1 s
say "GO!"
wiimote1.Leds=15
wiimote2.Leds=15
wiimote1.rumble=1
wiimote2.rumble=1
debug="------GO-------"
wait 500ms
wiimote1.Leds=0
wiimote2.Leds=0
wiimote1.rumble=0
wiimote2.rumble=0
var.race = true
endif
//Championship
if var.race = true and var.begin=true
if var.top="none" then
var.top=var.time
endif
debug ="[ player 1 -> "+ var.1pcount + " ] [ player 2 -> " + var.2pcount +" ] " + ' [ ' + var.top + ' ]'
var.waitcount = var.waitcount + 0.03 //adjust this if time go slow or fast
var.top= var.time - var.waitcount
endif
//Player 1
if Pressed(HeldDown(var.1plyr, 0 ms)) and var.race = true and var.begin=true
var.1pcount = var.1pcount+1
var.count1 = var.count1+1
if var.count1 = 6 then
var.count1=1
endif
if var.count1=1 then
wiimote1.Leds=1
endif
if var.count1=2 then
wiimote1.Leds=2
endif
if var.count1=3 then
wiimote1.leds=4
endif
if var.count1=4 then
wiimote1.Leds=8
endif
if var.count1=5 then
wiimote1.Leds=15
endif
endif
//Player 2
if Pressed(HeldDown(var.2plyr, 0 ms)) and var.race = true and var.begin=true
var.2pcount = var.2pcount+1
var.count2 = var.count2+1
if var.count2 = 6 then
var.count2=1
endif
if var.count2=1 then
wiimote2.Leds=1
endif
if var.count2=2 then
wiimote2.Leds=2
endif
if var.count2=3 then
wiimote2.leds=4
endif
if var.count2=4 then
wiimote2.Leds=8
endif
if var.count2=5 then
wiimote2.Leds=15
endif
endif
//Waiting to results
if var.top<=0 and var.begin=true and var.end=false then
say "STOP!"
wiimote1.leds=0
wiimote2.leds=0
wiimote1.rumble=1
wiimote2.rumble=1
var.race = false
wait 270 ms
debug="*** STOP *** [> ]"
wiimote1.rumble=0
wiimote2.rumble=0
wait 270 ms
debug="*** STOP *** [-> ]"
wait 270 ms
debug="*** STOP *** [--> ]"
wait 270 ms
debug="*** STOP *** [---> ]"
wait 270 ms
debug="*** STOP *** [----> ]"
wait 270 ms
debug="*** STOP *** [-----> ]"
wait 270 ms
debug="*** STOP *** [------> ]"
wait 270 ms
debug="*** STOP *** [-------> ]"
wait 270 ms
debug="*** STOP *** [-------->]"
wait 270 ms
debug="*** STOP *** [-------->]"
var.end = true
endif
//Results
if var.end=true and var.begin=true then
if var.1pcount >= var.2pcount then
var.player1=true
var.dif=var.1pcount-var.2pcount
else
var.player1=false
endif
if var.1pcount <= var.2pcount then
var.player2=true
var.dif=var.2pcount-var.1pcount
else
var.player2=false
endif
if var.1pcount == var.2pcount then
var.stale=true
else
var.stale=false
endif
var.end2=true
endif
//Show the results
if var.end2 = true and var.player1=true and var.player2=false and var.begin=true then
debug ="[ player 1 -> "+ var.1pcount + " ] [ player 2 -> " + var.2pcount +" ] "+ " Player 1 wins by "+var.dif+" points [A to Reset]"
wiimote1.leds=15
wait 200 ms
wiimote1.leds=0
wait 200 ms
endif
if var.end2 = true and var.player2=true and var.player1=false and var.begin=true then
debug ="[ player 1 -> "+ var.1pcount + " ] [ player 2 -> " + var.2pcount +" ] " + " Player 2 wins by "+var.dif+" points [A to Reset]"
wiimote2.leds=15
wait 200 ms
wiimote2.leds=0
wait 200 ms
endif
if var.end2=true and var.stale=true and var.begin=true then
debug ="[ player 1 -> "+ var.1pcount + " ] [ player 2 -> " + var.2pcount +" ] " + " Tie [A to Reset]"
endif
//Say the results
if var.say=0 and var.end2=true and var.begin=true then
if var.player1=true and var.player2=false then
say "player one, wins, by"+var.dif+" points!"
var.say=1
endif
if var.player1=false and var.player2=true then
say "player two, wins, by"+var.dif+" points!"
var.say=1
endif
if var.stale=true
say "tie!"
var.say=1
endif
endif
//Reset
if Pressed(HeldDown(key.enter or wiimote1.A or wiimote2.A, 0 ms)) and var.end2=true and var.begin=true then
var.begin=false
endif