Skip to content

Commit 8352fff

Browse files
v1.0.0
Vector class creation is now wrapped, keyword new is not required. Also, now there is a brief notation of the vector. Add new Vector2 methods: to_array(), to_list(), sub(), divis(), copy() Add new functions: display_get_gui_size(), display_set_gui_vsize(), position_get(), position_set(), position_add(), position_multi() Updated demo
1 parent 2820cb3 commit 8352fff

File tree

15 files changed

+377
-139
lines changed

15 files changed

+377
-139
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<p align="center"><img src="https://raw.githubusercontent.com/Tornado-Technology/Vectors/master/LOGO.png" style="display:block; margin:auto; width:300px"></p>
22
<h2 align="center">A Vectors system for GameMaker Studio 2.3+</h2>
3-
<h3 align="center">0.1.0</h3>
3+
<h3 align="center">1.0.0</h3>
44
<h3 align="right">by <b>@TornadoTech</b></h3>
55
&nbsp;
66

77
&nbsp;
8+
89
- ### [Download the .yymps](https://github.com/Tornado-Technology/Vectors/releases/)
910
- ### Read the [documentation](https://tornado-technology.github.io/Vectors/#/latest/)

Vectors.yyp

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

objects/obj_demo/Create_0.gml

Lines changed: 86 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,86 @@
1-
/// @desc Examples
2-
3-
// New Vector2
4-
var vector2 = new Vector2(324, 567);
5-
6-
// Vector2 to_string()
7-
// returns a document, you can supply your own separator as input, by default ":"
8-
// first x then y
9-
log(vector2.to_string()); // Outuput: 324:567
10-
log(vector2.to_string("][")); // Outuput: 324][567
11-
12-
// Vector2 negative()
13-
// makes vector values negative
14-
vector2.negative();
15-
log(vector2.to_string()); // Outuput: -324:-567
16-
17-
// Vector2 set()
18-
// sets values for x & y a vector
19-
vector2.set(35, 60); // or vector2.set(new Vector2(35, 60));
20-
log(vector2.to_string()); // Outuput: 35:60
21-
22-
// Vector2 add()
23-
// summing one vector by another, or alternatively takes two coordinates
24-
vector2.add(35, 60);
25-
log(vector2.to_string()); // Outuput: 70:120
26-
27-
// I did not create a function for subtraction,
28-
// you can simply use the negative() function and the vector itself to be subtracted
29-
var some_vector = new Vector2(-35, -60);
30-
vector2.add(some_vector);
31-
log(vector2.to_string()); // Outuput: 35:60
32-
33-
// Vector2 multi()
34-
// multiply one vector by another, or alternatively takes two coordinates
35-
vector2.multi(2, 2);
36-
log(vector2.to_string()); // Outuput: 70:120
37-
vector2.multi(new Vector2(2, 2));
38-
log(vector2.to_string()); // Outuput: 140:240
39-
// Division can be done through multiplication
40-
vector2.multi(0.1, 0.1);
41-
log(vector2.to_string()); // Outuput: 7:12
42-
43-
// Vector2 zero()
44-
// Nullifies the vector
45-
vector2.zero();
46-
log(vector2.to_string()); // Outuput: 0:0
47-
48-
// Vector2 _min() _max() _clamp()
49-
//accepts either a vector or numeric values as input and returns
50-
vector2.set(vector2._max(10, 10)); // Set max to vector
51-
log(vector2.to_string()); // Outuput: 10:10
52-
log((vector2._min(new Vector2(0, 11))).to_string()); // Outuput: 0:10
53-
log((vector2._clamp(4, 10, 3, 5)).to_string()); // Outuput: 3:5
54-
55-
// Vector2 _length()
56-
// returns the length of the vector according to the formula
57-
// sqr(x * x + y * y)
58-
// P.S. the function returns a real number, but the log automatically converts to a string
59-
log(vector2._length()); // Outuput: 4000
60-
61-
// Vector2 _lerp() & not Vector2 fumction vector2_to_string()
62-
// this also works for either numbers or vector
63-
log(vector2_to_string(vector2, " Juju ")); // Outuput: 10 Juju 10
64-
log(vector2_to_string(vector2._lerp(100, 100, 0.5), " - ")); // Outuput: 55 - 55
65-
66-
67-
// ########################### DIR EXAMPLE ##########################
68-
// Vector2 dir_set()
69-
// for info look: https://tornado-technology.github.io/Vectors/#/latest/methods?id=installed-dir
70-
vector2.dir_set(vector2_dir.down, 13);
71-
log(vector2.to_string()) // Outuput: 10:-13
72-
73-
vector2.dir_add(vector2_dir.right, 100);
74-
log(vector2.to_string()) // Outuput: 110:-13
75-
76-
vector2.dir_multi(vector2_dir.one, 0.1);
77-
log(vector2.to_string()) // Outuput: 11:-1.30
1+
var vector = Vector2(10, 15);
2+
3+
// Converts
4+
log("Converts");
5+
6+
log(vector.to_string());
7+
log(vector.to_string(" - "));
8+
9+
log(vector.to_array());
10+
log(vector.to_array(true));
11+
12+
// Console can't normaly print list
13+
log(vector.to_list());
14+
log(vector.to_list(true));
15+
16+
delete vector;
17+
log("==========");
18+
19+
// Set
20+
log("Sets");
21+
22+
// If you do not write a Y value, it will default to the X value,
23+
// And if you do not write anything, the vector will take on the value 0, 0
24+
var shortVector = Vector2(10);
25+
26+
// Zero - x: 0, y: 0
27+
// One - x: 1, y: 1
28+
// Negative - x: -x, y: -y
29+
log(shortVector.zero().to_string());
30+
log(shortVector.one().to_string());
31+
log(shortVector.negative().to_string());
32+
33+
delete shortVector;
34+
log("==========");
35+
36+
// Math - Base
37+
var mathBaseVector = Vector2();
38+
log("Math - Base");
39+
40+
// I will say once all these functions
41+
// Can take as input both a vector and two numbers separated by a comma
42+
log(mathBaseVector.set(70, 70).to_string());
43+
log(mathBaseVector.add(10, 10).to_string());
44+
log(mathBaseVector.sub(20, 20).to_string());
45+
log(mathBaseVector.multi(10, 10).to_string());
46+
log(mathBaseVector.divis(20, 20).to_string());
47+
48+
delete mathBaseVector;
49+
log("==========");
50+
51+
// Math - Base
52+
var mathVector = Vector2(10, 30);
53+
log("Math");
54+
55+
log(mathVector.math_length());
56+
log(mathVector.math_min(100, 100));
57+
log(mathVector.math_max(2, 2));
58+
log(mathVector.math_clamp(2, 50, 2, 50));
59+
log(mathVector.math_lerp(60, 60, 0.2));
60+
61+
delete mathVector;
62+
log("==========");
63+
64+
// Utils
65+
var utilsVector = Vector2(15, 35);
66+
log("Utils");
67+
68+
log(utilsVector.to_string());
69+
log(utilsVector.copy().add(1, 1).to_string());
70+
log(utilsVector.to_string());
71+
72+
delete utilsVector;
73+
log("==========");
74+
75+
var dirVector = Vector2(17);
76+
log("Dirs");
77+
78+
// For more info look: https://tornado-technology.github.io/Vectors/#/latest/methods?id=installed-dir
79+
log(dirVector.dir_set(vector2_dir.down, 13).to_string());
80+
log(dirVector.dir_add(vector2_dir.right, 100).to_string());
81+
log(dirVector.dir_multi(vector2_dir.one, 0.1).to_string());
82+
83+
delete dirVector;
84+
log("==========");
85+
86+
// Look to Draw event and obj_square for more functionality!

