Page 1 of 1
progressive system for platformer game not working
Posted: Wed Jul 20, 2022 3:55 pm
by freeve4h
i am making a platformer game, i programmed in a system so that the direction the player progresses with changes depending on what screen it is (i have no idea how to explain what im trying to make)
however, the progression system is not working, but it is less confusing than the fact that when i comment out the code it still runs the way it did before.
the .love file is
the function that holds the progressive system it in Player.lua and is commented out (
), try to find it
i have tried looking at the
, looking through all my code to find a function that may be preventing it to work, searching through all my code to see if the exact same function it somewhere else. the only other thing that may be causing this that i can think of is my potato pc with only 900MB RAM
Re: progressive system for platformer game not working
Posted: Thu Jul 21, 2022 8:11 am
by marclurr
The first thing I noticed is you have defined Player:bounds() twice, once in main.lua and once in Player.lua. I commented out the implementation in main.lua.
Then inside your commented code you have this block:
Code: Select all
-- level stuff
if Level < 10 and Level ~= 10 then
Player.boundDirection = "up"
elseif Level == 10 then
print("special")
Player.boundDirection = "special"
Player:bottomBlock(2, -1)
Player:topBlock()
Player:rightBlock(2, 1)
Player:leftBlock()
elseif Level > 10 and Level ~= 10 then
print("right")
Player.boundDirection = "right"
end
When you get to level 10 the boundDirection is set to "special", but you have no code to handle that. I changed it to this:
Code: Select all
-- level stuff
if Level < 10 then
Player.boundDirection = "up"
elseif Level >= 10 then
Player.boundDirection = "right"
end
And when you get to the level with the right facing arrow the player can move to the right (indefinitely it seems). Personally I wouldn't set this inside the player its self. In Platform_loader.lua you're setting all the positions of the objects for each level, I would also put the bound direction in there, since it's tied to the level anyway.
Re: progressive system for platformer game not working
Posted: Thu Jul 21, 2022 10:39 am
by freeve4h
marclurr wrote: ↑Thu Jul 21, 2022 8:11 am
When you get to level 10 the boundDirection is set to "special", but you have no code to handle that. I changed it to this:
"special" means that it is not going one way:
- pixil-frame-0 (3).png (13.59 KiB) Viewed 2159 times
it was meant so that i could change it any way i like
thanks for pointing out the fact that i defined it twice, that solved the problem