summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthe lemons <citrons@mondecitronne.com>2022-03-16 21:46:11 -0500
committerthe lemons <citrons@mondecitronne.com>2022-03-16 21:46:11 -0500
commit18aac387aad24918d91876bd082885c8fe5484e6 (patch)
treec56c9bb4ff67dedf9827050ddd5c4b9fc5111a26
hello world
-rw-r--r--conf.lua5
-rw-r--r--main.lua47
2 files changed, 52 insertions, 0 deletions
diff --git a/conf.lua b/conf.lua
new file mode 100644
index 0000000..ba05c92
--- /dev/null
+++ b/conf.lua
@@ -0,0 +1,5 @@
+function love.conf(t)
+ t.identity = "11_111"
+ t.window.title = "11¹¹¹"
+ t.window.resizable = true
+end
diff --git a/main.lua b/main.lua
new file mode 100644
index 0000000..043a90d
--- /dev/null
+++ b/main.lua
@@ -0,0 +1,47 @@
+
+local cam = {
+ x = 0, y = 0,
+ scale = 256,
+ panning = false,
+}
+
+local function view_scale()
+ local w, h = love.graphics.getDimensions()
+ return cam.scale / math.min(w, h)
+end
+
+local function view_transform()
+ local scale = view_scale()
+ local trans = love.math.newTransform(0, 0, 1/scale, 1/scale)
+ trans:translate(cam.x, cam.y)
+ return trans
+end
+
+
+function love.draw()
+ love.graphics.clear(0,0,0)
+ love.graphics.applyTransform(view_transform())
+ love.graphics.setColor(1, 1, 1)
+ love.graphics.ellipse("fill", 10, 10, 1, 1)
+end
+
+function love.mousepressed(_, _, button)
+ if button == 2 then
+ cam.panning = true
+ end
+end
+
+function love.mousereleased(_, _, button)
+ if button == 2 then
+ cam.panning = false
+ end
+end
+
+function love.mousemoved(_, _, dx, dy)
+ if cam.panning then
+ local scale = view_scale()
+ dx, dy = dx * scale, dy * scale
+ cam.x = cam.x + dx
+ cam.y = cam.y + dy
+ end
+end