Follow
 7

Not really sure if this was mentioned anywhere, but I thought it might be useful for anyone who wants to make use of vector math, specifically calculating the length of a 2D vector, while minimizing the risk of overflow.

Because the sqrt(32767) ~= 181, it is easy to overflow when using the textbook equation for calculating vector length:
 len = sqrt(x*x + y*y)

To derisk overflowing when squaring the terms, you can first scale down the vector's x and y components:
 m = max(x,y) x = x / m y = y / m

then scale the square root of their sums:
 len = sqrt(x*x + y*y) * m

Lua code (simplified since one term will always == 1):

 ```function length(v) local d = max(abs(v[1]),abs(v[2])) local n = min(abs(v[1]),abs(v[2])) / d return sqrt(n*n + 1) * d end ```
P#38407 2017-03-19 11:39 ( Edited 2017-05-16 19:01)

Here's a capture of some of the movement animations.

Still lots to do. For this game I am using the awesome Pyxel Edit software to create the animations. It is so nice to be able to import and export spritesheets with pico-8.

I'll hopefully have something more to post soon.

P#22116 2016-06-02 16:50 ( Edited 2016-06-02 20:50)

 30

Cart #33610 | 2016-12-17 | Code ▽ | No License
30

Climb to survive.

Enjoy!

 CONTROLS Movement: Left, Right, Up, Down A-Button: Jump B-Button: Use item in item box Keyboard: Player1 (yellow): Cursors + ZX / NM Player2 (white): SDFE + tab,Q / shift A

 * New high score: 228 (by flightrush)

My personal high score video:

P#19561 2016-04-03 08:49 ( Edited 2016-12-17 23:01)

Started work on a game based loosely on "jumpman" called "HighSteal".

I should be done in a few days... ok, maybe a week or so.

So far it is coming along really well. My original though was to create a 2-player game, and if there was time and space, add a single player mode.

I was so glad today when I upgraded to the latest pico-8 and found the code char limit had been doubled!!! Thank you!!!

So I am now working on the single player mode, and I think it will work out well.

P#19387 2016-03-24 14:06 ( Edited 2016-04-03 12:57)

 109