# SOLVEDsetting a enemies scale according to distance

#### anima

##### Member
hello so i am making a game and i need to make enemies scale according to their Y cord
(like higher Ycord less scale and moreYcord less scale)
and they spawn in random y positions
so i cant just use
if vspeed>0{vspeed+=0.10}
if vspeed<0{vspeed-=0.10}

Last edited:

#### TsukaYuriko

##### ☄️
Forum Staff
Moderator
(like higher Ycord less scale and moreYcord less scale)
What is the difference between higher and more?

If you want to set something according to the relative value of something to something else regardless of the sign, you can use abs to force a positive number.

If that's not what you want, please elaborate.

#### woods

##### Member
higher on the screen = farther away, so they appear smaller and slower
as they come down the screen (increase the Y-coord) they get bigger and faster to give the illusion of getting closer ??

#### anima

##### Member
higher on the screen = farther away, so they appear smaller and slower
as they come down the screen (increase the Y-coord) they get bigger and faster to give the illusion of getting closer ??
exactly but i dont know how to do this
the player i just put that if the "W key" is beign hold decrease the scale
and if "S key" is beign hold increase the scale
but i cant do
GML:
``````if vspeed>0{image_xscale+=0.10
image_yscale+=0.10}
if vspeed>0{image_xscale-=0.10
image_yscale-=0.10}``````
that with the enemies since they spawn in a random y position

Last edited:

#### Roldy

##### Member
exactly but i dont know how to do this
the player i just put that if the "W key" is beign hold decrease the scale
and if "S key" is beign hold increase the scale
but i cant do
GML:
``````if vspeed>0{image_xscale+=0.10
image_yscale+=0.10}
if vspeed>0{image_xscale-=0.10
image_yscale-=0.10}``````
that with the enemies since they spawn in a random y position

Just read what you wrote in English in the OP: "set enemies scale according to their Y cord." Just do that.

Something like:

GML:
``image_scale = y / room_height;``
Programming is translation. Take what is in your head and translate it into your natural language (english?) as precisely as possible, and then accurately translate that into a programming language, in this case GML. Do not skip any step: think of a solution, describe it naturally, translate into a software solution.

#### anima

##### Member
Just read what you wrote in English in the OP: "set enemies scale according to their Y cord." Just do that.

Something like:

GML:
``image_scale = y / room_height;``
Programming is translation. Take what is in your head and translate it into your natural language (english?) as precisely as possible, and then accurately translate that into a programming language, in this case GML. Do not skip any step: think of a solution, describe it naturally, translate into a software solution.
oh it worked thx!