From c15af7b16c64d0e44393ca30157fc24ded42b310 Mon Sep 17 00:00:00 2001 From: heav Date: Tue, 27 Dec 2022 20:41:42 +0000 Subject: added an optimal heav object. --- objects/heav_object.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 objects/heav_object.lua (limited to 'objects') diff --git a/objects/heav_object.lua b/objects/heav_object.lua new file mode 100644 index 0000000..946b87a --- /dev/null +++ b/objects/heav_object.lua @@ -0,0 +1,24 @@ +local heav_object = {hitbox = 4} +local obj = require "obj" + +function heav_object:draw() + set_color(0.8,0.7,0.95) + line(0, 4, -4, 0, 0, -4, 4, 0, 0, 4) +end + +function heav_object:init() + self.time = 0 +end + +function heav_object:tick() + local x, y = self.data.pos[1], self.data.pos[2] + self.time = self.time+1 + local the = math.sin(self.time/5) / 30 + for obj in obj.in_box(x-50, y-50, x+50, y+50) do + if obj ~= self then + obj.data.avel = obj.data.avel + the + end + end +end + +return {heav_object = heav_object} \ No newline at end of file -- cgit v1.2.3