• 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!

How to change direction a surface is facing?

JacktheLR

Member
I have this code for creating a boost flare when pressing a button.
if (!surface_exists(flare)){
flare = surface_create(124, 103);
}
surface_set_target(flare);
draw_sprite(Boost, image_i, 80, 76);
gpu_set_colorwriteenable(1,1,1,0);
surface_reset_target();
draw_surface(flare,x- 80,y-64)

But I would like to have the surface change direction depending on which way my character is going, whether that'd be to the left or up or down a wall. What do I need to do?
 
D

Deleted member 13992

Guest
It's always a good idea and look at the manual and find if there are similar functions to the one you're using (draw_surface) with more capability. The answer is usually yes, especially for draw functions.


draw_surface_ext should do the trick in your case.
 

JacktheLR

Member
Draw it rotated via draw_surface_ext.
It's always a good idea and look at the manual and find if there are similar functions to the one you're using (draw_surface) with more capability. The answer is usually yes, especially for draw functions.


draw_surface_ext should do the trick in your case.
I was able to find a way to get it to change angle. But now the flare will not stay centered on my character. When I set the offset to x-80, y-64, it changes places on the different surfaces. When I set them both to 0, they remain down to the right of my character, not centered on him. How do I fix this. And how to I make the animation I set for the flare play while I'm at it? Thank you in advance!

if (!surface_exists(flare)){flare = surface_create(124, 103);}
surface_set_target(flare);
draw_sprite(Boost, image_i, 80, 76);
surface_reset_target();
draw_surface_ext(flare,x-0,y-0,1,1,angle,c_white,1)
 
Top