add global color palette table

This commit is contained in:
yuki 2025-11-11 23:36:48 -03:00
parent 7e24a44617
commit e7b1e7e78a
6 changed files with 20 additions and 8 deletions

View file

@ -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 = {1,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")

View file

@ -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')

View file

@ -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

View file

@ -42,10 +42,10 @@ 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

View file

@ -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

View file

@ -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