Web
Analytics
Log In  

0

Cart [#55294#] | Copy | Code | 2018-08-16 | Link
0

This cart outlines a fairly simple way in which diagonal vectors can be normalized, to avoid super-fast diagonal movement. On tab 0, you can check out the normalization code, and an example of where you should drop it in your code to make it work!

Feel free to use this function in your code, or to revise the math to make a more efficient system! The movement is a little jittery, so there's definitely room for improvement!

Also ... Vector the Skateboarding Duck might feature in future games. We'll see!

tutorial cart cool duck skateboarding
P#55295 2018-08-16 23:10 ( Edited 2018-08-17 09:59)

::

Interesting. Player is penalized for moving diagonally and does not move as fast if just up, down, left, or right.

That should add challenge to a skater game !

P#55300 2018-08-16 23:59

::

@dw817 - Oh, it's not meant to penalize!

Say you want to cap your player's movement at 2 pixels per frame. Without normalizing, your player can move 2px vertically, 2px horizontally, and 2.8px diagonally. This code caps the diagonal movement at 2px, so movement in all directions is more-or-less the same pace!

P#55320 2018-08-17 09:59

Log in to post a comment

user:
password:

New User | Account Help
:: New User
X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2018-11-21 09:31 | 0.241s | 1835k | Q:19