GlovePIE:Elma

From WiiLi

Jump to: navigation, search

deloucnav

a game that seems to work quite well with the script on the analog tilt mode is Adrenaline Challenge (in flash)

//Elma-like games witht he Wiimote
//Originally coded by TiagoTiago
//Last edited 1914-26-01-2007



// controling digital controsl as analog stuff
//press home to turn it on/off
// .**.  = off
// *..*  = on
// pitch = up/down keys
// roll = left/right keys
// B = Space (flipping on omst Elma like game)s

//basicly it pulssates the key in a velocity dependant on how much the analog control is flexed

//modes
// 0 = Wiimote straight, Pitch accelerate roll tilts
// 1 = Wiimote sideways, Roll it to acelerate and turn to tilt

var.mode= 1

// use the aceeleromters to tilt the bike? (if not you press the directional
// buttoms ont he wiimote for that purpose)
// this works better for games that have a limit on how many tilting thrusts you can give per minute
var.analogtilt= FALSE

//Roll params
var.Rnullzone= 20 degrees //how much you must turnt he control till it starts reading it
var.Rmindelay= 1 // the minimum time ebtween key taps, the fastest it will tap the keys
var.Rmaxdelay= 1000 //the max time between taps, the slowest it will tap the keys
var.Rmaxang = 80  // how much (n degrees) you must move th wiimote to reach the maximum value
var.Rangoffset= 0 //offset for the central (zero) angle
//PitchParams
var.Pnullzone= 20 degrees
var.Pmindelay= 1
var.Pmaxdelay= 1000
var.Pmaxang = 60
var.Pangoffset= 0

if (var.mode) then
if (var.analogtilt) then
var.tilt = Wiimote1.Pitch - var.Rangoffset
else  

Key.Left= Wiimote.Up
Key.Right= Wiimote.Down

endif
var.throtle= -Wiimote1.Roll  - var.Pangoffset
else
if (var.analogtilt)
var.tilt = Wiimote1.Roll  - var.Rangoffset
else
Key.Left= Wiimote.Left
Key.Right= Wiimote.Right

endif
var.throtle= Wiimote1.Pitch - var.Pangoffset
endif


if (Released(Wiimote1.Home)) then
if (var.enabled = TRUE)then
var.enabled= FALSE
else
var.enabled= TRUE
endif
endif

if (var.enabled) then
Wiimote1.Leds  = 1 + 8
if (var.analogtilt)   then
if (var.tilt< -var.Rnullzone) then

var.Lrate=MapRange(var.tilt,-var.Rmaxang, -var.Rnullzone,  var.Rmindelay , var.Rmaxdelay)

var.Lon= TRUE
var.Ron= FALSE
else
var.Lon= FALSE
Key.Left= FALSE
endif
if (var.tilt> var.Rnullzone) then

var.Rrate=  var.Rmaxdelay-  MapRange(var.tilt,var.Rnullzone, var.Rmaxang,  var.Rmindelay , var.Rmaxdelay)
var.Ron= TRUE
var.Lon= FALSE
else
var.Ron=  FALSE
Key.Right = FALSE
endif
endif

if (var.throtle> var.Pnullzone) then

var.Urate= var.Pmaxdelay-MapRange(var.throtle,var.Pnullzone, var.Pmaxang,  var.Pmindelay , var.Pmaxdelay)
var.Uon= TRUE
var.Don= FALSE
else
var.Uon= FALSE
Key.Up= FALSE
endif
if (var.throtle< -var.Pnullzone) then

var.Drate= MapRange(var.throtle,-var.Pmaxang, -var.Pnullzone,  var.Pmindelay , var.Pmaxdelay)
var.Don= TRUE
var.Uon= FALSE
else
var.Don= FALSE
Key.Down= FALSE

endif



if ((var.tilt > var.Rmaxang)or (var.tilt< -var.Rmaxang))then

Wiimote1.Rumble = TRUE
wait 20ms
Wiimote1.Rumble = FALSE
wait 150ms
Wiimote1.Rumble = TRUE
wait 30ms
Wiimote1.Rumble = FALSE
endif

if ((var.throtle > var.Pmaxang)or (var.throtle < -var.Pmaxang))then

Wiimote1.Rumble = TRUE
wait 100ms
Wiimote1.Rumble = FALSE
wait 100ms
Wiimote1.Rumble = TRUE
wait 150ms
Wiimote1.Rumble = FALSE
endif

Key.Space= Wiimote1.B

else
var.Lon= FALSE
var.Ron =FALSE
var.Uon= FALSE
var.Don= FALSE
Wiimote1.Leds= 2+4
endif

if (var.analogtilt)  then
if (var.Ron) then


Pressed(Key.Right) = true
Key.Left = false
Wait var.Rrate ms


endif

if (var.Lon)  then


Pressed(Key.Left) = true
Key.Right= False
Wait var.Lrate ms


endif
endif

if (var.Uon)   then


Pressed(Key.Up) = true
Key.Down= false
Wait var.Urate ms


endif
if (var.Don)   then


Pressed(Key.Down) = true
Key.Up= false
Wait var.Drate ms


endif
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