• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM (SOLVED) Help with collisions mask debugging

S

ShilohPell

Guest
Hey guys. So I'm making my first platformer and I've run into a bit of a bug.

Desired behavior:
My player's sprite should cycle through different sprites based on three states. Player in the air, player on the ground and moving, and player on the ground and idle. The in-air sprite needs to rotate as it follows the player through the air.​

Current behavior:
The sprites cycle just as I want them to. The only issue is the in-air sprite's collision box rotates with it as the player's trajectory moves. Meaning when the player collides with a wall while jumping, the collision box cycles from an angled box to a square one and the player sticks to the wall instead of falling​

Desired solution:
I need to replace my sprite_index assignment with another line that will allow me to either change the sprite angle without changing the collision box, or a way to draw the sprite in the step event at the desired angle while I apply a different sprite's collision mask.​

Current code:
Code:
///Sprite Selection

if(collision_down) && (!move = 0) //If the player is touching the ground and pressing a movement key
{
    sprite_index = spr_player_moving;
    image_angle = 0;
    image_speed = 1;
};
if(!collision_down) && (!collision_left) && (!collision_right) //If the player is in the air
{
    sprite_index = spr_player_jumping;
    image_angle = direction;
    image_speed = 1;
};
if(collision_down) && (move = 0) //If the player is on the ground and not pressing a movement key
{
    sprite_index = spr_player_idle;
    image_angle = 0;
    image_speed = 0.25;
};
 
S

SyntaxError

Guest
Replace the image_angle variable with one of your own creation like i_angle. Then in the draw event, change the draw_sprite function to reflect this variable. EG:

draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, i_angle, c_white, image_alpha);

EDIT: added example.
 
S

ShilohPell

Guest
Replace the image_angle variable with one of your own creation like i_angle. Then in the draw event, change the draw_sprite function to reflect this variable. EG:

draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, i_angle, c_white, image_alpha);

EDIT: added example.
Thanks. That did just the trick.
 
Top