Understanding collisions - Platformer [4.5]

jataka5000

New member
I'm trying to get clear on the ways that conditions are checked for collisions with tiles, e.g. in doHandlePhysics_Gravity and stopOnSolid_Platformer:

Both "getPointColTable" and "CheckCollisionPoint" refer to a right and left collision table. What are these tables, and why the two tables instead of just one?
What is the purpose of getPointColTable?

I'd like to know how the 'self_' variables are defined. E.g. is self_left just the left-edge coordinate of the object? Is it the absolute position of the object or relative to some position (i.e. mapping the spatial extent of the object)?

self_left
self_right
self_top
self_bottom

I noticed that a positive speed means pointed down, so does this mean that adding a height (e.g. ADC self_top) actually means lower on the screen?

It would be awesome to see a more in-depth tutorial about how collisions work for the platformer in nesmaker! Specifically, doHandlePhysics_Gravity and stopOnSolid_Platformer
 

dale_coop

Moderator
Staff member
It's kinda complicated, there are 2 collision tables, because there are 2 nametables loaded (used for by scrolling engine).
And when there is a collision, the code needs to check if it's on the left nametable or on the right nametable:
2020-07-24-12-55-59-FCEUX-2-2-3-game.png


the self_ variables are used (calculated) only when collision with an object.

if you want to know about collision with tiles, you can use tileX (horizontal coord of the tile collision) and tileY (vertical coord of the tile collision)
You can also use the current position of the player object_x_hi,x and object_y_hi,x anytime, in any script.

0,0 for x,y corresponds to the top left corner of the screen.
 

jataka5000

New member
Ok, interesting. Thank you for the help.
So this explains why my custom collisions sometimes behave differently once I've walked the character to the next screen. There must be a variable then flagged by the scrolling engine that indicates whether object is in left or right nametable -- do you know what this variable is called?

0,0 for x,y corresponds to the top left corner of the screen.
So it sounds like down and to the right are always positive -- whether we're talking about position, speed, or gravity.. so adding positive values to a position (like ADC #$01) will always either shift down or right.

tileX (horizontal coord of the tile collision) and tileY (vertical coord of the tile collision)

would tileX be the furthest left coordinate of the tile, and tileY be the highest vertical coordinate of the tile?
 

dale_coop

Moderator
Staff member
tileX and tileY are the exact coords of the collision.
If you want the furthest left coord of the tile iteself, you need to do a "AND #%11110000" (same for vertical with tileY)
 
Top Bottom