Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boss HUD #2439

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed src/images/enemies/bossHud/bossChevron.png
Binary file not shown.
Binary file removed src/images/enemies/bossHud/bossChevronSnake.png
Binary file not shown.
Binary file added src/images/enemies/bossHud/circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/images/enemies/bossHud/energy.png
Binary file not shown.
Binary file added src/images/enemies/bossHud/health.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/images/hud/health.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 0 additions & 42 deletions src/nodes/enemies/benzalkBoss.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
62 changes: 0 additions & 62 deletions src/nodes/enemies/tSnake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 1 addition & 42 deletions src/nodes/enemies/turkeyBoss.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local fonts = require 'fonts'

return {
name = 'turkeyBoss',
isBoss = true,
attackDelay = 1,
height = 115,
width = 215,
Expand Down Expand Up @@ -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',
Expand Down
48 changes: 45 additions & 3 deletions src/nodes/enemy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ local utils = require 'utils'
local window = require 'window'
local camera = require 'camera'
local app = require 'app'

local fonts = require 'fonts'

local Enemy = {}
Enemy.__index = Enemy
Expand Down Expand Up @@ -50,7 +50,9 @@ function Enemy.new(node, collider, enemytype)
enemy.sprite = love.graphics.newImage( sprite_sheet )
enemy.sprite:setFilter('nearest', 'nearest')

enemy.grid = anim8.newGrid( enemy.props.width, enemy.props.height, enemy.sprite:getWidth(), enemy.sprite:getHeight() )
enemy.grid = anim8.newGrid( enemy.props.width, enemy.props.height, enemy.sprite:getDimensions())

enemy.isBoss = enemy.props.isBoss or false

enemy.node_properties = node.properties
enemy.node = node
Expand All @@ -66,6 +68,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.health = love.graphics.newImage('images/enemies/bossHud/health.png')
enemy.hudSheet:setFilter('nearest', 'nearest')
enemy.circle:setFilter('nearest', 'nearest')
enemy.health:setFilter('nearest', 'nearest')
end

enemy.height = enemy.props.height
enemy.width = enemy.props.width
enemy.bb_width = enemy.props.bb_width or enemy.width
Expand Down Expand Up @@ -449,6 +461,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)
Expand All @@ -468,6 +484,32 @@ function Enemy:draw()

end

function Enemy:drawBossHud()
local x = camera.x + window.width - 70
local y = camera.y + 30
love.graphics.draw(self.circle, x + 20, y - 20)
love.graphics.draw(self.hudSheet, x + 20, y - 20)

fonts.set('small')

-- draws boss name

-- draws health
local health = self.hp > 0 and self.hp or 0
-- draws black outline around text
love.graphics.setColor( 0, 0, 0, 255 )
love.graphics.printf(self.hp, x, y, 16, 'left', 0, 1, 1, 0.5, 0.5)
love.graphics.printf(self.hp, x, y, 16, 'left', 0, 1, 1, 0.5, -0.5)
love.graphics.printf(self.hp, x, y, 16, 'left', 0, 1, 1, -0.5, 0.5)
love.graphics.printf(self.hp, x, y, 16, 'left', 0, 1, 1, -0.5, -0.5)

love.graphics.print("King Trouser Snake", x - 100, y - 10)

love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.print(self.hp, x, y)
end


function Enemy:ceiling_pushback()
if self.props.ceiling_pushback then
self.props.ceiling_pushback(self)
Expand Down Expand Up @@ -565,4 +607,4 @@ function Enemy:onScreen()
return false
end

return Enemy
return Enemy