Movement test in room

This time, I use some code to calculate the visual width of the object rather than just use the room height.

So this is now mathematically accurate.

Basically I used pretty simple geometry method to do the calculation.

As the above figure shows, I need to find the length of line CF. The problem is that I don't know where point A is, so I need to find AB first. Using \(\frac{AB}{BG}=\frac{AB+BD}{DE}\), I can find AB, and use that to find CF as simply \(\frac{AC}{CF}=\frac{AD}{DE}\).

The code I use is as follows.

(ps. the way GameMaker: Studio handling arguments of a function sucks. But there's no way for me to change that. In long code I think I would manually give them some alias.)

And now I can have perspective movement in my game!

Still can't believe this simple code would took me so long to debug. Reason? I simply input arguments in the wrong order...

Maybe I should always keep the definition of those functions on another screen just in case.

Leave a Reply