Adjusted menu behvariour with entity and particle movement. adjusted player entity

This commit is contained in:
lustlion 2022-02-03 06:02:06 +01:00
parent 7595ed3b90
commit d4dbc034ea
4 changed files with 25 additions and 21 deletions

View File

@ -65,27 +65,14 @@
end end
function Player:Smart() function Player:Smart()
-- light self:LightAdjust(-self.target_offset.x,-self.target_offset.y)
self.light.pos.x = self.pos.x-self.target_offset.x
self.light.pos.y = self.pos.y-self.target_offset.y
if self.dashTimer <= 0 then if self.dashTimer <= 0 then
if self.isOnGround then
self.vel.x = self.vel.x * (1-self.groundFriction)
else
self.vel.x = self.vel.x * (1-self.airFriction)
end
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
if Keybind:CheckDown(Keybind.move.left) then if Keybind:CheckDown(Keybind.move.left) then
self.move_x = -self.moveSpeed self.move_x = -self.moveSpeed
elseif Keybind:CheckDown(Keybind.move.right) then elseif Keybind:CheckDown(Keybind.move.right) then
self.move_x = self.moveSpeed self.move_x = self.moveSpeed
else
self.move_x = 0
end end
self.vel.x = self.vel.x
if Keybind:CheckDown(Keybind.move.jump) then if Keybind:CheckDown(Keybind.move.jump) then
if self.coyoteValue > 0 then if self.coyoteValue > 0 then
@ -128,6 +115,14 @@ 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)
else
self.vel.x = self.vel.x * (1-self.airFriction)
end
if math.abs(self.vel.x) < self.zeroSpeed then self.vel.x = 0 end
end
-- reset state -- reset state
self.isOnGround = false self.isOnGround = false
-- adjust timers -- adjust timers
@ -202,4 +197,5 @@ function Player:HandleAnimation()
if self.dashCount > 0 then if self.dashCount > 0 then
self:Draw(self.mask) self:Draw(self.mask)
end end
self.move_x = 0
end end

View File

@ -49,8 +49,10 @@ function Entity:CollisionMove()
end end
end end
function Entity:LightAdjust() function Entity:LightAdjust(x,y)
if self.light ~= nil then if self.light ~= nil then
local x = x or 0
local y = y or 0
self.light.pos.x = self.pos.x self.light.pos.x = self.pos.x
self.light.pos.y = self.pos.y self.light.pos.y = self.pos.y
end end

View File

@ -2,16 +2,22 @@ function GameStep()
if menu_type == "no" then if menu_type == "no" then
for _, particle in pairs(LoadedParticles) do for _, particle in pairs(LoadedParticles) do
particle:Smart() particle:Smart()
particle:DoPhysics()
end end
for _, enty in pairs(LoadedEntities) do for _, enty in pairs(LoadedEntities) do
enty:Smart() enty:Smart()
end
end
for _, particle in pairs(LoadedParticles) do
particle:DoPhysics()
end
for _, enty in pairs(LoadedEntities) do
enty:DoPhysics() enty:DoPhysics()
end end
AnimateTiles() AnimateTiles()
Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y) Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height) --camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
end
if Keybind:HasPressed(Keybind.debug.debug) then if Keybind:HasPressed(Keybind.debug.debug) then
if debug then if debug then

View File

@ -43,7 +43,7 @@ function love.load()
LoadedParticles = {} LoadedParticles = {}
LevelLoadTiles() LevelLoadTiles()
language = "HEON" language = "ENG"
LocaleLoad(language) LocaleLoad(language)
main_Player = Player:New(75,50) main_Player = Player:New(75,50)