GlovePIE:Knytt

From WiiLi

Jump to: navigation, search

Knytt is a free PC platformer game made by Nifflas. Download here.

/*
  K N Y T T
  =========
  Game by Nifflas (http://knytt.ni2.se/)
  GlovePIE script by TylerK.

  To use this script hold the Wiimote in the classic NES controller style. It's
  recommended to go through the game's tutorial to get a feel for the gameplay.

  Wiimote              Function
  -----------------------------------------------
  2            |       Jump
  1            |       Show direction of closest item
  Plus         |       Display item checklist
  D-Pad        |       Movement

  Some very basic scripting is used to make the Wiimote rumble when you die. This
  will only work if you have the game in fullscreen mode (File -> Fullscreen).
*/

// Disable LEDs so we don't waste the battery
Wiimote.Leds = 0

// The opening menu requires use of the mouse, so a basic mouse script is included
// here. It will only function if it detects an IR dot of some kind.
var.x = ((1023-Wiimote.dot1x)/1023)*1.2-0.1
var.y = ((Wiimote.dot1y)/767)*1.2-0.1

if (Wiimote.dot1vis) then
  mouse.x = Smooth(var.x,10)
  mouse.y = Smooth(var.y,10)
  mouse.LeftButton = Wiimote.B or Wiimote.A
end if

// Basic controls
Up = Wiimote.Right
Down = Wiimote.Left
Left = Wiimote.Up
Right = Wiimote.Down
Q = Wiimote.Plus
A = Wiimote.One
S = Wiimote.Two

// Cancel fullscreen with the Home button
Escape = Wiimote.Home

/* 
 RUMBLE

 Whenever you die in the game, the background turns to a solid dark gray. The
 following code checks 3 pixels in the gameplay area and if all 3 are that shade
 of gray, it sets off the Wiimote's rumble.
*/

var.hdc = USER32.DLL.GetDC(NULL)
var.p1 = (IntToHex(GDI32.DLL.GetPixel(var.hdc, Int(36), Int(89)), 6) == 363636)
var.p2 = (IntToHex(GDI32.DLL.GetPixel(var.hdc, Int(312), Int(150)), 6) == 363636)
var.p3 = (IntToHex(GDI32.DLL.GetPixel(var.hdc, Int(590), Int(300)), 6) == 363636)
USER32.DLL.ReleaseDC(NULL, Int(var.hdc))
if (var.p1 and var.p2 and var.p3) then
   Wiimote.Rumble = true
   wait 50 ms
   Wiimote.Rumble = false
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