Play Virtua Tennis like WiiSports!

here it is another script for play virtua tennis. remember to calibrate the wiimote as usual.. move the player with nunchuk.

————————————–

// Lotti’s Virtua Tennis Script

// X/Y offsets for Analog. If it’s too sensitive then make the numbers larger.
var.xNunchukOff = .07
var.yNunchukOff = .07

//Switch off the leds
Wiimote.leds = 0

// Motion Mouse
// Manual Configuration
// When configuring the offsets please put the wiimote flat and do not move it.
// These are offsets change them so that your debug output reads 0,28,0
// The debug output is at the top of this window.
// Ex if you get -7,33,-6 then change the offsets to 7,-5,6

var.xOffset = 5
var.yOffset = -2
var.zOffset = 4

var.xRot = Wiimote.RawForceX + var.xOffset
var.yRot = Wiimote.RawForceY + var.yOffset
var.zRot = Wiimote.RawForceZ + var.zOffset

debug = ‘X:’ + var.xRot + ‘, ‘ + ‘Y:’ + var.yRot + ‘, ‘ + ‘Z:’ + var.zRot

// Automatic Configuration
// Simple press – and + buttons on wiimote before start playing
if Wiimote.Minus && Wiimote.Plus then
var.xOffset = -Wiimote.RawForceX
var.zOffset = -Wiimote.RawForceZ
var.yOffset = -Wiimote.RawForceY + 28
debug = debug + ‘ Autocalibration’
endif

//
// Game buttons.
//

key.Enter = Wiimote.Home
key.a = Wiimote.A
key.s = Wiimote.B
key.a = Wiimote.Nunchuk.ZButton

key.Tab = Wiimote.One
key.Space = Wiimote.Two

//
// Analog Movements
//

if Wiimote.Nunchuk.JoyX < -var.xNunchukOff then
key.Left = true
else key.Left = false
endif
if Wiimote.Nunchuk.JoyX > var.xNunchukOff then
key.Right = true
else key.Right = false
endif
if Wiimote.Nunchuk.JoyY < -var.yNunchukOff then
key.Up = true
else key.Up = false
endif
if Wiimote.Nunchuk.JoyY > var.yNunchukOff then
key.Down = true
else key.Down = false
endif

//
// Wiimote Movements
//

if abs(var.zRot) >= 20 && var.yRot >= 20 && var.yRot <= 35 then // For Forehand/Backhand
key.a = true
Wiimote.Rumble = True
Wait abs(var.zRot) ms
Wiimote.Rumble = False
key.a = false
endif
if var.yRot >= 50 && var.zRot >= -5 && var.zRot <= 5 then // For Lob
key.s = true
Wiimote.Rumble = True
Wait var.yRot-25 ms
Wiimote.Rumble = False
key.s = false
endif

2 thoughts on “Play Virtua Tennis like WiiSports!

  1. A

    Lotti, when do we get a video of you playing virtual tennis with your wiimote? –gamergirl

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.