Compare commits
3 commits
7e24a44617
...
62bc32c97a
| Author | SHA1 | Date | |
|---|---|---|---|
| 62bc32c97a | |||
| 96628b9a8b | |||
| e7b1e7e78a |
7 changed files with 59 additions and 8 deletions
12
main.lua
12
main.lua
|
|
@ -31,6 +31,18 @@ Area = require 'obj/Area'
|
|||
GameObject = require 'obj/GameObject'
|
||||
|
||||
function love.load()
|
||||
-- table of color palette
|
||||
COLORS = {
|
||||
default = {1,1,1,1},
|
||||
bg = {.05,.05,.05,1},
|
||||
ammo = {1,1,1,1},
|
||||
boost = {1,1,1,1},
|
||||
hp = {.8,.1,.1,1},
|
||||
skill_point = {1,1,1,1},
|
||||
collision = {1,0.4,0.4,1},
|
||||
debug = {0.4,1,0.4,1}
|
||||
}
|
||||
|
||||
-- screen setup
|
||||
love.graphics.setDefaultFilter("nearest")
|
||||
love.graphics.setLineStyle("rough")
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function Room:draw()
|
|||
end
|
||||
love.graphics.setCanvas()
|
||||
|
||||
love.graphics.setColor(255, 255, 255, 255)
|
||||
love.graphics.setColor(COLORS.default)
|
||||
love.graphics.setBlendMode('alpha', 'premultiplied')
|
||||
love.graphics.draw(self.main_canvas, 0, 0, 0, sx, sy)
|
||||
love.graphics.setBlendMode('alpha')
|
||||
|
|
|
|||
|
|
@ -65,12 +65,12 @@ end
|
|||
function Player:draw()
|
||||
Player.super.draw(self)
|
||||
if DEBUG then
|
||||
love.graphics.setColor(1, 0.4, 0.4)
|
||||
love.graphics.setColor(COLORS.collision)
|
||||
self.collider:draw()
|
||||
love.graphics.setColor(0.4, 1, 0.4)
|
||||
love.graphics.setColor(COLORS.debug)
|
||||
love.graphics.line(self.x, self.y, self.x + 2*self.w*math.cos(self.r), self.y + 2*self.w*math.sin(self.r))
|
||||
end
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setColor(COLORS.default)
|
||||
love.graphics.circle('line', self.x, self.y, self.w)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -42,11 +42,17 @@ end
|
|||
function Projectile:draw()
|
||||
Projectile.super.draw(self)
|
||||
if DEBUG then
|
||||
love.graphics.setColor(1, 0, 0)
|
||||
love.graphics.setColor(COLORS.collision)
|
||||
self.collider:draw()
|
||||
end
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setColor(COLORS.default)
|
||||
love.graphics.circle('fill', self.x, self.y, self.s)
|
||||
end
|
||||
|
||||
---Kills Projectile
|
||||
function Projectile:kill()
|
||||
self.area:addGameObject('ProjectileDeathEffect', self.x, self.y, {w = self.s*3})
|
||||
self:destroy()
|
||||
end
|
||||
|
||||
return Projectile
|
||||
|
|
|
|||
33
obj/game/ProjectileDeathEffect.lua
Normal file
33
obj/game/ProjectileDeathEffect.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
---@class ProjectileDeathEffect:GameObject
|
||||
local ProjectileDeathEffect = GameObject:extend()
|
||||
|
||||
function ProjectileDeathEffect:new(area, x, y, opts)
|
||||
ProjectileDeathEffect.super.new(self, area, x, y, opts)
|
||||
-- width
|
||||
self.w = opts.w or 12
|
||||
self.first = true
|
||||
self.timer:after(0.1, function()
|
||||
self.first = false
|
||||
self.second = true
|
||||
self.timer:after(0.15, function()
|
||||
self.second = false
|
||||
self:kill()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
---Updates ProjectileDeathEffect
|
||||
---@param dt number delta time
|
||||
function ProjectileDeathEffect:update(dt)
|
||||
ProjectileDeathEffect.super.update(self, dt)
|
||||
end
|
||||
|
||||
---Draws ProjectileDeathEffect
|
||||
function ProjectileDeathEffect:draw()
|
||||
ProjectileDeathEffect.super.draw(self)
|
||||
if self.first then love.graphics.setColor(COLORS.default)
|
||||
elseif self.second then love.graphics.setColor(COLORS.hp) end
|
||||
love.graphics.rectangle('fill', self.x - self.w/2, self.y - self.w/2, self.w, self.w)
|
||||
end
|
||||
|
||||
return ProjectileDeathEffect
|
||||
|
|
@ -23,7 +23,7 @@ end
|
|||
function ShootEffect:draw()
|
||||
ShootEffect.super.draw(self)
|
||||
pushRotateScale(self.x, self.y, self.player.r+math.pi/4)
|
||||
love.graphics.setColor(1,1,1)
|
||||
love.graphics.setColor(COLORS.default)
|
||||
love.graphics.rectangle('fill', self.x - self.w/2, self.y - self.w/2, self.w, self.w)
|
||||
love.graphics.pop()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ end
|
|||
|
||||
function CircleRoom:canvasDraw()
|
||||
CircleRoom.super.canvasDraw(self)
|
||||
love.graphics.setColor(1, 1, 1)
|
||||
love.graphics.setColor(COLORS.default)
|
||||
end
|
||||
|
||||
return CircleRoom
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue