• 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 Trying to move a sprite...

N

NeonBits

Guest
I don't know if I have everything to make it perfect. If you like puzzles, here's one:

create_event :
Code:
var_A = 660;
var_B = 50;
var_C = 0;
"var_B" will decrease depending of the number inside "var_C".
"var_C" will increase (0, 0.1, 0.2, etc) until it reaches 1. It can also decrease until it reaches 0.


draw_event:
Code:
draw_sprite_ext ( spr_sprite,  0  , var_A  , .........);
when "var_C" is greater than "0", I would like the sprite to move to the left until "var_A" reaches "415", during the small sequence held in "var_B".

At "var_B = 50", "var_A" = "660".
At "var_B = 0", "var_A" should be at "415" (660 - 415 = 245).

the answer is "var_A -= someting" but I'm just making things too fast or too slow. Best I get is:
Code:
var_A -= (245 / 100) * var_C;
because of codes somewhere else, once the situation has changed, where "var_A" is still substracted until "415".

edit: Maybe I should add that the sprite is 162w, 79h, origine: center, and is xscaled/yscaled at 0.1 for depth simulation.
 
Last edited by a moderator:
Can you name your variables according to what you actually want them to do? Are var_A and var_B the start point and end points of a line and var_C the percentage of the path the sprite should be on?
 

NightFrost

Member
Your intent is a little unclear, but if you want to create linear movement between two points based on a time / counter variable, you should define start and end points with startx, starty, endx, endy. Then you can calculate current position for both coordinates doing current = start + (end - start) * time.
 
N

NeonBits

Guest
You can close this.
I've managed to cheat logic with another logic... after an hundred attempts... It's not perfect but it's ok ( I hope..).
Can you name your variables according to what you actually want them to do? Are var_A and var_B the start point and end points of a line and var_C the percentage of the path the sprite should be on?
I was trying to emulate background movement; I could not include the structure as part of it so I made it a sprite; I wanted it to get in the picture according to "distance" and "current speed", while the object was turning. Then had to fix the x/yscale...
Your intent is a little unclear, but if you want to create linear movement between two points based on a time / counter variable, you should define start and end points with startx, starty, endx, endy. Then you can calculate current position for both coordinates doing current = start + (end - start) * time.
Thanks for the suggestion, but I could not make it work; I was trying upside down or I'm not good enough, probably both, but it moved too fast in the scene. So I adjusted movement compared to the different "speed situations" until it's "good".
 
Last edited by a moderator:
Top