GlovePIE:Plasma Pong with the chuk

From WiiLi

Jump to: navigation, search


////Plasma Pong with the chuk v0.41

// press the home button to turn on and off
// .**. = turned off
// *..* = turned on

// press + to toggle smoothing
// longer rumble = enabled
// shorter rumble = disabled

//use the directional buttons on the wiimote to set which direction is up
// i.e. press left to make the mouse move up when you move the stick to the left





//sets the stuff only once when it starts
if not(var.initialized)then
var.dir = 0 //which direction moves the paddle, 0 for vertical and 1 for horizontal
var.reverse  = 0 // reverse the direction
var.smooth = false //should the value be smoothed?
var.range = 0.70 //how much the nunchuck stick must be deflected, zero is centered 1 is fully
pie.FrameRate = 120 //makes gpi run faster
var.initialized= true //there, no more setting those things over and over
endif

//setting which direction is up
if (wiimote.up) then
var.dir = 0
var.reverse = 0
elseif (wiimote.down) then
var.dir = 0
var.reverse = 1
elseif (wiimote.left) then
var.dir = 1
var.reverse = 0
elseif (wiimote.right) then
var.dir = 1
var.reverse = 1
endif


//pass the stick deflection to screen coordinate
if var.dir then

var.y =  ensureMapRange(Wiimote.Nunchuk.JoyX * (1 - (2*var.reverse)), -var.range, var.range,  0,Screen.Height)
else
var.y =  ensureMapRange(Wiimote.Nunchuk.JoyY * (1 - (2*var.reverse)), -var.range, var.range,  0,Screen.Height)
endif
//smooth the value, change the 15 to change how much smoother it will be,
// bigger  = more smooth but also less responsive
var.yy = smooth(var.y, 15)

if (var.enabled)then //if turned on
if (var.smooth)then //if using smoothing
mouse.CursorPosy = var.yy //set the mouse tot he smoothed position
else //otherwise
mouse.CursorPosy = var.y //sets it to the raw pos
endif
endif
// the C and the B buttons do the jet
mouse.LeftButton = wiimote.Nunchuk.CButton or wiimote.B
// the Z and the A buttons do the black hole
mouse.RightButton = wiimote.Nunchuk.zButton or wiimote.A


if (clicked(wiimote.Home)) then //if you press and release the home buttom
var.enabled= not(var.enabled) //toggle between on and off
endif
if (clicked(wiimote.Plus)) then
var.smooth = !var.smooth
endif
var.a= clicked(var.smooth)
var.b= clicked(!var.smooth)



//nifty trick to light some leds when on and others when off
wiimote.Led1 = var.enabled
wiimote.Led2 = !var.enabled
wiimote.Led3 = !var.enabled
wiimote.Led4 = var.enabled

//another trick similar in functioning, to rumble the wiimote
wiimote.Rumble = KeepDown(var.a or var.b, (.2seconds) + (.5* var.smooth))
Personal tools
Online Casino - best online casino reviews.
Facebook Developers - facebook applications, facebook developers, facebook development, social network application development and viral widget social media strategy