diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-13 11:11:45 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-13 11:11:45 +0800 |
| commit | 14fe9ae7434ca365b7e44131042ce6e1f8e73799 (patch) | |
| tree | 5763e96c14c11f08e50c2a495ddf8018ffa502d6 /objects/Enemy.lua | |
| parent | aa3d4e377fddf077e2b8cc77f17c1eefd5f97b5e (diff) | |
refactor: remove body object
Diffstat (limited to 'objects/Enemy.lua')
| -rw-r--r-- | objects/Enemy.lua | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/objects/Enemy.lua b/objects/Enemy.lua index 36c238f..c80eb11 100644 --- a/objects/Enemy.lua +++ b/objects/Enemy.lua @@ -1,6 +1,6 @@ require "data.directions" -local Body = require "objects.Body" local Loot = require "objects.Loot" +local physics = require "logic.physics" local enemyData = require "data.enemyData" local FrameTimer = require "utils.frameTimer" local audio = require "utils.audio" @@ -16,10 +16,8 @@ function Enemy:new(name, location) presetLocation = (type(location) == "string" and location) or nil, x = (type(location) == "table" and location.x) or nil, y = (type(location) == "table" and location.y) or nil, - body = Body:new("circle", - data.size or nil, nil, - data.zoom or 1 - ), + r = data.size or nil, + zoom = data.zoom or 1, speed = data.speed or nil, health = data.health or nil, stunned = false, @@ -139,10 +137,8 @@ function Enemy:update(dt) self:move(dt) self.frameTimer:update(dt) - if not self.physicsBody:isDestroyed() then - self.x = self.physicsBody:getX() - self.y = self.physicsBody:getY() - end + local data = physics.getObjectPosition(self) + self.x, self.y = data.x, data.y end return Enemy |
