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

View File

@ -49,8 +49,10 @@ function Entity:CollisionMove()
end
end
function Entity:LightAdjust()
function Entity:LightAdjust(x,y)
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.y = self.pos.y
end

View File

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

View File

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