ref: ee5a2ea5ab003cd1a72c117c3d6635c9443a4aa6
parent: 160ee55c18972419554636290278e892d5716d8b
author: phil9 <telephil9@gmail.com>
date: Sun Dec 4 02:45:15 EST 2022
add animation sample
--- /dev/null
+++ b/samples/bounce.lua
@@ -1,0 +1,32 @@
+#!/bin/slug
+
+function setup()
+ size(400, 400)
+end
+
+x = math.random(400)
+y = math.random(400)
+vx = 1
+vy = 1
+function draw()
+ background(200)
+ fill(255, 100, 100)
+ circle(x, y, 20)
+ x = x + vx
+ if x < 10 then
+ x = 10
+ vx = -vx
+ elseif x > width - 10 then
+ x = width - 10
+ vx = -vx
+ end
+ y = y + vy
+ if y < 10 then
+ y = 10
+ vy = -vy
+ elseif y > height - 10 then
+ y = height - 10
+ vy = -vy
+ end
+end
+