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

Dynamic sprite size?

I

IE Entertainment

Guest
Hello, everyone. Not sure what to call the thing I’m asking about but I want my sprites to dynamically change size based on their background depth. For example, imagine a side scrolling view but when ever your character walks towards the background, the sprite would appear appear smaller based on how far away from the screen they are and as they move toward the screen they would appear larger. How would I go about programming that? What is the logic?

Am I telling GM that the further my sprites move up the -Y axis the smaller it becomes and then the opposite for when the sprite moves down the Y axis toward the screen?

Thanks in advanced for the help. You guys are always great!
 
The simplest way would be to use the image_xscale/image_yscale built-in variables.
Code:
image_xscale = .5;
image_yscale = .5;
Would make the object's sprite be drawn at half the size, for instance.
 
A

Amoses

Guest
Hello, everyone. Not sure what to call the thing I’m asking about but I want my sprites to dynamically change size based on their background depth. For example, imagine a side scrolling view but when ever your character walks towards the background, the sprite would appear appear smaller based on how far away from the screen they are and as they move toward the screen they would appear larger. How would I go about programming that? What is the logic?

Am I telling GM that the further my sprites move up the -Y axis the smaller it becomes and then the opposite for when the sprite moves down the Y axis toward the screen?

Thanks in advanced for the help. You guys are always great!
im pretty new, but the only way I could think of that working is to make your movement, so just the basic
Code:
 CREATE EVENT: right = keyboard_check(ord("D")) left = keyboard_check(ord("A")) up = keyboard_check(ord("W")) down = keyboard_check(ord("S"))
Code:
STEP EVENT: if (right) x += 4; if (left) x -= 4 if (up) y-= 4; if (down) y += 4; (the up and down may have to be switched)
You would have to make a sprite of the character getting smaller and smaller, and then in the step event make the image_index higher and higher until your character is to your liking of size
 

Yal

🐧 *penguin noises*
GMC Elder
How would I go about programming that? What is the logic?
Let's say you want the sprite to be half as big when you're at the very top of the room and twice as big at the very bottom, then something like this should do the trick:
Code:
image_yscale = lerp(0.5,2,y/room_height)
image_xscale = abs(image_yscale)*sign(image_xscale) //Have the same scale but retain sign (so you can flip the sprite horizontally by setting xscale negative instead of having a "left" and a "right" sprite for every animation)
 
I

IE Entertainment

Guest
im pretty new, but the only way I could think of that working is to make your movement, so just the basic
Code:
 CREATE EVENT: right = keyboard_check(ord("D")) left = keyboard_check(ord("A")) up = keyboard_check(ord("W")) down = keyboard_check(ord("S"))
Code:
STEP EVENT: if (right) x += 4; if (left) x -= 4 if (up) y-= 4; if (down) y += 4; (the up and down may have to be switched)
You would have to make a sprite of the character getting smaller and smaller, and then in the step event make the image_index higher and higher until your character is to your liking of size
Hmm.. ok. I’ll try that out and see what I get. Thanks!
 
I

IE Entertainment

Guest
Let's say you want the sprite to be half as big when you're at the very top of the room and twice as big at the very bottom, then something like this should do the trick:
Code:
image_yscale = lerp(0.5,2,y/room_height)
image_xscale = abs(image_yscale)*sign(image_xscale) //Have the same scale but retain sign (so you can flip the sprite horizontally by setting xscale negative instead of having a "left" and a "right" sprite for every animation)
Great! Thanks for the reply. I’ll give it a try.
 
Top