Movable, more buttons.
Download pad.luaLanguage: lua
require "gd"
joysimg = gd.createFromPng("segajoystick.png"):gdStr()
joysw = 120
joysh = 64
joyx = 2
joyx = 2
joyy = 170
transp = {0,0,0,0}
btnpress = {0,0,255,244}
gui.circle = function (x, y, r, fill, border)
fill = fill or {0,0,0,0}
-- Fill
for xr = -r, r do
yr = math.sqrt(r*r - xr*xr)
gui.line (x+xr, y-yr, x+xr, y+yr, fill)
end
-- Border
border = border or fill
yd = 0
for xr = -r, r do
yr = math.sqrt(r*r - xr*xr)
gui.line (x+xr, y-yr, x+xr, y-yd, border)
gui.line (x+xr, y+yr, x+xr, y+yd, border)
--[[--
if (math.abs((y-yd) - (y-yr)) > 1) then
gui.line (x+xr, y-yr, x+xr, y-yd-1, border)
gui.line (x+xr, y+yr, x+xr, y+yd+1, border)
else
gui.pixel (x+xr, y-yr, border)
gui.pixel (x+xr, y+yr, border)
end
--]]--
yd = yr;
end
end
gens.registerafter(function()
keys = input.get()
if keys["leftclick"] then
joyx = keys.xmouse - joysw/2
joyy = keys.ymouse - joysh/2
end
gui.gdoverlay(joyx, joyy-10, joysimg, 0.9)
local buttons = joypad.get(1)
if buttons.up then gui.box (joyx+22, joyy+14, joyx+29, joyy+21, btnpress, 'white') end
if buttons.down then gui.box (joyx+22, joyy+28, joyx+29, joyy+35, btnpress, 'white') end
if buttons.left then gui.box (joyx+15, joyy+21, joyx+22, joyy+28, btnpress, 'white') end
if buttons.right then gui.box (joyx+29, joyy+21, joyx+36, joyy+28, btnpress, 'white') end
if buttons.start then gui.box (joyx+55, joyy+19, joyx+64, joyy+23, btnpress, 'white') end
if buttons.A then gui.circle (joyx+ 81, joyy+34, 5, btnpress, 'white') end
if buttons.B then gui.circle (joyx+ 93, joyy+28, 5, btnpress, 'white') end
if buttons.C then gui.circle (joyx+107, joyy+23, 5, btnpress, 'white') end
if buttons.X then gui.circle (joyx+ 78, joyy+20, 3, btnpress, 'white') end
if buttons.Y then gui.circle (joyx+ 88, joyy+15, 3, btnpress, 'white') end
if buttons.Z then gui.circle (joyx+ 99, joyy+10, 3, btnpress, 'white') end
end)