naming convention for most stuff but not all
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
Arrow = Entity:New()
|
||||
Arrow = Entity:new()
|
||||
|
||||
function Arrow:New(x,y,rotation,speed)
|
||||
local o = Entity:New(x,y)
|
||||
function Arrow:new(x,y,rotation,speed)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "arrow"
|
||||
|
||||
@@ -17,9 +17,9 @@ function Arrow:New(x,y,rotation,speed)
|
||||
o.illuminated = true
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.kupo.arrow)
|
||||
o.body = Animation:new(animation.kupo.arrow)
|
||||
|
||||
o.boxCollision = {
|
||||
o.box = {
|
||||
from = {x = -0.5, y = -0.5}, --gameworld pixels
|
||||
to = {x = 0.5, y = 0.5} -- gameworld pixels
|
||||
}
|
||||
@@ -32,11 +32,11 @@ function Arrow:New(x,y,rotation,speed)
|
||||
return o
|
||||
end
|
||||
|
||||
function Arrow:DrawBackground()
|
||||
self:Draw(self.body)
|
||||
function Arrow:drawBackground()
|
||||
self:draw(self.body)
|
||||
end
|
||||
|
||||
function Arrow:DoPhysics()
|
||||
function Arrow:doPhysics()
|
||||
if not self:isCollidingAt(self.pos.x + self.vel.x, self.pos.y, LoadedObjects.Collisions) then
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
else
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
CursedBook = Entity:New()
|
||||
CursedBook = Entity:new()
|
||||
|
||||
function CursedBook:New(x,y)
|
||||
local o = Entity:New(x,y)
|
||||
function CursedBook:new(x,y)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "cursed_book"
|
||||
-- behaviour
|
||||
@@ -20,14 +20,14 @@ function CursedBook:New(x,y)
|
||||
o.attack_range = 50
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.cursed_book.spawn)
|
||||
o.body = Animation:new(animation.cursed_book.spawn)
|
||||
o.sprite_tint = {0.7,0.7,0.7}
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
o:createBox(o.body)
|
||||
|
||||
-- light
|
||||
o.light_range = 500
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.light_range,2,HEX2RGB("#fe00d1"))
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_range,2,HEX2RGB("#fe00d1"))
|
||||
|
||||
table.insert(LoadedObjects.Entities,o)
|
||||
o.id = #LoadedObjects.Entities
|
||||
@@ -37,7 +37,7 @@ function CursedBook:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function CursedBook:Smart()
|
||||
function CursedBook:doLogic()
|
||||
self.target.x = main_Player.pos.x - main_Player.target_offset.x
|
||||
self.target.y = main_Player.pos.y - main_Player.target_offset.y
|
||||
local distance_x = self.target.x - self.pos.x
|
||||
@@ -66,7 +66,7 @@ function CursedBook:Smart()
|
||||
end
|
||||
end
|
||||
|
||||
function CursedBook:HandleAnimation()
|
||||
function CursedBook:handleAnimation()
|
||||
if self.status == 1 then
|
||||
if self.body.path == "assets/entities/cursed_book/spawn" then
|
||||
self.body.speed = 1/3
|
||||
@@ -74,7 +74,7 @@ function CursedBook:HandleAnimation()
|
||||
self.sprite_tint = {tint,tint,tint}
|
||||
if self.body.frame == self.body.frames then
|
||||
self.status = 2
|
||||
self.body = self.body:ChangeTo(animation.cursed_book.flying)
|
||||
self.body = self.body:change(animation.cursed_book.flying)
|
||||
self.sprite_tint = {1,1,1}
|
||||
--self:getBoundingBox(self.body,2,2,-2,-2)
|
||||
self:centerOffset(self.body)
|
||||
@@ -82,21 +82,21 @@ function CursedBook:HandleAnimation()
|
||||
end
|
||||
elseif self.status == 3 then
|
||||
if self.body.path == "assets/entities/cursed_book/flying" then
|
||||
self.body = self.body:ChangeTo(animation.cursed_book.attack_transition)
|
||||
self.body = self.body:change(animation.cursed_book.attack_transition)
|
||||
self.body.speed = 1/3
|
||||
self:centerOffset(self.body)
|
||||
if self.body.frame == self.body.frames then
|
||||
self.status = 4
|
||||
self.body = self.body:ChangeTo(animation.cursed_book.attack_loop)
|
||||
self.body = self.body:change(animation.cursed_book.attack_loop)
|
||||
self:centerOffset(self.body)
|
||||
end
|
||||
end
|
||||
end
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
self.body:animate()
|
||||
self:draw(self.body)
|
||||
end
|
||||
|
||||
function CursedBook:DoPhysics()
|
||||
function CursedBook:doPhysics()
|
||||
if self.isFlying then
|
||||
local random_x = math.random(-4, 4)/100
|
||||
local random_y = math.random(-4, 4)/100
|
||||
@@ -105,11 +105,11 @@ function CursedBook:DoPhysics()
|
||||
end
|
||||
-- move
|
||||
|
||||
self:CollisionMove()
|
||||
self:LightAdjust()
|
||||
self:moveWithCollision()
|
||||
self:adjustLight()
|
||||
end
|
||||
|
||||
function CursedBook:Debug()
|
||||
function CursedBook:debug()
|
||||
-- draw center GREEN
|
||||
love.graphics.setColor(0,1,0)
|
||||
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.spawn_range)
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
Decoration = Entity:New()
|
||||
Decoration = Entity:new()
|
||||
|
||||
function Decoration:New(x,y,animation,lightRange)
|
||||
local o = Entity:New(x,y)
|
||||
function Decoration:new(x,y,animation,light_radius)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "decoration"
|
||||
|
||||
o.pos = {x = x, y = y}
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation)
|
||||
o.body = Animation:new(animation)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
o:createBox(o.body)
|
||||
|
||||
if lightRange ~= nil then
|
||||
o.lightRange = lightRange
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
|
||||
if light_radius ~= nil then
|
||||
o.light_radius = light_radius
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius)
|
||||
end
|
||||
|
||||
table.insert(LoadedObjects.Entities,o)
|
||||
@@ -25,10 +25,10 @@ function Decoration:New(x,y,animation,lightRange)
|
||||
return o
|
||||
end
|
||||
|
||||
function Decoration:HandleAnimation()
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
function Decoration:handleAnimation()
|
||||
self.body:animate()
|
||||
self:draw(self.body)
|
||||
end
|
||||
|
||||
function Decoration:DoPhysics()
|
||||
function Decoration:doPhysics()
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Fairy = Entity:New()
|
||||
Fairy = Entity:new()
|
||||
|
||||
function Fairy:New(x,y)
|
||||
local o = Entity:New(x,y)
|
||||
function Fairy:new(x,y)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "fairy"
|
||||
|
||||
@@ -14,13 +14,13 @@ function Fairy:New(x,y)
|
||||
o.hover_distance = 60
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.fairy.flying)
|
||||
o.body = Animation:new(animation.fairy.flying)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
o:createBox(o.body)
|
||||
|
||||
-- light
|
||||
o.light_range = 80
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.light_range,nil,HEX2RGB("#fed100"))
|
||||
o.light_radius = 80
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius,nil,HEX2RGB("#fed100"))
|
||||
|
||||
-- timer
|
||||
o.particle_timer = 0
|
||||
@@ -34,9 +34,9 @@ function Fairy:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function Fairy:Smart()
|
||||
function Fairy:doLogic()
|
||||
|
||||
if self:CheckVisionLine(main_Player,self.vision_range) then
|
||||
if self:checkVisionLine(main_Player,self.vision_range) then
|
||||
|
||||
self.target.x = main_Player.pos.x + main_Player.target_offset.x
|
||||
self.target.y = main_Player.pos.y + main_Player.target_offset.y
|
||||
@@ -85,31 +85,31 @@ function Fairy:Smart()
|
||||
speed = 0.8*(distance/50),
|
||||
speed_increase = -0.01,
|
||||
}
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
Particle:new(self.pos.x,self.pos.y,particle_data)
|
||||
end
|
||||
end
|
||||
|
||||
function Fairy:HandleAnimation()
|
||||
self.body:Animate()
|
||||
function Fairy:handleAnimation()
|
||||
self.body:animate()
|
||||
--if self:isCollidingWith(main_Player) then self.sprite_tint = {1,0,0} else self.sprite_tint = {1,1,1} end
|
||||
self:Draw(self.body)
|
||||
self:draw(self.body)
|
||||
end
|
||||
|
||||
function Fairy:DoPhysics()
|
||||
function Fairy:doPhysics()
|
||||
local random_x = math.random(-4, 4)/10
|
||||
local random_y = math.random(-4, 4)/10
|
||||
|
||||
self.vel.x = self.vel.x + random_x
|
||||
self.vel.y = self.vel.y + random_y
|
||||
|
||||
self:CollisionMove()
|
||||
self:moveWithCollision()
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
|
||||
self:LightAdjust()
|
||||
self:adjustLight()
|
||||
end
|
||||
|
||||
function Fairy:Debug()
|
||||
Entity.Debug(self)
|
||||
self:CheckVisionLineDebug(main_Player,self.vision_range)
|
||||
function Fairy:debug()
|
||||
Entity.debug(self)
|
||||
self:checkVisionLineDebug(main_Player,self.vision_range)
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
HookAnchor = Entity:New()
|
||||
HookAnchor = Entity:new()
|
||||
|
||||
function HookAnchor:New(x,y,hookDistance)
|
||||
local o = Entity:New(x,y)
|
||||
function HookAnchor:new(x,y,hookDistance)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "hook_anchor"
|
||||
|
||||
o.pos = {x = x, y = y}
|
||||
o.hookDistance = hookDistance or 100
|
||||
-- animations
|
||||
o.body = Animation:New(animation.fairy.flying)
|
||||
o.body = Animation:new(animation.fairy.flying)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
o:createBox(o.body)
|
||||
|
||||
|
||||
table.insert(LoadedObjects.Entities,o)
|
||||
@@ -21,13 +21,13 @@ function HookAnchor:New(x,y,hookDistance)
|
||||
return o
|
||||
end
|
||||
|
||||
function HookAnchor:HandleAnimation()
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
function HookAnchor:handleAnimation()
|
||||
self.body:animate()
|
||||
self:draw(self.body)
|
||||
end
|
||||
|
||||
function HookAnchor:DrawBackground()
|
||||
Entity.DrawBackground(self)
|
||||
function HookAnchor:drawBackground()
|
||||
Entity.drawBackground(self)
|
||||
love.graphics.setColor(1,1,1,0)
|
||||
love.graphics.circle(
|
||||
"fill",
|
||||
@@ -37,10 +37,10 @@ function HookAnchor:DrawBackground()
|
||||
)
|
||||
end
|
||||
|
||||
function HookAnchor:DoPhysics()
|
||||
function HookAnchor:doPhysics()
|
||||
end
|
||||
|
||||
|
||||
function Fairy:Debug()
|
||||
Entity.Debug(self)
|
||||
function Fairy:debug()
|
||||
Entity.debug(self)
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Kupo = Entity:New()
|
||||
Kupo = Entity:new()
|
||||
|
||||
function Kupo:New(x,y)
|
||||
local o = Entity:New(x,y)
|
||||
function Kupo:new(x,y)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "kupo"
|
||||
|
||||
@@ -12,8 +12,8 @@ function Kupo:New(x,y)
|
||||
o.sprite_offset = {x = 8, y = 5}
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.kupo.body)
|
||||
o.bow = Animation:New(animation.kupo.bow)
|
||||
o.body = Animation:new(animation.kupo.body)
|
||||
o.bow = Animation:new(animation.kupo.bow)
|
||||
|
||||
-- bow
|
||||
o.bow_flip = 1
|
||||
@@ -27,8 +27,8 @@ function Kupo:New(x,y)
|
||||
o.bow_aim_frames = 8
|
||||
o.hostile = true
|
||||
|
||||
o.lightRange = o.range/2
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
|
||||
o.light_radius = o.range/2
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius)
|
||||
|
||||
table.insert(LoadedObjects.Entities,o)
|
||||
o.id = #LoadedObjects.Entities
|
||||
@@ -38,9 +38,8 @@ function Kupo:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function Kupo:Smart()
|
||||
self.light.pos.x = self.pos.x-self.target_offset.x
|
||||
self.light.pos.y = self.pos.y-self.target_offset.y
|
||||
function Kupo:doLogic()
|
||||
self:adjustLight(self.target_offset.x,self.target_offset.y)
|
||||
|
||||
self.target.x = main_Player.pos.x - main_Player.target_offset.x
|
||||
self.target.y = main_Player.pos.y - main_Player.target_offset.y
|
||||
@@ -89,7 +88,7 @@ function Kupo:Smart()
|
||||
if self.bow_aim_frame > self.bow_aim_frames then
|
||||
self.bow_aim_frame = self.bow_aim_frame - self.bow_aim_frames
|
||||
self.bow_frame = self.bow_frame + 1
|
||||
Arrow:New(self.pos.x,self.pos.y,self.bow_rotation,10)
|
||||
Arrow:new(self.pos.x,self.pos.y,self.bow_rotation,10)
|
||||
end
|
||||
else
|
||||
self.bow_frame = self.bow_frame + 1
|
||||
@@ -130,7 +129,7 @@ function Kupo:Smart()
|
||||
self.angle = angle
|
||||
end
|
||||
|
||||
function Kupo:HandleAnimation()
|
||||
function Kupo:handleAnimation()
|
||||
local distance_x = self.target.x - self.pos.x
|
||||
local distance_y = self.target.y - self.pos.y
|
||||
|
||||
@@ -143,11 +142,11 @@ function Kupo:HandleAnimation()
|
||||
-- flip sprite to look in the direction is moving
|
||||
if self.vel.x ~= 0 then self.sprite_flip.x = math.sign(self.vel.x) end
|
||||
|
||||
self.body:Animate()
|
||||
self.body:animate()
|
||||
self:Draw(self.body)
|
||||
|
||||
if self.draw_bow == true then
|
||||
self.bow:DrawFrame(
|
||||
self.bow:drawFrame(
|
||||
math.min(self.bow_frame,self.bow_frames),
|
||||
self.pos.x + ( 8 * math.sin(self.bow_rotation)),
|
||||
self.pos.y + (2 - 6 * math.cos(self.bow_rotation)),
|
||||
@@ -156,6 +155,6 @@ function Kupo:HandleAnimation()
|
||||
end
|
||||
end
|
||||
|
||||
function Kupo:DoPhysics()
|
||||
self:CollisionMove()
|
||||
function Kupo:doPhysics()
|
||||
self:moveWithCollision()
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Particle = Entity:New()
|
||||
Particle = Entity:new()
|
||||
LoadedObjects.Particles = {}
|
||||
|
||||
function Particle:New(x,y,particle_data)
|
||||
local o = Entity:New(x,y)
|
||||
function Particle:new(x,y,particle_data)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.pos = {x = x, y = y}
|
||||
|
||||
@@ -29,17 +29,17 @@ function Particle:New(x,y,particle_data)
|
||||
o.speed_increase = particle_data.speed_increase or 0
|
||||
|
||||
if particle_data.light ~= nil then
|
||||
o.lightRange = particle_data.light
|
||||
o.light_range = particle_data.light
|
||||
local flicker = particle_data.light_flicker or nil
|
||||
local color = particle_data.light_color or nil
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange,flicker,color)
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_range,flicker,color)
|
||||
end
|
||||
|
||||
-- animations
|
||||
if particle_data.animation ~= nil then
|
||||
o.body = Animation:New(particle_data.animation)
|
||||
o.body = Animation:new(particle_data.animation)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
o:createBox(o.body)
|
||||
if not o.animation_active then
|
||||
o.body.speed = 0
|
||||
end
|
||||
@@ -53,9 +53,9 @@ function Particle:New(x,y,particle_data)
|
||||
return o
|
||||
end
|
||||
|
||||
function Particle:Kill()
|
||||
function Particle:kill()
|
||||
if self.light ~= nil then
|
||||
self.light:Kill()
|
||||
self.light:kill()
|
||||
end
|
||||
if self.id ~= nil then
|
||||
for _, e in pairs(LoadedObjects.Particles) do
|
||||
@@ -68,21 +68,21 @@ function Particle:Kill()
|
||||
self = nil
|
||||
end
|
||||
|
||||
function Particle:HandleAnimation()
|
||||
function Particle:handleAnimation()
|
||||
self.timer = self.timer + current_dt
|
||||
self.sprite_alpha = self.sprite_alpha_base*(self.time-self.timer)/self.time
|
||||
if self.light ~= nil then
|
||||
self:LightAdjust()
|
||||
self.light.range = self.lightRange * self.sprite_alpha/2
|
||||
self:adjustLight()
|
||||
self.light.range = self.light_range * self.sprite_alpha/2
|
||||
end
|
||||
if self.sprite_alpha < 0 then self:Kill() end
|
||||
if self.sprite_alpha < 0 then self:kill() end
|
||||
if self.body ~= nil then
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
self.body:animate()
|
||||
self:draw(self.body)
|
||||
end
|
||||
end
|
||||
|
||||
function Particle:DoPhysics()
|
||||
function Particle:doPhysics()
|
||||
-- adjust speed
|
||||
if self.speed_increase ~= 0 then
|
||||
self.speed = self.speed + self.speed_increase
|
||||
@@ -90,10 +90,10 @@ function Particle:DoPhysics()
|
||||
self.vel.y = self.speed * math.sin(self.direction)
|
||||
end
|
||||
-- move
|
||||
self:CollisionMove()
|
||||
self:moveWithCollision()
|
||||
end
|
||||
|
||||
function Particle:Debug()
|
||||
function Particle:debug()
|
||||
-- draw center CYAN
|
||||
love.graphics.setColor(0,1,1)
|
||||
love.graphics.circle("fill", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, 1)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Player = Entity:New()
|
||||
Player = Entity:new()
|
||||
|
||||
function Player:New(x,y)
|
||||
local o = Entity:New(x,y)
|
||||
function Player:new(x,y)
|
||||
local o = Entity:new(x,y)
|
||||
|
||||
o.type = "player"
|
||||
-- physics
|
||||
@@ -43,7 +43,7 @@ function Player:New(x,y)
|
||||
o.walljumpFriction = 0.3 -- gameworld pixels
|
||||
|
||||
-- light values
|
||||
o.lightRange = 40 -- screen pixels
|
||||
o.light_radius = 40 -- screen pixels
|
||||
|
||||
-- status
|
||||
o.canJump = true
|
||||
@@ -69,13 +69,13 @@ function Player:New(x,y)
|
||||
|
||||
-- sprite
|
||||
o.target_offset = {x = 0, y = 0}
|
||||
o.body = Animation:New(animation.nancy.idle)
|
||||
o.mask = Animation:New(animation.moth_mask.idle)
|
||||
o.body = Animation:new(animation.nancy.idle)
|
||||
o.mask = Animation:new(animation.moth_mask.idle)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body,0,3,-1,-3)
|
||||
o:createBox(o.body,0,3,-1,-3)
|
||||
|
||||
-- lights
|
||||
o.light = Light:New(o.pos.x,o.pos.y,o.lightRange)
|
||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_radius)
|
||||
|
||||
table.insert(LoadedObjects.Entities,o)
|
||||
o.id = #LoadedObjects.Entities
|
||||
@@ -85,8 +85,8 @@ function Player:New(x,y)
|
||||
return o
|
||||
end
|
||||
|
||||
function Player:Smart()
|
||||
self:LightAdjust(self.target_offset.x,self.target_offset.y)
|
||||
function Player:doLogic()
|
||||
self:adjustLight(self.target_offset.x,self.target_offset.y)
|
||||
|
||||
-- reset coyoteValue
|
||||
if self.isOnGround then
|
||||
@@ -134,7 +134,7 @@ function Player:Smart()
|
||||
if self.dashCooldownTimer == 0
|
||||
and not self.isDashing
|
||||
and self.dashCount > 0 then
|
||||
self:Unhook()
|
||||
self:unhook()
|
||||
|
||||
-- state player
|
||||
self.isDashing = true
|
||||
@@ -164,9 +164,9 @@ function Player:Smart()
|
||||
|
||||
if self.canHook and Keybind:CheckPressed(Keybind.move.hook) then
|
||||
if self.isHooked then
|
||||
self:Unhook()
|
||||
self:unhook()
|
||||
else
|
||||
local anchor = self:CheckNearest("hook_anchor",self.hookDistance)
|
||||
local anchor = self:checkNearest("hook_anchor",self.hookDistance)
|
||||
if anchor then
|
||||
self.isHooked = true
|
||||
self.hookDistance = anchor.hookDistance
|
||||
@@ -179,7 +179,7 @@ function Player:Smart()
|
||||
end
|
||||
end
|
||||
|
||||
function Player:DoPhysics()
|
||||
function Player:doPhysics()
|
||||
if self.dashTimer <= 0 then
|
||||
if self.isOnGround then
|
||||
self.vel.x = self.vel.x * (1-self.groundFriction)
|
||||
@@ -219,7 +219,7 @@ function Player:DoPhysics()
|
||||
y = self.sprite_flip.y
|
||||
}
|
||||
}
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
Particle:new(self.pos.x,self.pos.y,particle_data)
|
||||
self.dashCooldownTimer = self.dashCooldownTime
|
||||
-- dash movement
|
||||
self.vel.x = self.dashSpeed * math.cos(self.dashDirection)
|
||||
@@ -252,7 +252,7 @@ function Player:DoPhysics()
|
||||
y = self.sprite_flip.y
|
||||
}
|
||||
}
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
Particle:new(self.pos.x,self.pos.y,particle_data)
|
||||
|
||||
local pos_x = self.hookAnchor.x + dist * math.cos(hook_angle)
|
||||
local pos_y = self.hookAnchor.y + dist * math.sin(hook_angle)
|
||||
@@ -291,16 +291,16 @@ function Player:DoPhysics()
|
||||
|
||||
-- if u collision w hazard, respawn
|
||||
if self:isCollidingAt(self.pos.x, self.pos.y, LoadedObjects.Hazards) then
|
||||
self:Respawn()
|
||||
self:respawn()
|
||||
end
|
||||
end
|
||||
|
||||
function Player:Respawn()
|
||||
function Player:respawn()
|
||||
self.pos.x = self.anchorRespawn.x
|
||||
self.pos.y = self.anchorRespawn.y
|
||||
end
|
||||
|
||||
function Player:HandleAnimation()
|
||||
function Player:handleAnimation()
|
||||
-- flip sprite to look in the direction is moving
|
||||
if self.isHooked then
|
||||
if self.vel.x ~= 0 then
|
||||
@@ -312,17 +312,17 @@ function Player:HandleAnimation()
|
||||
|
||||
-- animation priority
|
||||
if self.vel.y > 1.25 or self.isSliding then
|
||||
self.body = self.body:ChangeTo(animation.nancy.fall)
|
||||
self.mask = self.mask:ChangeTo(self.maskType.fall)
|
||||
self.body = self.body:change(animation.nancy.fall)
|
||||
self.mask = self.mask:change(self.maskType.fall)
|
||||
elseif self.vel.y < 0 then
|
||||
self.body = self.body:ChangeTo(animation.nancy.jump)
|
||||
self.mask = self.mask:ChangeTo(self.maskType.jump)
|
||||
self.body = self.body:change(animation.nancy.jump)
|
||||
self.mask = self.mask:change(self.maskType.jump)
|
||||
elseif self.vel.x + self.move_x ~= 0 then
|
||||
self.body = self.body:ChangeTo(animation.nancy.run)
|
||||
self.mask = self.mask:ChangeTo(self.maskType.run)
|
||||
self.body = self.body:change(animation.nancy.run)
|
||||
self.mask = self.mask:change(self.maskType.run)
|
||||
else
|
||||
self.body = self.body:ChangeTo(animation.nancy.idle)
|
||||
self.mask = self.mask:ChangeTo(self.maskType.idle)
|
||||
self.body = self.body:change(animation.nancy.idle)
|
||||
self.mask = self.mask:change(self.maskType.idle)
|
||||
end
|
||||
|
||||
-- special case: idle animation gets slower by time
|
||||
@@ -341,21 +341,21 @@ function Player:HandleAnimation()
|
||||
)
|
||||
end
|
||||
|
||||
self.body:Animate()
|
||||
self:Draw(self.body)
|
||||
self.body:animate()
|
||||
self:draw(self.body)
|
||||
|
||||
if self.dashCount > 0 then
|
||||
self:Draw(self.mask)
|
||||
self:draw(self.mask)
|
||||
end
|
||||
self.move_x = 0
|
||||
end
|
||||
|
||||
function Player:Unhook()
|
||||
function Player:unhook()
|
||||
self.isHooked = false
|
||||
self.hookAnchor = nil
|
||||
end
|
||||
|
||||
function Player:Debug()
|
||||
Entity.Debug(self)
|
||||
function Player:debug()
|
||||
Entity.debug(self)
|
||||
love.graphics.print("wallHit: "..self.wallHit)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user