Personal tools
You are here: Home Downloads Etc Ballance.PIE
Navigation
Log in


Forgot your password?
New user?
Google AdSense
 
Document Actions

Ballance.PIE

by Paul Kieper last modified 2008-12-14 13:26

GlovePIE script for using Nintendo Wii remote with Ballance computer game. Written by Carl Kenner.

Check out this video to see the script in action.  Ballance can be downloaded here.  GlovePIE can be downloaded here.


// Ballance script (http://www.ballance.org/download.htm)
// Hold wiimote with D-Pad to the left and buttons facing up
// Tilt wiimote to tilt the level
// D-Pad to rotate level 90 degrees, or zoom out
// A = Enter ("Return")
// Plus = Exit tutorial (Q)
// Home = Menu (Escape)
// By Carl Kenner
Var.DeadZone = 26%
Var.FullAngle = 17 degrees
Var.PreventExtraTilt = true
Pie.FrameRate = 60 Hz

// Type your program here, or click the GUI tab to autogenerate it!
var.IRJoyX = DeadZone(MapRange(Wiimote1.Pitch+Wiimote2.Pitch, -var.FullAngle,var.FullAngle, -1,1), var.DeadZone)
var.IRJoyY = DeadZone(MapRange(-Wiimote1.Roll-Wiimote2.Roll, -var.FullAngle,var.FullAngle, -1,1), var.DeadZone)
var.Aiming = not Shift

if var.PreventExtraTilt then
  var.IRJoyX = EnsureRange(var.IRJoyX, -1,1)
  var.IRJoyY = EnsureRange(var.IRJoyY, -1,1)
end if

// Additional aiming controls, for example if you want to also use the
// joystick to aim
var.OtherJoyX = Int(Wiimote.Down)+Int(Wiimote2.Down)-Int(Wiimote.Up)-Int(Wiimote2.Up)
var.OtherJoyY = 0

if var.Aiming then
  var.jx = Var.OtherJoyX + var.IRJoyX + var.LeftOverX
  var.jjx = Var.OtherJoyX + var.IRJoyX + var.jLeftOverX
  var.jy = Var.OtherJoyX + var.IRJoyY + var.LeftOverY
  var.jjy = Var.OtherJoyX + var.IRJoyY + var.jLeftOverY
else
  var.jx = Var.OtherJoyX + var.LeftOverX
  var.jjx = Var.OtherJoyX + var.jLeftOverX
  var.jy = Var.OtherJoyX + var.LeftOverY
  var.jjy = Var.OtherJoyX + var.jLeftOverY
end if

if var.jx > 1 then
  var.LeftOverX = Var.jx - 1
  var.jLeftOverX = Var.jjx - 1
  var.LeftKey = false
  var.RightKey = true
else if var.jx < -1 then
  var.LeftOverX = Var.jx + 1
  var.jLeftOverX = Var.jjx + 1
  var.RightKey = false
  var.LeftKey = true
else
  var.LeftOverX = Var.jx
  var.jLeftOverX = 0
  var.LeftKey = false
  var.RightKey = false
end if

if var.jy > 1 then
  var.LeftOverY = Var.jy - 1
  var.jLeftOverY = Var.jjy - 1
  var.UpKey = false
  var.DownKey = true
else if var.jy < -1 then
  var.LeftOverY = Var.jy + 1
  var.jLeftOverY = Var.jjy + 1
  var.DownKey = false
  var.UpKey = true
else
  var.LeftOverY = Var.jy
  var.jLeftOverY = 0
  var.UpKey = false
  var.DownKey = false
end if
var.PPJoyX = EnsureRange(var.jjx, -1, 1)
var.PPJoyY = EnsureRange(var.jjy, -1, 1)

// Move this block to the bottom of the script for better performance
// Digital controls for vertical aiming
Key.Up = var.UpKey
Key.Down = var.DownKey
// Digital controls for horizontal aiming
Key.Left = var.LeftKey
Key.Right = var.RightKey
// Analog controls for vertical aiming
//PPJoy.Analog0 = var.PPJoyX
// Analog controls for horizontal aiming
//PPJoy.Analog1 = var.PPJoyY

debug = var.IRJoyX+', '+var.IRJoyY
Key.Shift = Wiimote.Up or Wiimote2.Up or Wiimote.Down or Wiimote2.Down or Wiimote.Two or Wiimote2.Two
Esc = Wiimote.Home or Wiimote2.Home
StopScript = DoubleClicked(Wiimote.Home) or DoubleClicked(Wiimote2.Home)
Q = Wiimote.Plus or Wiimote2.Plus
Enter = Wiimote.A or Wiimote2.A
Space = Wiimote.One or Wiimote2.One or Wiimote.Left or Wiimote2.Left

tweet tweet
 

Powered by Plone, the Open Source Content Management System