S
Shadowblitz16
Guest
can somebody tell me how to achieve zelda 4 style collision in a mario game?
basicly that way zelda 4 collision worked is it only stopped if the player from walking into solid walls if there was a collision right next to him
so something like this... https://drive.google.com/open?id=0B16wNFPwi_2keF9zdUtMemxWclE
you would think that this wouldn't work if the player was going to fast or was not aligned to the pixel but in fact
this wasn't a problem because he was already aligned to the pixel and his position was incremented 1 pixel at a time in a loop similar to this..
I have this as my collision code using tiles as masks
basicly that way zelda 4 collision worked is it only stopped if the player from walking into solid walls if there was a collision right next to him
so something like this... https://drive.google.com/open?id=0B16wNFPwi_2keF9zdUtMemxWclE
you would think that this wouldn't work if the player was going to fast or was not aligned to the pixel but in fact
this wasn't a problem because he was already aligned to the pixel and his position was incremented 1 pixel at a time in a loop similar to this..
Code:
var next_step = point_distance(xprevious, yprevious, x+vx, y+vy)
for (i=0; i<next_step; i++)
{
collision_tile(x, y)
x += sign(vx)
y += sign(vy)
}
Code:
/// @desc collision_tile()
/// @arg x
/// @arg y
var _x = argument[0]
var _y = argument[1]
var lay_id = layer_get_id("Collision_0")
var map_id = layer_tilemap_get_id(lay_id)
var tile = tilemap_get(map_id, _x >> 4, _y >> 4)
//switch (tile)
//{
collision_perform_t(bbox_left, bbox_bottom-16) collision_perform_t(bbox_right, bbox_bottom-16)
//}
Code:
/// @desc collision_perform_t(x, y)
var _x = next_mul(argument[0], 16) / 16
var _y = next_mul(argument[1], 16) / 16
var lay_id = layer_get_id("Collision_0")
var map_id = layer_tilemap_get_id(lay_id)
var tile = tilemap_get(map_id, _x, _y)
show_debug_message(tile)
if (tile == 1) // top platform
{
while(!tile == 1)
{
y += sign(vy)
tile = tilemap_get_at_pixel(map_id, _x, _y)
}
vy = 0
}
Code:
/// @desc next_mul(value, mulitpule)
return ceil(argument[0] / argument[1]) * argument[1]
Code:
/// @desc prev_mul(value, mulitpule)
return floor(argument[0] / argument[1]) * argument[1]