GlovePIE: MotoGP

From WiiLi

Jump to: navigation, search


//MotoGP style games script v2.0 [by marsuten  @gmail.com]

/* Requires PPJoy and Nunchuk. ENJOY!

* Hold the Wii remote with the right hand, the buttons facing up and
* the nunchuk connector on the left, this will be the accelerator of
* the motorcycle. On the other hand take the nunchuck horizontally
* covering C Z buttons. Think that you have the handlebars of the
* bike in your hands. Steering must be done at once with the nunchuck
* and wiimote. The wiiremote's buttons are mapped from button 1 to
* button 14, set them up however you like in the game.
                                _________________________________
      _________ ___            | o   Wiimote   O     ___         |
  ___/         /   \      ____|| o  ,-, ,-,    _    /   \  __|__ |
 /  | Nunchuk |  +  |    /    || o  `-` `-`         \___/    |   |
 |   \_________\___/    /      |_o_____________O_________________|
 \_____________________/

* -----If you dont have the PPJoy configured :
* 0. Download last PPJoy and install it :D
* 1. In GlovePIE, go to CP-Settings > PPJoy.
* 2. Click on Add, then select "Constoller 1".
* 3. Select "PPJoy Virtual Joystick 1" and click Mapping.
* 4. Choose "Set a custom mapping..." and click Next.
* 5. Select 2 Axes and 14 Buttons, then click Next.
* 6. Click Next again.
* 7. Set Button1 to "Digital 1", Button2 to "Digital 2", etc.,
*    then click next.
* 8. Click finish. -John Doe instructions
*/

//Variables  (use Debug ,wide window)
var.trimZ = -9      //RawZ Wiimote face-up
var.trimX = 15      //RawX Wiimote face-up
var.trimXmax = 75   //RawX Wiimote right side

//PPjoy mapping
ppjoy2.Analog0=-var.an0
ppjoy2.Analog1=var.an1

ppjoy2.digital1 = Wiimote.A
ppjoy2.digital2 = Wiimote.B

ppjoy2.digital3 = Wiimote.Minus
ppjoy2.digital4 = Wiimote.Home
ppjoy2.digital5 = Wiimote.Plus

ppjoy2.digital6 = Wiimote.One
ppjoy2.digital7 = Wiimote.Two

ppjoy2.digital8 = (-1.2 < nunchuk.Joyx < -0.7)
ppjoy2.digital9 = (0.7 < nunchuk.Joyx < 1.2)
ppjoy2.digital10 = (-1.2 < nunchuk.Joyy < -0.7)
ppjoy2.digital11 = (0.7 < nunchuk.Joyy < 1.2)

ppjoy2.digital12 = Nunchuk.ZButton
ppjoy2.digital13 = Nunchuk.CButton

//Menu
key.up= wiimote.left
key.down= wiimote.right
key.right = wiimote.Up
key.left = wiimote.Down

Key.Enter = Wiimote.Nunchuk.ZButton
Key.Backspace = Wiimote.Nunchuk.CButton
key.escape = wiimote.Home

//Analogs
var.an0=(MapRange(Wiimote.RawForceZ - var.trimz, -27 , 27, -1, 1)+MapRange(nunchuk.rawforcez, -38 , 35, -1, 1))/2
var.an1=maprange(wiimote.SmoothRoll,var.trimX,var.trimXmax,0,-1,1)
if var.an1<-1 then var.an1=-1 elseif var.an1>0 then var.an1=0

//Debug
if true
wait 200 ms
debug="[Wiimote face-up:  var.trimZ = "+wiimote.RawForceZ+"  var.trimX = "+removeunits(wiimote.smoothroll)+" ][Wiimote right side:  var.trimXmax = "+removeunits(wiimote.SmoothRoll)+"]"
endif

//LEDs acceleration indicator; rumbling at max
if var.an1 =0 then wiimote.Leds=0
if var.an1 <= -0.01 and >=-0.35  then wiimote.Leds=8
if var.an1 <= -0.35 and >=-0.52  then wiimote.Leds=12
if var.an1 <= -0.52 and >=-0.78  then wiimote.Leds=14
if var.an1 <= -0.78 and >= -0.98  then wiimote.Leds=15
if var.an1 <= -0.97 and >= -1  then
wait 90 ms
wiimote.Leds=0
wait 90 ms
wiimote.Leds=15
wiimote.rumble= false
wait 40 ms
wiimote.rumble = true
wait 45 ms
wiimote.rumble = false
endif
Personal tools