Skip to content

Commit

Permalink
boss hud wip
Browse files Browse the repository at this point in the history
  • Loading branch information
edisonout committed Jun 12, 2015
1 parent c676325 commit 3242cee
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 147 deletions.
12 changes: 12 additions & 0 deletions src/hud.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
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.
File renamed without changes
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
31 changes: 30 additions & 1 deletion src/nodes/enemy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -565,4 +594,4 @@ function Enemy:onScreen()
return false
end

return Enemy
return Enemy

0 comments on commit 3242cee

Please sign in to comment.