SuperFreaksDev
Member
My platform engine is almost complete and I've been working on one last feature to add: rotating platforms.
My platform engine is an imitation of the one used in the New Super Mario Bros. games. To handle slopes, the player object uses a single pixel (in Game Maker, a collision_point at the player's bottom center) to collide with them. All platforms move in their Begin Step, and the player gets the platform's ID, stores it as "floorID," and moves with it in the player's Step. I have all sorts of moving and sloped grounds working properly, but spinning platforms are giving me a lot of trouble.
My theory right now is to make a circle using lengthdir functions based on how far the player's slope collider (which is just at objPlayer.x/objPlayer.y) is from the platform's pivot point but I'm just lost.
My platform engine is an imitation of the one used in the New Super Mario Bros. games. To handle slopes, the player object uses a single pixel (in Game Maker, a collision_point at the player's bottom center) to collide with them. All platforms move in their Begin Step, and the player gets the platform's ID, stores it as "floorID," and moves with it in the player's Step. I have all sorts of moving and sloped grounds working properly, but spinning platforms are giving me a lot of trouble.
My theory right now is to make a circle using lengthdir functions based on how far the player's slope collider (which is just at objPlayer.x/objPlayer.y) is from the platform's pivot point but I'm just lost.
Code:
///Moving Platforms
if (floorID != 0)
{
if instance_exists(floorID)
{
var floorIDXPos, floorIDYPos, floorIDAnglePos, pivotPointDistance;
floorIDXPos = floorID.x - floorID.xprevious;
floorIDYPos = floorID.y - floorID.yprevious;
floorIDAnglePos = floorID.anglePrevious;
pivotPointDistance = point_distance(x, y, floorID.x, floorID.y);
repeat(abs(floorIDYPos))
y += sign(floorIDYPos);
repeat(abs(floorIDXPos))
x += sign(floorIDXPos);
}
Attachments
-
97.8 KB Views: 34