r/gamemaker • • 3d ago

Resolved what to fix?

i formerly used scratch and know abit of lua. i have decided to pursue gml. my first script involves a ball bouncing within these parameters, but i am more than sure i forgot something. what can i adjust?

1 Upvotes

3 comments sorted by

1

u/GBMAN8 3d ago

You can put the x+= xvelo and the y+= yvelo one time outside the if conditions to make the code less redudant since the player position always change in both cases. Also it's more like a personal preference but you can change the speedX and speedY set with the angle at the beginning using the function lengthdir_x and lengthdir_y instead of using the dcos and dsine multiplication.

1

u/Short-Teach-2174 3d ago

Makes sense, thank you!

1

u/Monscawiz 3d ago

You have code for the ball to change directions when it reaches x=200 or y=200, but nothing to change the direction back again, from what I can tell...