Log In  
Follow
ThaCuber

I make music and games.

vector.p8: A simple and lightweight vector math library
by
sand and water test
by
[ :: Read More :: ]

Cart #vector_p8-3 | 2023-03-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

vector.p8

a simple and lightweight (in tokens) vector math library for PICO-8. this library contains no error handling at all. it's a side effect of keeping it low in tokens, so you're gonna have to be responsible of whatever goes in.

usage:

  • load #vector_p8
  • save as such: vector.p8.
  • remove all the demo code; it's in the second tab.
  • #include in any cart you want.

functions within:

creation and management

vector(x,y,z) - the function. vectors are just normal Lua tables with x, y and z fields, so you can pass any table that contains x, y and z to any of the functions and it'll work just fine.

v_polar(length,angle)- makes a vector using polar coordinates.
v_rnd() - gives a normalized vector with a random direction.

v_cpy(v) - copies a vector.
v_unpck(v) - unpacks a vector.
v_arr(v) - returns a vector as an array of the 3 components that comprise it. Ignore the third value (Z) if your vector is a 2D one.
v_tostr(v,d) - turns a vector into a string. The d parameter is used to know if it should be printed as a 3D vector or not.
v_isvec(v) - checks if a certain value is a vector.

actual math

v_add(a,b) - adds two vectors of any dimension.
v_sub(a,b) - subtracts two vectors of any dimension.
v_scl(v,n) - scales a vector by a scalar (normal number).
v_mul(v,n) - alias for v_scl.
v_div(v,n) - scales a vector by the inverse of a scalar ("divides" the vector).

v_dot(a,b) - computes the dot product of two vectors.
v_cross(a,b) - computes the cross product of two 3D vectors.
v_magsq(v) - computes the magnitude squared of a vector.
v_mag(v) - computes the magnitude of a vector.
v_dstsq(a,b) - computes the distance squared between two vectors.
v_dst(a,b) - computes the distance between two vectors.
v_norm(v) - normalizes a vector.
v_perp(v) - gets a 2D vector perpendicular to the passed one.
v_sprj(a,b) - returns the scalar projection of one 2D vector in another.
v_proj(a,b) - returns the actual projection of one 2D vector in another.

rotation related functions

WARNING!
none of these functions work with 3D vectors. all of them work with revolutions according to PICO-8's convention.

v_rot(v,t) - Rotates a vector by an angle t.
v_ang(v) - Gets the direction a vector is pointing towards.
v_atwds(a,b) - Gets the angle needed to point towards another vector.

miscellaneous

v_lerp(a,b,t) - linearly interpolates two vectors.
v_flr(v) - floors a vector.
v_eq(a,b) - checks if two vectors are equal.

constants

WARNING!
because of the way Lua tables work, do NOT use compound assignments to alter a variable if you directly assign one of these constants to it. either copy the constant using v_cpy and then assign that to the variable or use one of the functions within the library to manipulate it.

v_right - rightwards pointing vector.
v_left - leftwards pointing vector.
v_up - upwards pointing vector. Y points downward in 2D so this vector points towards -Y.
v_down - downwards pointing vector. Y points downward in 2D so this vector points towards +Y.

v_above - 3D vector pointing upwards. unlike 2D, Y in 3D points upwards, so this vector points towards +Y.
v_below - 3D vector pointing downwards. unlike 2D, Y in 3D points upwards, so this vector points towards -Y.
v_front - 3D vector pointing forwards.
v_back - 3D vector pointing backwards.

v_zero - zero vector. all components are set to 0.
v_one - identity vector. all components are set to 1.

v_cntr - utility vector pointing towards the center of the screen, i.e. [64,64].

changelog

v1.2.1 (11-03-2023):

  • thought I had fixed all functions that used v_getd, but turns out one function I hadn't added to the docs, v_flr, still used it.
  • documented v_flr.
  • improved explanation for v_atwds.

v1.2 (06-12-2022):

  • fixed the math functions v_add, v_sub, v_scl, v_div and v_neg using the now-defunct v_getd function.

v1.1 (09-11-2022):

  • removed all dimension related functions.
    Consequently, a parameter was added to v_tostr for it to know how to format the output.
  • added v_sprj and v_proj.
  • renamed v_center to v_cntr.

v1.0 (09-11-2022):

  • initial release
P#121553 2022-11-29 14:31 ( Edited 2023-07-24 14:49)

[ :: Read More :: ]

Description from the itch.io page:

