I'm a bit of a beginner in Pico 8 programming and I wanted to know how to implement a gravity system that doesn't activate the collision function.
(I saw some tutorials on YouTube and I think I will have to change a large part of my code)
Could anyone tell me how to fix this? (ps: typos due to Google Translate)
player code (related only to movement):
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/45608/2_rgbg_avatar.png)
Your code already has gravity. Right now, it's linear. If you want more realistic gravity, then it would need to be an acceleration which would mean adding gravity to ben.dy instead of setting ben.dy equal to gravity.
The line after the "gravity check" comment is checking if the map tile underneath ben is solid. It's also missing the x value needed to work. I'm pretty sure the y value is wrong too. The line after the check is for updating the vertical position, which is necessary for gravity to have any meaning.
If you don't want the map check to occur, get rid of the line after the "gravity check" comment and also the "end" right after it. More work will be done for a good gravity system, but I can't advise on that without more understanding regarding what you want the game to do.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](https://www.lexaloffle.com/bbs/files/32759/comovic.gif)
It may be better to fix the problems in which the nest of the function is unnaturally codeed before working on gravity and collision.
This is because if you proceed in this state, you may be unintended in an unexpected place.
Currently, the function of benupdate()
is closed immediately after _untrans()
.
One of the end
of _untrans ()
must be added behind benupdate()
.
function benupdate() ︙ --trasform button if (btnp(3)) then omini+=1 ben.form=1 _transform() if ben.head~=96 and omini==2 then _untrans() omini=0 end end --There is few "end". ︙ function _untrans() ben.oframe=80 ben.eframe=83 ben.head=96 ben.sframe=ben.oframe end --There is more "end". end |
[Please log in to post a comment]