Skip to content

Commit

Permalink
Added charcoal boss. Missing angry animations and projectiles
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonLarsen committed Apr 3, 2013
1 parent 431c971 commit 2deeaba
Show file tree
Hide file tree
Showing 21 changed files with 183 additions and 11 deletions.
9 changes: 6 additions & 3 deletions boss.lua
@@ -1,4 +1,4 @@
Boss = { DEAD_TIME = 5, DEAD_SMOKE_INTERVAL = 0.5 }
Boss = { DEAD_TIME = 5, DEAD_SMOKE_INTERVAL = 0.5, IDLE_TIME = 1.5 }
Boss.__index = Boss
-- Boss states
BS_IDLE,
Expand All @@ -9,5 +9,8 @@ BS_TRANSITION,
BS_DEAD,
BS_WALK,
BS_PUSHED,
BS_SHOOT
= 0,1,2,3,4,5,6,7,8
BS_SHOOT,
BS_ROLL,
BS_DAZED,
BS_TRANSFORM
= 0,1,2,3,4,5,6,7,8,9,10,11
163 changes: 163 additions & 0 deletions charcoal.lua
@@ -0,0 +1,163 @@
Charcoal = { MAX_HEALTH = 1.2, GRAVITY = 350, ROLL_SPEED = 100, DAZED_TIME = 3, TRANSITION_TIME = 2 }
Charcoal.__index = Charcoal
setmetatable(Charcoal, Boss)

Charcoal.bbox_dazed = {x = -12, y = -26, w = 24, h = 25}

function Charcoal.create(x,y)
local self = setmetatable({}, Charcoal)

self.alive = true
self.hit = false
self.x, self.y = x,y
self.xspeed, self.yspeed = 0,0
self.time = self.IDLE_TIME
self.dir = -1
self.health = self.MAX_HEALTH
self.shockwaveAction = false
self.angry = false

self.anims = {}
self.anims[BS_IDLE] = newAnimation(img.charcoal_idle, 64, 64, 1, 1)
self.anims[BS_TRANSFORM] = newAnimation(img.charcoal_transform, 40, 64, 0.14, 19,
function()
self:setState(BS_ROLL)
end)
self.anims[BS_TRANSITION] = newAnimation(img.charcoal_transition, 40, 64, 0.14, 2)
self.anims[BS_DEAD] = self.anims[BS_TRANSITION]
self.anims[BS_ROLL] = newAnimation(img.charcoal_roll, 32, 32, 0.05, 19)
self.anims[BS_DAZED] = newAnimation(img.charcoal_daze, 40, 64, 0.14, 4)

self:setState(BS_IDLE)

return self
end

function Charcoal:update(dt)
if self.anim then
self.anim:update(dt)
end

if self.state == BS_IDLE then
self.time = self.time - dt
if self.time <= 0 then
self:setState(BS_TRANSFORM)
self.time = self.TRANSITION_TIME
end

elseif self.state == BS_TRANSITION then
self.time = self.time - dt
if self.time <= 0 then
self.angry = true
self:setState(BS_TRANSFORM)
end

elseif self.state == BS_ROLL then
self.x = self.x + self.dir * self.ROLL_SPEED * dt

if self.x < 190 or self.x > 466 then
self.y = MAPH-16
self.yspeed = -100
self.dir = -self.dir
self.xspeed = self.dir*40
ingame.shake = 0.4
self:setState(BS_DAZED)
self.time = self.DAZED_TIME
end

elseif self.state == BS_DAZED then
self.time = self.time - dt
self.yspeed = self.yspeed + self.GRAVITY*dt
self.x = self.x + self.xspeed*dt
self.y = self.y + self.yspeed*dt
if self.y > MAPH-16 then
self.xspeed = 0
self.yspeed = 0
self.y = MAPH-16
end
if self.health <= 0 then
self.time = self.DEAD_TIME
self.yspeed = self.DEAD_SMOKE_INTERVAL
ingame.shake = self.DEAD_TIME
self:setState(BS_DEAD)
map:clearFire()
map:clearEnemies()
elseif self.time <= 0 then
self:setState(BS_TRANSFORM)
elseif self.angry == false and self.health < self.MAX_HEALTH*0.75 then
self:setState(BS_TRANSITION)
self.time = self.TRANSITION_TIME
end