You're a bee, and for some reason I still do not comprehend, you decided to get some honey. In the middle of the rain. The drops are twice as bigger than you. You might die if you get hit by one. And the rain gets worse the more honey you collect. That wasn't the best idea you've gotten.

Made in 4 hours for the Crunchy Jam, hosted by Celesmeh.

Still has noticeable bugs, since I couldn't get time for enough bugfixing sadly.

Cart #riskyhoney-0 | 2022-06-12 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
2

P#113059 2022-06-12 15:56

[ :: Read More :: ]

Cart #spaceshipgame-0 | 2021-09-07 | Code ▽ | Embed ▽ | No License

A game about shooting aliens that i made cause boredom.
The collision system is also trash but i can't make it better
[0x0]

Anyways, it's pretty cool and i have like 3 days working on it, so please tell me what you think in the comments too!
and also print("have a good day :D")

P#97024 2021-09-07 21:17

[ :: Read More :: ]

sand and water

and yes, the physics are wrong, don't need to tell me

Cart #sand-1 | 2021-06-29 | Code ▽ | Embed ▽ | No License
3

P#94228 2021-06-29 23:01

[ :: Read More :: ]

Cart #edge2-2 | 2021-01-30 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

New things:

  • A level editor that doesn't really work well
  • Climbing
  • More bugs
  • My brain hurts

Yeah, i don't really thing i will go on with this project. Well, it depends.

Depends in if my coding skills are enough to continue this thing.

i dont think so

P#86968 2021-01-30 16:01

[ :: Read More :: ]

Cart #edge-2 | 2021-01-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Please don't ask me why i do tutorials and immediately come with a game remake coded all by myself. Just play this.

This is a 2D remake of a game i've always wanted to remake somewhere else. I ended remaking it in PICO-8 (here), which is an uncomfortable thing since the original game is in 3D, and this thing is in 2D. But i'll be cool and say that this is a demake instead. For now it's just a very hecking early alpha, but i'll be working on it.

Also also, i don't know if i'll be able to code moving platforms.

To-do:

The ability to climb blocks, if it isn't there how could i call this an EDGE Remake.
Not being able to move in certain places ( for example, when you're trapped in a little tunnel )
The collectables, win, lose, and all the other things that need to be here and if not i could hardly call this a game.
And a lot more things.

Anyways, hope you like this thing, it's my first PICO-8 project with no tutorials, and because of it i'm so proud of it. Even though it's a copy of another game.

And yes, you can edit it according to the Creative Commons license.

Stay cool and see ya!

  • Tha Cuber
P#86690 2021-01-22 22:44 ( Edited 2022-06-11 19:15)

[ :: Read More :: ]

Cart #basicpong-1 | 2021-01-04 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

A basic pong game.

Thanks to @Krystman for the tutorials.

Also sorry too because i literally changed almost nothing.

P#86121 2021-01-04 02:43 ( Edited 2021-01-04 02:44)

[ :: Read More :: ]

Is there a PICO-8 official discord server?

If there is, how can I join?

If there isn't, are there any plans to make one?

Because I would like to have one.

Off-Topic

Also, I'm getting better at PICO-8.

Kinda.

P#85928 2020-12-30 17:01

[ :: Read More :: ]

What if i, instead of doing games, i make mechanics for games?

i feel like this is a good idea.

puzzlescript.

P#82179 2020-09-23 19:08

[ :: Read More :: ]

Hi! I'm here again and i'm testing a hitbox thing.

Also you can walljump. How interesting.

And double jump. i'm awesome.

Btw im not gonna use it, 2 hard 4 me

Cart #sayudiziwo-0 | 2020-09-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Also, just a fun fact, i make Puzzlescript games.

That's it, i wasted your time.

P#82120 2020-09-22 19:30 ( Edited 2020-09-22 19:32)

[ :: Read More :: ]

The header of my account is one of my so many Puzzlescript games.

That's it, i wasted your time.

P#82083 2020-09-22 03:22

[ :: Read More :: ]

Hi! I'm ThaCuber! I want to post here my first game ever on here, even though i didn't finished it.

Please tell me guys what you thnk about it!

btw yes i used @MBoffin's top down game tutorial, don't tell that on the comments pls

Cart #mahiyajimu-0 | 2020-09-22 | Code ▽ | Embed ▽ | No License
1

Oh, and, i am proud of it, i don't care if you don't

P#82072 2020-09-22 01:49 ( Edited 2020-09-22 01:52)