objects/obj_demo/Draw_0.gml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
draw_set_halign(fa_center);
22
draw_set_valign(fa_center);
33
draw_set_font(font_russian_pank);
4-
draw_text_transformed_color(room_width / 2, room_height / 2, "It simple text!\nFor examples see in output and obj_demo", wave(2.25, 2.75, 3, 0), wave(2.25, 2.75, 3, 1), wave(-10, 10, 3, 2), c_green, c_green, c_purple, c_purple, 1);
4+
5+
draw_text_transformed(room_width / 2, room_height / 2, "It simple text!\nFor examples see in output and obj_demo", wave(2.25, 2.75, 3, 0), wave(2.25, 2.75, 3, 1), wave(-10, 10, 3, 2));
6+
7+
draw_set_halign(fa_left);
8+
draw_set_valign(fa_center);
9+
draw_set_font(noone);
10+
11+
draw_text(5, 15, "Display Size: " + display_get_gui_size().to_string("x"));

objects/obj_square/Create_0.gml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
randomize();
2+
_speed = Vector2(irandom_range(0, 5), irandom_range(0, 5));

objects/obj_square/Draw_0.gml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
draw_set_halign(fa_center);
2+
draw_set_valign(fa_center);
3+
draw_set_font(noone);
4+
5+
draw_text(x, y - 48, position_get().to_string(" - "));
6+
draw_self();

objects/obj_square/Step_0.gml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
position_add(_speed);
2+
move_wrap(true, true, sprite_width);

objects/obj_square/obj_square.yy

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options/main/options_main.yy

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options/windows/options_windows.yy

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)