elseif self.state == BS_DEAD then
self.time = self.time - dt
self.yspeed = self.yspeed + dt
if self.yspeed > self.DEAD_SMOKE_INTERVAL then
self.yspeed = 0
if ingame_state ~= INGAME_WON then
map:addParticle(BlackSmoke.create(self.x+math.random(-16,16),self.y-math.random(0,32)))
playSound("endexplosion")
end
end
if self.time <= 0 then
ingame_state = INGAME_WON
end
end

self.x = cap(self.x, 190, 466)
self.health = cap(self.health, 0, self.MAX_HEALTH)
end

function Charcoal:draw()
self.flx = math.floor(self.x)
self.fly = math.floor(self.y)

if self.state == BS_IDLE then
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 32, 64)
elseif self.state == BS_DAZED then
if self.hit == true then
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 20, 64, nil, img.charcoal_daze_hit)
else
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 20, 64)
end
elseif self.state == BS_TRANSFORM then
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 20, 64)
elseif self.state == BS_ROLL then
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 16, 32)
elseif self.state == BS_TRANSITION or self.state == BS_DEAD then
self.anim:draw(self.flx, self.fly, 0, self.dir, 1, 20, 64)
end
end

function Charcoal:collideBox(bbox)
if self.x-12 > bbox.x+bbox.w or self.x+12 < bbox.x
or self.y-26 > bbox.y+bbox.h or self.y < bbox.y then
return false
else
return true
end
return false
end

function Charcoal:getBBox()
return {x = self.x-12, y = self.y-22, w = 25, h = 26}
end

function Charcoal:setState(state)
self.state = state
self.anim = self.anims[state]
if self.anim then
self.anim:reset()
end
end

function Charcoal:shot(dt,dir)
if self.state == BS_DAZED then
self.hit = true
self.health = self.health - dt
end
end

