diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-11 19:02:12 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-11 19:02:12 +0800 |
| commit | d34e8ea9f06ec4415827a00d83da2d9e45b0e519 (patch) | |
| tree | b891271ddf77044ff183910e6de3fa73744786ae /objects/Enemy.lua | |
| parent | fca22059009adb64240bf1f0d87b46130d02645c (diff) | |
chore: tidy up dependencies and clean code
Diffstat (limited to 'objects/Enemy.lua')
| -rw-r--r-- | objects/Enemy.lua | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/objects/Enemy.lua b/objects/Enemy.lua index 406a7c5..05f9a98 100644 --- a/objects/Enemy.lua +++ b/objects/Enemy.lua @@ -1,16 +1,12 @@ require "data.directions" - local Body = require "objects.Body" +local Loot = require "objects.Loot" local enemyData = require "data.enemyData" -local physics = require "logic.physics" - -require "logic.bullets" +local FrameTimer = require "utils.frameTimer" local Enemy = {} Enemy.__index = Enemy -local FrameTimer = require "utils.frameTimer" - function Enemy:new(name, location) local data = enemyData[name] local obj = { @@ -35,11 +31,8 @@ function Enemy:new(name, location) return obj end -function Enemy:isBlocked() - -end - function Enemy:move(dt) + -- deal with stunned status if self.stunned and self.stunned > 0 then self.stunned = self.stunned - dt return false @@ -47,6 +40,7 @@ function Enemy:move(dt) self.stunned = nil end + -- deal with sticky status if self.sticky and self.sticky > 0 then self.sticky = self.sticky - dt if not self.originalSpeed then @@ -118,7 +112,8 @@ function Enemy:die() local temp = math.random(10) / 10 if temp <= item.chances then local offset = (i - 1) * 5 - loot.drop(self.x + offset, self.y + offset, item.type) + local lootItem = Loot:new(item.type, self.x + offset, self.y + offset) + table.insert(G.currentRoom.objects.loots, lootItem) end end @@ -150,6 +145,7 @@ function Enemy:getShot() -- kill shot table.remove(shots, j) -- bullet effect + local bullets = require "logic.bullets" bullets.hit(shot.type, self.x, self.y, self.type) end end |
