commit 768eed87872c82daf77d4d591560d87525438760 Author: Mango Date: Sat Aug 23 19:10:20 2025 -0700 first commit diff --git a/button.lua b/button.lua new file mode 100644 index 0000000..ed22ed3 --- /dev/null +++ b/button.lua @@ -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 \ No newline at end of file diff --git a/classic.lua b/classic.lua new file mode 100644 index 0000000..cbd6f81 --- /dev/null +++ b/classic.lua @@ -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 diff --git a/conf.lua b/conf.lua new file mode 100644 index 0000000..d436c39 --- /dev/null +++ b/conf.lua @@ -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 \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..cb9f8ce Binary files /dev/null and b/icon.png differ diff --git a/main.lua b/main.lua new file mode 100644 index 0000000..3643250 --- /dev/null +++ b/main.lua @@ -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 \ No newline at end of file