|
|
|
@ -5,7 +5,9 @@ Enemy = Object:extend() |
|
|
|
local fireTime = love.timer.getTime() |
|
|
|
local enemyBullets |
|
|
|
|
|
|
|
function Enemy:new(x, y, radius) |
|
|
|
--int x, y, radius |
|
|
|
--playableArea -> {int[2]} |
|
|
|
function Enemy:new(x, y, radius, playableArea) |
|
|
|
self.origin = { x, y } |
|
|
|
self.image = love.graphics.newImage("/assets/enemy/e-fighter.png") |
|
|
|
|
|
|
|
@ -13,6 +15,8 @@ function Enemy:new(x, y, radius) |
|
|
|
self.y = y |
|
|
|
self.width = self.image:getWidth() |
|
|
|
self.height = self.image:getHeight() |
|
|
|
self.playableLeft = playableArea[1] |
|
|
|
self.playableRight = playableArea[2] |
|
|
|
|
|
|
|
self.type = "enemy" |
|
|
|
self.health = 10 |
|
|
|
@ -21,7 +25,7 @@ function Enemy:new(x, y, radius) |
|
|
|
self.fireRate = 1 |
|
|
|
self.destroy = false |
|
|
|
|
|
|
|
self.bounds = { (self.x + 18), (self.x + 44), (self.y + 20), (self.y + 44) } |
|
|
|
self.hitbox = { (self.x + 18), (self.x + 44), (self.y + 20), (self.y + 44) } |
|
|
|
enemyBullets = {} |
|
|
|
end |
|
|
|
|
|
|
|
@ -42,7 +46,7 @@ function Enemy:update(dt, player) |
|
|
|
|
|
|
|
self.x = self.x + self.speed * dt |
|
|
|
|
|
|
|
self.bounds = { (self.x + 18), (self.x + 44), (self.y + 20), (self.y + 44) } |
|
|
|
self.hitbox = { (self.x + 18), (self.x + 44), (self.y + 20), (self.y + 44) } |
|
|
|
--movement |
|
|
|
if self.x > game_bounds[2] then |
|
|
|
self.speed = -self.speed |
|
|
|
|