How to implement the attraction (gravity) to the ground,provided you're not standing on the object?

linewire.ru/t/Mario_game/Mario_game.html

I think to register if mario.Y above the "land" to include "attraction" mario.Y=20 for example,current is not clear how cecati that I do not stand on the surface of some stone or another one, or coord.top.

objects a lot,will not I in a condition to each register,may be the array to do cecati array or what?
can you show example code please?
July 8th 19 at 16:10
July 8th 19 at 16:12
Solution
Test it with every stone. But not at all every stone on the level and only those that are "near". Conventionally, we can divide the level into cells and each cell comes across a few stones. To check the collision will only need those stones, kotoyre in the same cell as the player.
mmm,good idea,and that the cell is possible more in detail,please? - Rudy.Williamson commented on July 8th 19 at 16:15
: Depending on how the levels of "cell" can mean completely different implementation.
The most banal, divide the whole map into equal squares and in each square keep a list of objects that are partially or completely within (comparing the dimensions of the object with the dimensions of the "square"). Also you can Google about BSP trees and more... But the trite division into squares easiest to implement. Provided that you have a map fully formed and all at once loaded, you need a "square" is derived from the coordinates of the object, even search for nothing. If the level is dynamically loaded, then a little harder to implement. - Kory.Jenki commented on July 8th 19 at 16:18
: The idea is good,thanks!It remains to find how optimized for HPD to do it.That would be moving in a different cage he machine cecal pattern - Rudy.Williamson commented on July 8th 19 at 16:21
July 8th 19 at 16:14
um, physics engines it is like this - there is a dynamic object, it is subject to the prescribed forces such as gravity, are always. And there are static objects on which these forces act. Plus the special property of the type of collision that is the interaction with other objects. To repel them, just not to miss, etc. So in your case, the stones of the earth and things that should not move is static objects with collision and Mario is a dynamic object on which the force of gravity and other movements.
July 8th 19 at 16:16
kekaishi before downward movement under the action of gravity if there is an object, if there is nowhere to go, you stand, speed = 0. something like this in a nutshell
how cecati is there an object?if such objects 30 say on stage - Rudy.Williamson commented on July 8th 19 at 16:19
when I did a simple platformer, then I had a 2D array of objects, the objects were cells located, respectively, depending on the position of the character cekal only nearby cells and the objects they are. - Kory.Jenki commented on July 8th 19 at 16:22
July 8th 19 at 16:18
Add a condition in the spirit
onLand = true||false
for Mario
Very overstory response - Rudy.Williamson commented on July 8th 19 at 16:21

Find more questions by tags Development of gamesJavaScript