first commit
This commit is contained in:
commit
768eed8787
5 changed files with 169 additions and 0 deletions
31
button.lua
Normal file
31
button.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
local Object = require "classic"
|
||||
local Button = Object:extend()
|
||||
|
||||
function Button:new(x, y, r, b)
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.r = r
|
||||
self.b = b
|
||||
self.press = false
|
||||
end
|
||||
|
||||
function Button:update(dt)
|
||||
if love.keyboard.isDown(self.b) then
|
||||
self.press = true
|
||||
else
|
||||
self.press = false
|
||||
end
|
||||
end
|
||||
|
||||
function Button:draw()
|
||||
local mode
|
||||
if self.press then
|
||||
mode = "fill"
|
||||
else
|
||||
mode = "line"
|
||||
end
|
||||
|
||||
love.graphics.circle(mode, self.x + self.r, self.y + self.r, self.r)
|
||||
end
|
||||
|
||||
return Button
|
68
classic.lua
Normal file
68
classic.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
--
|
||||
-- classic
|
||||
--
|
||||
-- Copyright (c) 2014, rxi
|
||||
--
|
||||
-- This module is free software; you can redistribute it and/or modify it under
|
||||
-- the terms of the MIT license. See LICENSE for details.
|
||||
--
|
||||
|
||||
|
||||
local Object = {}
|
||||
Object.__index = Object
|
||||
|
||||
|
||||
function Object:new()
|
||||
end
|
||||
|
||||
|
||||
function Object:extend()
|
||||
local cls = {}
|
||||
for k, v in pairs(self) do
|
||||
if k:find("__") == 1 then
|
||||
cls[k] = v
|
||||
end
|
||||
end
|
||||
cls.__index = cls
|
||||
cls.super = self
|
||||
setmetatable(cls, self)
|
||||
return cls
|
||||
end
|
||||
|
||||
|
||||
function Object:implement(...)
|
||||
for _, cls in pairs({...}) do
|
||||
for k, v in pairs(cls) do
|
||||
if self[k] == nil and type(v) == "function" then
|
||||
self[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Object:is(T)
|
||||
local mt = getmetatable(self)
|
||||
while mt do
|
||||
if mt == T then
|
||||
return true
|
||||
end
|
||||
mt = getmetatable(mt)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function Object:__tostring()
|
||||
return "Object"
|
||||
end
|
||||
|
||||
|
||||
function Object:__call(...)
|
||||
local obj = setmetatable({}, self)
|
||||
obj:new(...)
|
||||
return obj
|
||||
end
|
||||
|
||||
|
||||
return Object
|
10
conf.lua
Normal file
10
conf.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
function love.conf(t)
|
||||
t.window.width = 373
|
||||
t.window.height = 212
|
||||
t.window.borderless = true
|
||||
t.window.title = "input display"
|
||||
t.window.icon = "icon.png"
|
||||
|
||||
t.modules.physics = false
|
||||
|
||||
end
|
BIN
icon.png
Normal file
BIN
icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
60
main.lua
Normal file
60
main.lua
Normal file
|
@ -0,0 +1,60 @@
|
|||
function love.load()
|
||||
local Button = require "button"
|
||||
|
||||
--movement keys
|
||||
movement = {}
|
||||
mL = Button(8, 27, 24, "a")
|
||||
mD = Button(62, 27, 24, "s")
|
||||
mR = Button(109, 53, 24, "d")
|
||||
mU = Button(127, 144, 30, "space")
|
||||
|
||||
--attack keys
|
||||
attack = {}
|
||||
bA = Button(159, 29, 24, "u")
|
||||
bB = Button(208, 8, 24, "i")
|
||||
bC = Button(262, 9, 24, "o")
|
||||
bD = Button(317, 16, 24, "p")
|
||||
bE = Button(155, 85, 24, "j")
|
||||
bF = Button(206, 64, 24, "k")
|
||||
bG = Button(262, 64, 24, "l")
|
||||
bH = Button(315,72, 24, ";")
|
||||
end
|
||||
|
||||
function love.update(dt)
|
||||
--movement keys
|
||||
mL:update(dt)
|
||||
mD:update(dt)
|
||||
mR:update(dt)
|
||||
mU:update(dt)
|
||||
|
||||
--attack keys
|
||||
bA:update(dt)
|
||||
bB:update(dt)
|
||||
bC:update(dt)
|
||||
bD:update(dt)
|
||||
bE:update(dt)
|
||||
bF:update(dt)
|
||||
bG:update(dt)
|
||||
bH:update(dt)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
||||
love.graphics.setBackgroundColor(1, 179/255, 102/255)
|
||||
|
||||
--movement keys
|
||||
mL:draw()
|
||||
mD:draw()
|
||||
mR:draw()
|
||||
mU:draw()
|
||||
|
||||
--attack keys
|
||||
bA:draw()
|
||||
bB:draw()
|
||||
bC:draw()
|
||||
bD:draw()
|
||||
bE:draw()
|
||||
bF:draw()
|
||||
bG:draw()
|
||||
bH:draw()
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue