For the people who need to make a game with physics and turn out not to know… For starters, I need help with this. Anyone available?
Leader you can depreciate this topic at the end if you want to.
*typo: it’s “deprecate”.
How ironic, lol.
I can’t edit…
I know. You’re past the 30m editing window. You can ask a leader to edit it for you.
Hmmm it’s fine… Anyways you know gravity physics don’t you?
For like platformers? @CodeHelp? Would anyone be fascinated helping me?
I would suggest looking at Spy Guys platformers, to get a basics
I don’t get it that way… blushes…
So I guess @Spy_Guy_96? Help?
So a basic platformer is made out of 2 parts.
The player and tiles. (And some other things but these are not important right now)
The player is where all the physics happen, the tiles is where the collision happens.
However, for the collision code to work properly, the player physics need to work properly.
So the player physics code have 3 sets of variables. 1 set of variable tracks the players speed (or how fast the player is going).
Another set of variables tracks the players current position (where the player is on screen)
And the last set of variables track the players Next position (where the player is going).
There is also the “air” variable which checks if the player is on the ground or not (if they are not, the player can’t jump.)
You also have scrolling but that’s not important right now.
The collision code is a bit more complicated.
Each tile calculates collision between the player and itself.
For a basic solid tile, there are 2 collisions. 1 for horizontal collision (walls) and 1 for vertical collisions (floor and ceiling).
If a tile detects a collision, it will change the variables that track the players NEXT position.
Say, if the player walks into a wall, the code will basically set the players next X position to be right next to that wall.
If the player jumps on a platforms, it will change the players next Y position to be on top of that platform (it will also set the variable “air” to 1 to show that the player is on top of a platform).
So that’s basically how it works without going to deep into the code. If you want to see how the code would look like, you can go into this project.
Thanks so much!
O yhea by the way, there currently is a bug in hopscotch that makes this code not work on newer projects so you might want to wait before starting your own.
Oh okay! Got it! Thanks like sooooooooo much!
(I can’t explain how much appreciate this!)