PDA

View Full Version : Wiimote Laser Tag



wraggster
January 25th, 2007, 23:23
via carlkenner (http://www.wiili.org/forum/wiimote-laser-tag-t1196.html#7369)

I made a GlovePIE Skirmish game that you can play away from the computer.

You need:
* Two wireless sensor bars (or TV remotes or candles or whatever generates infra-red). Each person must wear one on their body somewhere so it won't fall off or break if they run around.
* Two Wii remotes
* One reasonably fast computer with Windows and a Bluetooth adapter with the two wiimotes connected.
* GlovePIE 0.29
* a friend
* A space where you can run around and shoot at each other, that is in range.
* The following GlovePIE script.

Instructions:

Each player puts on their wireless "sensor bar" and switches it on, and they pick up their connected wiimote. Then they press "Run" on the script. Then it will warn you that you have 10 seconds before the game will start. So run and get into position.

After the 5 seconds your weapon will start to charge up. When your weapon is charging it will beep five times then make a sound and vibrate which indicates that it is ready. Also the LEDs will come on one at a time while it is charging.

The lights on your weapon will be on when your weapon is charged and ready to fire. You can also check whether you are player 1 or player 2 by holding the A button. Or you can check player 1's score by holding the 1 button, or you can check player 2's score by holding the 2 button. It stops counting once it gets to 10.

You can shoot with the B button. The default maximum firing rate is five rounds per second, but you can change that at the top of the script. It will make a sound and vibrate when you shoot. If you hit the opponent then their remote will make a loud noise and power down for 7 seconds. Their weapon will beep very quietly while it charges up again. They can't shoot during that time, and they can't be shot again either.

The score will also be shown in the debug box on the screen, if you don't want to check it with the 1 or 2 button.

Code Via Comments, Use with Glovepie (http://wii-news.dcemu.co.uk/glovepie-0-29-speaker-auto-pair-classic-tray-icon-etc--47934.html)

wraggster
January 25th, 2007, 23:24
heres the code


Code:
// Laser Skirmish Script
// By Carl Kenner
//
// Set master volume to between 0% and 100%
var.GameVolume = 50%
// Set time it takes to reload to whatever you want
var.ReloadTime = 200ms

if not var.Initialized then
var.Player1disabled = true
var.Player2disabled = true
var.BeepVolume = 40%
Say("Skirmish will begin in 10 seconds")
Wait 3 seconds
Say("Ten")
Wait 1 second
Say("Nine")
Wait 1 second
Say("Eight")
Wait 1 second
Say("Seven")
Wait 1 second
Say("Six")
Wait 100 ms
var.Player1Starting = true
var.Player2Starting = true
Wait 900 ms
//Say("Five")
Wait 1 second
//Say("Four")
Wait 1 second
//Say("Three")
Wait 1 second
//Say("Two")
Wait 1 second
//Say("One")
Wait 1 second

Wait 1 second
var.BeepVolume = 2%
var.Initialized = true
end if

var.player1targeted = (Wiimote2.dot1vis or Wiimote2.dot2vis) and (not var.Player1disabled)
var.player2targeted = (Wiimote1.dot1vis or Wiimote1.dot2vis) and (not var.Player2disabled)

var.player1reloading = keepdown(pressed(var.player1shooting), var.ReloadTime)
var.player1shooting = Wiimote1.B and (not var.player1reloading) and (not var.player1disabled)

var.player2reloading = keepdown(pressed(var.player2shooting), var.ReloadTime)
var.player2shooting = Wiimote2.B and (not var.player2reloading) and (not var.player2disabled)

if Wiimote1.A then
Wiimote1.leds = 1
else if Wiimote1.One then
Wiimote1.Led1 = var.Player1Frags=1 or var.Player1Frags=5 or var.Player1Frags=8 or var.Player1Frags>=10
Wiimote1.Led2 = var.Player1Frags=2 or var.Player1Frags=6 or var.Player1Frags>=9
Wiimote1.Led3 = var.Player1Frags=3 or var.Player1Frags>=7
Wiimote1.Led4 = var.Player1Frags>=4
else if Wiimote1.Two then
Wiimote1.Led1 = var.Player2Frags=1 or var.Player2Frags=5 or var.Player2Frags=8 or var.Player2Frags>=10
Wiimote1.Led2 = var.Player2Frags=2 or var.Player2Frags=6 or var.Player2Frags>=9
Wiimote1.Led3 = var.Player2Frags=3 or var.Player2Frags>=7
Wiimote1.Led4 = var.Player2Frags>=4
else if not var.player1disabled then
Wiimote1.leds = 15 * (1-int(var.player1reloading))
end if
if Wiimote2.A then
Wiimote2.leds = 2
else if Wiimote2.One then
Wiimote2.Led1 = var.Player1Frags=1 or var.Player1Frags=5 or var.Player1Frags=8 or var.Player1Frags>=10
Wiimote2.Led2 = var.Player1Frags=2 or var.Player1Frags=6 or var.Player1Frags>=9
Wiimote2.Led3 = var.Player1Frags=3 or var.Player1Frags>=7
Wiimote2.Led4 = var.Player1Frags>=4
else if Wiimote2.Two then
Wiimote2.Led1 = var.Player2Frags=1 or var.Player2Frags=5 or var.Player2Frags=8 or var.Player2Frags>=10
Wiimote2.Led2 = var.Player2Frags=2 or var.Player2Frags=6 or var.Player2Frags>=9
Wiimote2.Led3 = var.Player2Frags=3 or var.Player2Frags>=7
Wiimote2.Led4 = var.Player2Frags>=4
else if not var.player2disabled then
Wiimote2.leds = 15 * (1-int(var.player2reloading))
end if

var.player1hit = var.player2shooting and var.player1targeted
var.player2hit = var.player1shooting and var.player2targeted

if var.player1shooting but not var.player2hit then
Wiimote1.volume = 120% * var.GameVolume
Wiimote1.frequency = 300 Hz
Wiimote1.rumble = true
wait 100 ms
Wiimote1.rumble = false
Wiimote1.frequency = 400 Hz
wait 50 ms
Wiimote1.frequency = 0
end if

if var.player2shooting but not var.player1hit then
Wiimote2.volume = 120% * var.GameVolume
Wiimote2.frequency = 300 Hz
Wiimote2.rumble = true
wait 100 ms
Wiimote2.rumble = false
Wiimote2.frequency = 400 Hz
wait 50 ms
Wiimote2.frequency = 0
end if

if var.player1hit then
Inc(var.Player2Frags)
var.player1disabled = true
Wiimote1.volume = 200% * var.GameVolume
Wiimote1.frequency = 500 Hz
Wiimote1.rumble = true
wait 200 ms
Wiimote1.leds = 1+2+4
Wiimote1.frequency = 400 Hz
wait 200 ms
Wiimote1.leds = 1+2
Wiimote1.frequency = 300 Hz
wait 200 ms
Wiimote1.leds = 1
Wiimote1.frequency = 200 Hz
wait 200 ms
Wiimote1.leds = 0
Wiimote1.frequency = 100 Hz
wait 200 ms
Wiimote1.frequency = 0
Wiimote1.rumble = false
var.Player1Starting = true
end if

if var.Player1Starting then
var.Player1Starting = false
Wiimote1.volume = var.BeepVolume * var.GameVolume
wait 1 second
// 1 second beep
Wiimote1.frequency = 1600 Hz
wait 100 ms
Wiimote1.frequency = 0
wait 900 ms
// 2 seconds beep
Wiimote1.leds = 1
Wiimote1.frequency = 1600 Hz
wait 100 ms
Wiimote1.frequency = 0
wait 900 ms
// 3 seconds beep
Wiimote1.leds = 1+2
Wiimote1.frequency = 1600 Hz
wait 100 ms
Wiimote1.frequency = 0
wait 900 ms
// 4 seconds beep
Wiimote1.leds = 1+2+4
Wiimote1.frequency = 1600 Hz
wait 100 ms
Wiimote1.frequency = 0
wait 900 ms
// 5 seconds beep
Wiimote1.leds = 1+2+4+8
Wiimote1.frequency = 1600 Hz
wait 100 ms
Wiimote1.frequency = 0
wait 900 ms
Wiimote1.volume = 25% * var.GameVolume
Wiimote1.frequency = 100 Hz
Wiimote1.rumble = true
wait 100 ms
Wiimote1.frequency = 200 Hz
wait 100 ms
Wiimote1.frequency = 300 Hz
wait 100 ms
Wiimote1.frequency = 400 Hz
wait 100 ms
Wiimote1.frequency = 500 Hz
wait 100 ms
Wiimote1.frequency = 0
Wiimote1.rumble = false
var.Player1disabled = false
end if

if var.player2hit then
Inc(var.Player1Frags)
var.player2disabled = true
Wiimote2.volume = 200% * var.GameVolume
Wiimote2.frequency = 500 Hz
Wiimote2.rumble = true
wait 200 ms
Wiimote2.leds = 1+2+4
Wiimote2.frequency = 400 Hz
wait 200 ms
Wiimote2.rumble = false
Wiimote2.leds = 1+2
Wiimote2.frequency = 300 Hz
wait 200 ms
Wiimote2.leds = 1
Wiimote2.frequency = 200 Hz
wait 200 ms
Wiimote2.leds = 0
Wiimote2.frequency = 100 Hz
wait 200 ms
Wiimote2.frequency = 0
var.player2starting = true
end if

if var.player2starting then
var.player2starting = false
Wiimote2.volume = var.BeepVolume * var.GameVolume
wait 700 ms
// 1 second beep
Wiimote2.frequency = 1600 Hz
wait 100 ms
Wiimote2.frequency = 0
wait 900 ms
// 2 seconds beep
Wiimote2.leds = 1
Wiimote2.frequency = 1600 Hz
wait 100 ms
Wiimote2.frequency = 0
wait 900 ms
// 3 seconds beep
Wiimote2.leds = 1+2
Wiimote2.frequency = 1600 Hz
wait 100 ms
Wiimote2.frequency = 0
wait 900 ms
// 4 seconds beep
Wiimote2.leds = 1+2+4
Wiimote2.frequency = 1600 Hz
wait 100 ms
Wiimote2.frequency = 0
wait 900 ms
// 5 seconds beep
Wiimote2.leds = 1+2+4+8
Wiimote2.frequency = 1600 Hz
wait 100 ms
Wiimote2.frequency = 0
wait 900 ms
Wiimote2.volume = 25% * var.gamevolume
Wiimote2.frequency = 100 Hz
Wiimote2.rumble = true
wait 100 ms
Wiimote2.frequency = 200 Hz
wait 100 ms
Wiimote2.rumble = false
Wiimote2.frequency = 300 Hz
wait 200 ms
Wiimote2.frequency = 400 Hz
wait 200 ms
Wiimote2.frequency = 500 Hz
wait 200 ms
Wiimote2.frequency = 0
Wiimote2.rumble = false
var.Player2disabled = false
end if

debug = Wiimote1.Battery+', '+Wiimote2.battery+ ' Score: Player1 = '+var.Player1Frags+', Player2 = '+var.Player2Frags

pubjoe
January 26th, 2007, 00:49
What a great idea. Reading that put a great stupid grin on my face.

curt_grymala
January 26th, 2007, 02:18
You need:
* Two wireless sensor bars (or TV remotes or candles or whatever generates infra-red). Each person must wear one on their body somewhere so it won't fall off or break if they run around.


Now there's a good idea. :thumbup:

mickshake
January 26th, 2007, 19:45
hahaha! candles?!

can i just set myself on fire? will that count as a sensor?

Jack_Skellington
January 26th, 2007, 19:50
hahaha! candles?!

can i just set myself on fire? will that count as a sensor?

lol, the candles are to be unlit

AtariFreek
January 26th, 2007, 22:54
Actually it call for the candle to bet lit. :rofl: