D
Dibidoolandas
Guest
Hey guys, I have a fairly complex question that I'll try and keep as simple as possible. Essentially I'm trying to rotate my sprite 45 degrees when it's going up/down a diagonal hill. I've found that using image_angle rotates the sprite AND the player's mask, which immediately causes clipping issues. It seems like draw_sprite_ext would be a better way to handle this, but here's where I run into problems.
My player's sprite code is handled almost entirely in a script run in the player's STEP event, not DRAW, so I can't actually run draw_sprite_ext. I'll show you the code setup, it was based on a tutorial by Shaun Spalding. My player uses a state machine, so the sprite code determines what state the player is in, and changes the sprite accordingly.
This is just a small sample because I have a lot of states and there's some fairly complex stuff going on in there. Is there a reason I can't just migrate all of this to run from the draw event? I've tried and it doesn't even render my player's sprite (plus I assume this will all be unnecessary draw on processing power).
Any help would be appreciated. Ultimately I could just make a separate sprite that's rotated 45 degrees and -45 degrees, but I also have 22.5 degree hills that would need their own sprite, plus multiple behaviors within this angle, so it really seems inefficient to do it this way.
My player's sprite code is handled almost entirely in a script run in the player's STEP event, not DRAW, so I can't actually run draw_sprite_ext. I'll show you the code setup, it was based on a tutorial by Shaun Spalding. My player uses a state machine, so the sprite code determines what state the player is in, and changes the sprite accordingly.
Code:
//Adjust sprite based on player state
switch (state)
{
case states.normal:
{
image_speed = ispd;
if (hsp == 0)
{
if !(key_right || key_left)
{
sprite_index = psprites.stand;
}
else
{
sprite_index = psprites.walk;
image_speed = (ispd/4) + abs(ispd * (hsp/4));
}
if (hdir != 0) image_xscale = hdir;
break;
}
case states.trip:
{
sprite_index = psprites.trip;
}
break;
case states.air_ride:
{
if (shoot == true) sprite_index = spr_player_r_s;
else sprite_index = psprites.ride;
image_xscale = 1;
}
break;
case states.idle:
{
if (place_meeting(x,y+1,par_collide)) sprite_index = psprites.stand;
if (!place_meeting(x,y+1,par_collide)) sprite_index = psprites.jump;
}
break;
Any help would be appreciated. Ultimately I could just make a separate sprite that's rotated 45 degrees and -45 degrees, but I also have 22.5 degree hills that would need their own sprite, plus multiple behaviors within this angle, so it really seems inefficient to do it this way.