function Charcoal:getPortraitImage()
return img.charcoal_portrait
end
Binary file modified data/captain_dialog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_bump.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_daze.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_daze_hit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_idle.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_portrait.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_projectile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_roll.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_shards.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_transform.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_transform_hit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/charcoal_transition.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions gasleak.lua
@@ -1,4 +1,4 @@
GasLeak = { MAX_HEALTH = 12, IDLE_TIME = 1.5, WALK_SPEED = 40, PUSHED_COOLDOWN = 0.2,
GasLeak = { MAX_HEALTH = 12, WALK_SPEED = 40, PUSHED_COOLDOWN = 0.2,
PUSHED_SPEED = 40, DEAD_TIME = 5, DEAD_SMOKE_INTERVAL = 0.5,
GHOST_DELAY = 2.5, GHOST_DELAY_ANGRY = 1.5, HAS_SHOT_TIME = 0.4 }
GasLeak.__index = GasLeak
Expand Down Expand Up @@ -84,7 +84,6 @@ function GasLeak:update(dt)
map:clearEnemies()
elseif self.angry == false and self.health < self.MAX_HEALTH*0.75 then
self:setState(BS_TRANSITION)
self.time = self.TRANSITION_TIME
end
elseif self.state == BS_PUSHED then
self.hit = true
Expand All @@ -104,7 +103,6 @@ function GasLeak:update(dt)
map:clearEnemies()
elseif self.angry == false and self.health < self.MAX_HEALTH*0.75 then
self:setState(BS_TRANSITION)
self.time = self.TRANSITION_TIME
end
elseif self.state == BS_DEAD then
self.time = self.time - dt
Expand Down
6 changes: 4 additions & 2 deletions highscore_list.lua
Expand Up @@ -32,10 +32,12 @@ function highscore_list.draw()
if highscore_list.level == highscore_list.hllevel
and highscore_list.hlpos == i then
lg.setColor(25,118,115,255)
lg.print(scores[i].name.." "..scores[i].score, 48, 14+i*16)
lg.print(scores[i].name, 48, 14+i*16)
lg.print(scores[i].score, 105, 14+i*16)
lg.setColor(255,255,255,255)
else
lg.print(scores[i].name.." "..scores[i].score, 48, 14+i*16)
lg.print(scores[i].name, 48, 14+i*16)
lg.print(scores[i].score, 105, 14+i*16)
end
else
lg.print("---", 48, 14+i*16)
Expand Down
2 changes: 1 addition & 1 deletion magmahulk.lua
@@ -1,4 +1,4 @@
MagmaHulk = { MAX_HEALTH = 12, GRAVITY = 350, JUMP_POWER = 200, IDLE_TIME = 1.5, MAX_JUMP = 128,
MagmaHulk = { MAX_HEALTH = 12, GRAVITY = 350, JUMP_POWER = 200, MAX_JUMP = 128,
TRANSITION_TIME = 2 }
MagmaHulk.__index = MagmaHulk
setmetatable(MagmaHulk, Boss)
Expand Down
1 change: 1 addition & 0 deletions main.lua
Expand Up @@ -9,6 +9,7 @@ require("boss")
require("magmahulk")
require("gasleak")
require("gasghost")
require("charcoal")
require("door")
require("item")
require("fire")
Expand Down
3 changes: 2 additions & 1 deletion map.lua
Expand Up @@ -89,7 +89,8 @@ function Map.create(section, level)
self.startx = 280
self.starty = 240
--self.boss = MagmaHulk.create((self.width*16)/2, MAPH-16)
self.boss = GasLeak.create(368, MAPH-16)
--self.boss = GasLeak.create(368, MAPH-16)
self.boss = Charcoal.create(368, MAPH-16)
table.insert(self.items, Item.create(16*16, 8*16, "coolant"))
table.insert(self.items, Item.create(24*16, 10*16, "coolant"))
end
Expand Down
2 changes: 1 addition & 1 deletion player.lua
Expand Up @@ -6,7 +6,7 @@ local MAX_SPEED = 160 -- Maximum running speed
local MAX_SPEED_CARRY = 100 -- Maximum running speed when carrying human
local BRAKE_SPEED = 250
local GRAVITY = 350
local JUMP_POWER = 130 -- initial yspeed when jumping
local JUMP_POWER = 135 -- initial yspeed when jumping
local CLIMB_SPEED = 60 -- climbing speed
local STREAM_SPEED = 400 -- stream growth speed
local MAX_STREAM = 100 -- maximum stream length
Expand Down
4 changes: 4 additions & 0 deletions resources.lua
Expand Up @@ -39,6 +39,10 @@ local IMAGE_FILES = {
"gasleak_rage_walk", "gasleak_rage_shot_walk", "gasleak_idle_shot", "gasleak_rage_idle_shot", "gasleak_rage_idle",
"gasleak_transition", "gasleak_portrait", "gasghost", "gasghost_hit",

"charcoal_bump", "charcoal_daze", "charcoal_daze_hit", "charcoal_idle",
"charcoal_projectile", "charcoal_roll", "charcoal_shards",
"charcoal_transform", "charcoal_transition", "charcoal_portrait",

"human_1_run", "human_2_run", "human_3_run", "human_4_run",
"human_1_carry_left", "human_2_carry_left", "human_3_carry_left", "human_4_carry_left",
"human_1_carry_right", "human_2_carry_right", "human_3_carry_right", "human_4_carry_right",
Expand Down

0 comments on commit 2deeaba

Please sign in to comment.