-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
Bute = class("Bute", BaseAI) | ||
|
||
--- | ||
-- Bute:initialize | ||
-- An enemy that tries to shoot you. | ||
-- | ||
-- @param x X position | ||
-- @param y Y position | ||
-- | ||
function Bute:initialize(x, y) | ||
BaseAI.initialize(self, x, y) | ||
self.speed = math.random(2, 5) | ||
-- self.turnSspeed = 500 | ||
self.body:setLinearDamping(3) | ||
self.fixture:setRestitution(1) | ||
|
||
self.nextFire = 0 | ||
self.fireInterval = 0.1 | ||
|
||
self.moveOffset = math.random(-20, 20) / 180 * math.pi | ||
|
||
self:pushInDirection(utils.randomAngle(), 10) | ||
|
||
self.shield = Shield:new(self.body, 15, 2) | ||
end | ||
|
||
|
||
--- | ||
-- Bute:update | ||
-- Updates the Bute. | ||
-- | ||
-- @param dt Time passed since last frame | ||
-- | ||
function Bute:update(dt) | ||
local dx = game.ship.body:getX() - self.body:getX() | ||
local dy = game.ship.body:getY() - self.body:getY() | ||
local ang = math.atan2(dy, dx) + self.moveOffset | ||
|
||
self:aimInDirection(ang) | ||
|
||
if math.random(1, 600) > 500 + dt * 100 then | ||
self:pushInDirection(utils.randomAngle(), self.speed) | ||
end | ||
|
||
|
||
if self.nextFire <= love.timer.getTime() and math.random(1,200) == 1 then | ||
self.nextFire = love.timer.getTime() + self.fireInterval | ||
|
||
Bullet:new(self.body:getX(), self.body:getY(), self.body:getAngle(), 20, colgroup.ENEMY) | ||
end | ||
|
||
|
||
self.shield:update(dt) | ||
end | ||
|
||
|
||
--- | ||
-- Bute:draw | ||
-- Draws the Bute. | ||
-- | ||
function Bute:draw() | ||
if self.shield:isEmpty() then | ||
love.graphics.setColor(200, 200, 200) | ||
else | ||
love.graphics.setColor(200, 200, 240) | ||
end | ||
love.graphics.circle("line", self.body:getX(), self.body:getY(), self.shape:getRadius(), self.shape:getRadius()) | ||
|
||
self.shield:draw() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
Pont = class("Pont", BaseAI) | ||
|
||
--- | ||
-- Pont:initialize | ||
-- An enemy that follows you around. | ||
-- | ||
-- @param x X position | ||
-- @param y Y position | ||
-- | ||
function Pont:initialize(x, y) | ||
BaseAI.initialize(self, x, y) | ||
self.speed = math.random(50, 65) | ||
-- self.turnSspeed = 500 | ||
self.body:setLinearDamping(3) | ||
self.fixture:setRestitution(1) | ||
|
||
self.moveOffset = math.random(-20, 20) / 180 * math.pi | ||
|
||
local ang = math.random(1, 360) / 180 * math.pi | ||
self.body:applyLinearImpulse(math.cos(ang) * 10, math.sin(ang) * 10) | ||
|
||
self.shield = Shield:new(self.body, 15, 1) | ||
end | ||
|
||
|
||
--- | ||
-- Pont:update | ||
-- Updates the Pont. | ||
-- | ||
-- @param dt Time passed since last frame | ||
-- | ||
function Pont:update(dt) | ||
local dx = game.ship.body:getX() - self.body:getX() | ||
local dy = game.ship.body:getY() - self.body:getY() | ||
local ang = math.atan2(dy, dx) + self.moveOffset | ||
|
||
self:moveInDirection(ang, self.speed) | ||
|
||
|
||
self.shield:update(dt) | ||
end | ||
|
||
|
||
--- | ||
-- Pont:draw | ||
-- Draws the Pont. | ||
-- | ||
function Pont:draw() | ||
if self.shield:isEmpty() then | ||
love.graphics.setColor(200, 200, 200) | ||
else | ||
love.graphics.setColor(200, 200, 240) | ||
end | ||
love.graphics.circle("line", self.body:getX(), self.body:getY(), self.shape:getRadius(), self.shape:getRadius()) | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters