|
1 |
| -<p align="center"><img src="https://raw.githubusercontent.com/Tornado-Technology/Vectors/master/LOGO.png" style="display:block; margin:auto; width:300px"></p> |
2 |
| -<h2 align="center">A Vectors system for GameMaker Studio 2.3+</h2> |
3 |
| -<h3 align="center">1.2.0</h3> |
4 |
| -<h3 align="right">by <b>@TornadoTech</b></h3> |
5 |
| - |
| 1 | +Vector structures is a package for your project that contains a handy implementation of 2D vectors for GameMaker Studio 2 using constructors. |
| 2 | +The package was originally written for personal work on TornadoTech projects, but has been posted on GitHub for the convenience of all developers. |
6 | 3 |
|
7 |
| - |
| 4 | +You can convert vectors to other data types such as `DsMap`, `DsList`, `Array` to work and also `String`. |
8 | 5 |
|
9 |
| -- ### [Download the .yymps](https://github.com/Tornado-Technology/Vectors/releases/) |
10 |
| -- ### Read the [documentation](https://tornado-technology.github.io/Vectors/#/latest/) |
| 6 | +```js |
| 7 | +var vector = new Vector2(10, 15); |
| 8 | +show_debug_message(vector); // 10:15 |
| 9 | +show_debug_message(vector.to_string(" - ")); // 10 - 15 |
| 10 | +show_debug_message(vector.to_array()); // [ 10,15 ] |
| 11 | + |
| 12 | +// Console can't normaly print list |
| 13 | +show_debug_message(vector.to_ds_list()); // ref ds_list 0 |
| 14 | +``` |
| 15 | + |
| 16 | +You can different `set_` method to affect the vector. There are also different operators to work between vectors. |
| 17 | +Also the prefix `s` before the method name means that the function accepts several numbers instead of a vector. |
| 18 | + |
| 19 | +```js |
| 20 | +var vector = new Vector2(10, 10); |
| 21 | +show_debug_message(vector.set_zero()); // 0:0 |
| 22 | +show_debug_message(vector.set_one()); // 1:1 |
| 23 | +show_debug_message(vector.set_negative()); //-1:-1 |
| 24 | + |
| 25 | +show_debug_message(vector.sset(70, 70)); // 70:70 |
| 26 | +show_debug_message(vector.sadd(10, 10)); // 80:80 |
| 27 | +show_debug_message(vector.ssub(20, 20)); // 60:60 |
| 28 | +show_debug_message(vector.smulti(10, 10)); // 600:600 |
| 29 | +show_debug_message(vector.sdivis(20, 20)); // 30:30 |
| 30 | + |
| 31 | +// Same |
| 32 | +// show_debug_message(vector.set(new Vector2(70, 70))); |
| 33 | +// show_debug_message(vector.add(new Vector2(10, 10))); |
| 34 | +// show_debug_message(vector.sub(new Vector2(20, 20))); |
| 35 | +// show_debug_message(vector.multi(new Vector2(10, 10))); |
| 36 | +// show_debug_message(vector.divis(new Vector2(20, 20))); |
| 37 | +``` |
| 38 | + |
| 39 | +```js |
| 40 | +var vector = new Vector2(10, 30); |
| 41 | +show_debug_message(vector.length()); // 1000000 |
| 42 | +show_debug_message(vector.dot(new Vector2(17, 6))); // 350 |
| 43 | +show_debug_message(vector.get_abs()); // 10:30 |
| 44 | +show_debug_message(vector.cross(new Vector2(23, 50))); // -1270 |
| 45 | +show_debug_message(vector.get_min(new Vector2(100, 100))); // 10:30 |
| 46 | +show_debug_message(vector.get_smax(2)); // 10:30 |
| 47 | +show_debug_message(vector.get_clamp(new Vector2(2, 50), new Vector2(2, 50))); // 2:50 |
| 48 | +show_debug_message(vector.get_lerp(new Vector2(60, 60), new Vector2(0.2))); // 20:30 |
| 49 | +``` |
| 50 | + |
| 51 | +```js |
| 52 | +var vector = new Vetor2(15, 35); |
| 53 | +show_debug_message(vector); // 15:35 |
| 54 | +show_debug_message(vector.copy().sadd(1, 1)); // 16:36 |
| 55 | +show_debug_message(vector); // 15:35 |
| 56 | +``` |
| 57 | + |
| 58 | +```js |
| 59 | +var vector = new Vector2(17, 17); |
| 60 | +show_debug_message(vector.dir_set(vector2_dir.down, 13)); // 17:-13 |
| 61 | +show_debug_message(vector.dir_add(vector2_dir.right, 100)); // 117:-26 |
| 62 | +show_debug_message(vector.dir_multi(vector2_dir.one, 0.1)); // 11.70:-2.60 |
| 63 | +``` |
0 commit comments