diff options
author | heav <hheav3@gmail.com> | 2022-12-27 20:41:42 +0000 |
---|---|---|
committer | heav <hheav3@gmail.com> | 2022-12-27 20:41:42 +0000 |
commit | c15af7b16c64d0e44393ca30157fc24ded42b310 (patch) | |
tree | 948cb07d42c3a7cdf36cf02a09236a10ea58269e | |
parent | 80b544614ec3a96e9119a4f8b8f6b34ae07dbfbe (diff) |
added an optimal heav object.
-rw-r--r-- | objects/heav_object.lua | 24 |
1 files changed, 24 insertions, 0 deletions
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 |