diff --git a/src/hud.lua b/src/hud.lua index eee2d3f5e..9199c8e3d 100644 --- a/src/hud.lua +++ b/src/hud.lua @@ -11,6 +11,7 @@ HUD.__index = HUD local lens = love.graphics.newImage('images/hud/lens.png') local chevron = love.graphics.newImage('images/hud/chevron.png') local energy = love.graphics.newImage('images/hud/energy.png') +local health = love.graphics.newImage('images/hud/health.png') local savingImage = love.graphics.newImage('images/hud/saving.png') lens:setFilter('nearest', 'nearest') @@ -92,6 +93,9 @@ function HUD:questBadge( player ) end function HUD:draw( player ) +-- COMMENTED OUT WHILE TESTING BOSS HUD +--[[ + if not window.dressing_visible then return end @@ -147,6 +151,14 @@ function HUD:draw( player ) end fonts.revert() +]]-- +end + +function HUD:drawBossHud() + local x = camera.x + window.width/2 + local y = camera.y + 10 + + love.graphics.draw(health, x - 58, y + 16) end return HUD diff --git a/src/images/enemies/bossHud/bossChevron.png b/src/images/enemies/bossHud/bossChevron.png deleted file mode 100644 index 96f093200..000000000 Binary files a/src/images/enemies/bossHud/bossChevron.png and /dev/null differ diff --git a/src/images/enemies/bossHud/bossChevronSnake.png b/src/images/enemies/bossHud/bossChevronSnake.png deleted file mode 100644 index 96f093200..000000000 Binary files a/src/images/enemies/bossHud/bossChevronSnake.png and /dev/null differ diff --git a/src/images/enemies/bossHud/circle.png b/src/images/enemies/bossHud/circle.png new file mode 100644 index 000000000..252d27ee6 Binary files /dev/null and b/src/images/enemies/bossHud/circle.png differ diff --git a/src/images/enemies/bossHud/energy.png b/src/images/enemies/bossHud/energy.png deleted file mode 100644 index 32634d0d3..000000000 Binary files a/src/images/enemies/bossHud/energy.png and /dev/null differ diff --git a/src/images/enemies/bossHud/health.png b/src/images/enemies/bossHud/health.png new file mode 100644 index 000000000..853b5789a Binary files /dev/null and b/src/images/enemies/bossHud/health.png differ diff --git a/src/images/enemies/bossHud/snakeBoss.png b/src/images/enemies/bossHud/tSnake.png similarity index 100% rename from src/images/enemies/bossHud/snakeBoss.png rename to src/images/enemies/bossHud/tSnake.png diff --git a/src/images/hud/health.png b/src/images/hud/health.png new file mode 100644 index 000000000..ecdc8a0c1 Binary files /dev/null and b/src/images/hud/health.png differ diff --git a/src/nodes/enemies/benzalkBoss.lua b/src/nodes/enemies/benzalkBoss.lua index c1909e22b..e43c687fe 100644 --- a/src/nodes/enemies/benzalkBoss.lua +++ b/src/nodes/enemies/benzalkBoss.lua @@ -94,48 +94,6 @@ return { enemy.db:set("bosstriggers.benzalk", true) end, - draw = function( enemy ) - fonts.set( 'small' ) - - love.graphics.setStencil( ) - - local energy = love.graphics.newImage('images/enemies/bossHud/energy.png') - local bossChevron = love.graphics.newImage('images/enemies/bossHud/bossChevron.png') - local bossPic = love.graphics.newImage('images/enemies/bossHud/benzalkBoss.png') - - energy:setFilter('nearest', 'nearest') - bossChevron:setFilter('nearest', 'nearest') - bossPic:setFilter('nearest', 'nearest') - - x, y = camera.x + window.width - 130 , camera.y + 10 - - love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.draw( bossChevron, x , y ) - love.graphics.draw( bossPic, x + 69, y + 10 ) - - love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.printf( "Benzalk", x + 15, y + 15, 52, 'center' ) - love.graphics.printf( "GUARD", x + 15, y + 41, 52, 'center' ) - - energy_stencil = function( x, y ) - love.graphics.rectangle( 'fill', x + 11, y + 27, 59, 9 ) - end - love.graphics.setStencil(energy_stencil, x, y) - local max_hp = 100 - local rate = 55/max_hp - love.graphics.setColor( - math.min(utils.map(enemy.hp, max_hp, max_hp / 2 + 1, 0, 255 ), 255), -- green to yellow - math.min(utils.map(enemy.hp, max_hp / 2, 0, 255, 0), 255), -- yellow to red - 0, - 255 - ) - love.graphics.draw(energy, x + ( max_hp - enemy.hp ) * rate, y) - - love.graphics.setStencil( ) - love.graphics.setColor( 255, 255, 255, 255 ) - fonts.revert() - end, - recoil = function( enemy ) enemy.props.recoiling = true local direction = enemy.direction == "left" and -1 or 1 diff --git a/src/nodes/enemies/tSnake.lua b/src/nodes/enemies/tSnake.lua index 71c67fecf..6ec2fb55a 100644 --- a/src/nodes/enemies/tSnake.lua +++ b/src/nodes/enemies/tSnake.lua @@ -78,68 +78,6 @@ return { end end, - die = function( enemy, player ) - local Player = require 'player' - local player = Player.factory() - local NodeClass = require('nodes/key') - local node = { - type = 'key', - name = 'ferry', - x = 1490, - y = 463,--742, - width = 24, - height = 24, - properties = {}, - } - local spawnedNode = NodeClass.new(node, enemy.collider) - local level = gamestate.currentState() - level:addNode(spawnedNode) - end, - - draw = function( enemy ) - fonts.set( 'small' ) - - love.graphics.setStencil( ) - - local energy = love.graphics.newImage('images/enemies/bossHud/energy.png') - local bossChevron = love.graphics.newImage('images/enemies/bossHud/bossChevron.png') - local bossPic = love.graphics.newImage('images/enemies/bossHud/snakeBoss.png') - - - energy:setFilter('nearest', 'nearest') - bossChevron:setFilter('nearest', 'nearest') - bossPic:setFilter('nearest', 'nearest') - - x, y = camera.x + window.width - 130 , camera.y + 10 - - love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.draw( bossChevron, x , y ) - love.graphics.draw( bossPic, x + 69, y + 10 ) - - love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.printf( "Trouser Snake", x + 10, y + 15, 100, 'left' , 0, .8, .8) - love.graphics.printf( "BOSS", x + 15, y + 41, 52, 'center' ) - - - energy_stencil = function( x, y ) - love.graphics.rectangle( 'fill', x + 11, y + 27, 59, 9 ) - end - love.graphics.setStencil(energy_stencil, x, y) - local max_hp = 70 - local rate = 60/max_hp - love.graphics.setColor( - math.min(utils.map(enemy.hp, max_hp, max_hp / 2 + 1, 0, 255 ), 255), -- green to yellow - math.min(utils.map(enemy.hp, max_hp / 2, 0, 255, 0), 255), -- yellow to red - 0, - 255 - ) - love.graphics.draw(energy, x + ( max_hp - enemy.hp ) * rate, y) - - love.graphics.setStencil( ) - love.graphics.setColor( 255, 255, 255, 255 ) - fonts.revert() - end, - attackRainbow = function(enemy) enemy.state = 'attack' enemy.last_attack = 0 diff --git a/src/nodes/enemies/turkeyBoss.lua b/src/nodes/enemies/turkeyBoss.lua index fd3221cda..cd19a60cb 100644 --- a/src/nodes/enemies/turkeyBoss.lua +++ b/src/nodes/enemies/turkeyBoss.lua @@ -11,6 +11,7 @@ local fonts = require 'fonts' return { name = 'turkeyBoss', + isBoss = true, attackDelay = 1, height = 115, width = 215, @@ -94,48 +95,6 @@ return { level:addNode(spawnedNode) end, - draw = function( enemy ) - fonts.set( 'small' ) - - love.graphics.setStencil( ) - - local energy = love.graphics.newImage('images/enemies/bossHud/energy.png') - local bossChevron = love.graphics.newImage('images/enemies/bossHud/bossChevron.png') - local bossPic = love.graphics.newImage('images/enemies/bossHud/turkeyBoss.png') - - energy:setFilter('nearest', 'nearest') - bossChevron:setFilter('nearest', 'nearest') - bossPic:setFilter('nearest', 'nearest') - - x, y = camera.x + window.width - 130 , camera.y + 10 - - love.graphics.setColor( 255, 255, 255, 255 ) - love.graphics.draw( bossChevron, x , y ) - love.graphics.draw( bossPic, x + 69, y + 10 ) - - love.graphics.setColor( 0, 0, 0, 255 ) - love.graphics.printf( "TURKEY", x + 15, y + 15, 52, 'center' ) - love.graphics.printf( "BOSS", x + 15, y + 41, 52, 'center' ) - - energy_stencil = function( x, y ) - love.graphics.rectangle( 'fill', x + 11, y + 27, 59, 9 ) - end - love.graphics.setStencil(energy_stencil, x, y) - local max_hp = 100 - local rate = 55/max_hp - love.graphics.setColor( - math.min(utils.map(enemy.hp, max_hp, max_hp / 2 + 1, 0, 255 ), 255), -- green to yellow - math.min(utils.map(enemy.hp, max_hp / 2, 0, 255, 0), 255), -- yellow to red - 0, - 255 - ) - love.graphics.draw(energy, x + ( max_hp - enemy.hp ) * rate, y) - - love.graphics.setStencil( ) - love.graphics.setColor( 255, 255, 255, 255 ) - fonts.revert() - end, - attackBasketball = function( enemy ) local node = { type = 'projectile', diff --git a/src/nodes/enemy.lua b/src/nodes/enemy.lua index cdcf6ce06..42f81d7fb 100644 --- a/src/nodes/enemy.lua +++ b/src/nodes/enemy.lua @@ -22,6 +22,7 @@ local utils = require 'utils' local window = require 'window' local camera = require 'camera' local app = require 'app' +local hud = require 'hud' local Enemy = {} @@ -52,6 +53,8 @@ function Enemy.new(node, collider, enemytype) enemy.grid = anim8.newGrid( enemy.props.width, enemy.props.height, enemy.sprite:getWidth(), enemy.sprite:getHeight() ) + enemy.isBoss = enemy.props.isBoss or false + enemy.node_properties = node.properties enemy.node = node enemy.collider = collider @@ -66,6 +69,16 @@ function Enemy.new(node, collider, enemytype) assert( tonumber(enemy.props.hp),"Hp must be a number" ) enemy.hp = tonumber(enemy.props.hp) + if enemy.isBoss then + enemy.maxHealth = enemy.hp + enemy.hudSheet = love.graphics.newImage('images/enemies/bossHud/' .. type .. '.png') + enemy.circle = love.graphics.newImage('images/enemies/bossHud/circle.png') + enemy.hudHealth = love.graphics.newImage('images/enemies/bossHud/health.png') + enemy.hudSheet:setFilter('nearest', 'nearest') + enemy.circle:setFilter('nearest', 'nearest') + enemy.hudHealth:setFilter('nearest', 'nearest') + end + enemy.height = enemy.props.height enemy.width = enemy.props.width enemy.bb_width = enemy.props.bb_width or enemy.width @@ -449,6 +462,10 @@ end function Enemy:draw() local r, g, b, a = love.graphics.getColor() + + if self.isBoss then + self:drawBossHud() + end if self.flash then love.graphics.setColor(255, 0, 0, 255) @@ -468,6 +485,18 @@ function Enemy:draw() end +function Enemy:drawBossHud() + local x = camera.x + window.width/2 + local y = camera.y + 10 + love.graphics.draw(self.circle, x - 100, y) -- extra circle for player + love.graphics.draw(self.circle, x + 100, y) + love.graphics.draw(self.hudSheet, x + 100, y) + love.graphics.draw(self.hudHealth, x + 41, y + 16) + + hud:drawBossHud() +end + + function Enemy:ceiling_pushback() if self.props.ceiling_pushback then self.props.ceiling_pushback(self) @@ -565,4 +594,4 @@ function Enemy:onScreen() return false end -return Enemy +return Enemy \ No newline at end of file