Skip to content

Instantly share code, notes, and snippets.

@njbmartin

njbmartin/keypress.lua

Last active Dec 2, 2015
Embed
What would you like to do?
local Colore = clr.Corale.Colore.Core
local Thread = clr.System.Threading.Thread
local c = Colore.Color.Purple
local Colors = {
Background = Colore.Color(10, 10, 10),
One = Colore.Color.Pink,
}
local direction = "right"
local speed = 200
function play_game()
local x = 0
local y = 0
while true do
Keyboard.SetAll(Colors.Background)
if direction == "up" then y = y - 1 end
if direction == "down" then y = y + 1 end
if direction == "left" then x = x -1 end
if direction == "right" then x = x + 1 end
if x < 0 then x = 21 end
if x > 21 then x = 0 end
if y < 0 then y = 5 end
if y > 5 then y = 0 end
Keyboard[y,x] = Colors.One
Thread.Sleep(speed)
end
end
function keyPress(key)
if key == "Up" then direction = "up" end
if key == "Down" then direction = "down" end
if key == "Left" then direction = "left" end
if key == "Right" then direction = "right" end
if key == "PageUp" then speed = speed - 100 end
if key == "Next" then speed = speed + 50 end
end
clr.KeyHook.Hooker.registerEvents("Test Hook", keyPress)
play_game()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.