Skip to content

Commit 7b24a06

Browse files
committed
added more demos, fixed cursor wrapping in menu
1 parent 0b91a46 commit 7b24a06

File tree

13 files changed

+162
-24
lines changed

13 files changed

+162
-24
lines changed

current-scripts/Demos/useful-scripts/objects/obj_column_menu/Step_1.gml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ if (!enabled) exit;
99
control_state.poll_input();
1010

1111
if (control_state.pressed_state[MENU_CONTROLS.UP]) {
12-
pos = wrap(pos-1, 0, num_items-1);
12+
pos = wrap(pos-1, 0, num_items);
1313
audio_play_sound(cursor_move_sfx, 1, false);
1414
}
1515

1616
if (control_state.pressed_state[MENU_CONTROLS.DOWN]) {
17-
pos = wrap(pos+1, 0, num_items-1);
17+
pos = wrap(pos+1, 0, num_items);
1818
audio_play_sound(cursor_move_sfx, 1, false);
1919
}
2020

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
randomise();
2+
test_array = [1, -3, "foo", { n: "bar" }, [0, 2.333]];
3+
choice = choose_from_array(test_array);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
draw_set_font(fnt_title);
2+
draw_set_halign(fa_center);
3+
draw_set_colour(c_white);
4+
draw_text(room_width/2, 16, "Data Structures Demo");
5+
6+
draw_set_halign(fa_left);
7+
draw_text(16, 64, "Choose From Array");
8+
9+
draw_set_font(fnt_demo);
10+
11+
// Choose From Array
12+
draw_text(16, 96, "Original Array: " + string(test_array));
13+
draw_text(16, 128, "Random Choice: " + string(choice));

current-scripts/Demos/useful-scripts/objects/obj_data_structures_demo/obj_data_structures_demo.yy

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

current-scripts/Demos/useful-scripts/objects/obj_demo_title/Create_0.gml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
rooms = [
22
room_control_manager_demo,
3+
room_data_structures_demo,
34
room_drawing_demo,
45
room_dta_demo,
56
room_easing_demo,
@@ -15,6 +16,7 @@ num_rooms = array_length(rooms);
1516

1617
room_names = [
1718
"Control Manager",
19+
"Data Structures",
1820
"Drawing",
1921
"Delta Time Alarm",
2022
"Easings",

current-scripts/Demos/useful-scripts/objects/obj_grid_menu/Step_1.gml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if (control_state.pressed_state[MENU_CONTROLS.UP]) {
1414
var _item = -1;
1515

1616
do {
17-
pos.y = wrap(pos.y-1, 0, ds_grid_height(items)-1);
17+
pos.y = wrap(pos.y-1, 0, ds_grid_height(items));
1818
_item = items[# pos.x, pos.y];
1919
} until (is_struct(_item) || _cur_pos == pos.y)
2020

@@ -26,7 +26,7 @@ if (control_state.pressed_state[MENU_CONTROLS.DOWN]) {
2626
var _item = -1;
2727

2828
do {
29-
pos.y = wrap(pos.y+1, 0, ds_grid_height(items)-1);
29+
pos.y = wrap(pos.y+1, 0, ds_grid_height(items));
3030
_item = items[# pos.x, pos.y];
3131
} until (is_struct(_item) || _cur_pos == pos.y)
3232

@@ -45,7 +45,7 @@ if (control_state.pressed_state[MENU_CONTROLS.LEFT]) {
4545
}
4646

4747
do {
48-
pos.x = wrap(pos.x-1, 0, ds_grid_width(items)-1);
48+
pos.x = wrap(pos.x-1, 0, ds_grid_width(items));
4949
_item = items[# pos.x, pos.y];
5050
} until (is_struct(_item) || _cur_pos == pos.x)
5151

@@ -64,7 +64,7 @@ if (control_state.pressed_state[MENU_CONTROLS.RIGHT]) {
6464
}
6565

6666
do {
67-
pos.x = wrap(pos.x+1, 0, ds_grid_width(items)-1);
67+
pos.x = wrap(pos.x+1, 0, ds_grid_width(items));
6868
_item = items[# pos.x, pos.y];
6969
} until (is_struct(_item) || _cur_pos == pos.x)
7070

current-scripts/Demos/useful-scripts/objects/obj_math_demo/Draw_0.gml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ draw_text(16, 256, "Pulse");
1515
draw_sprite_ext(spr_meter, 0, 16, 288, 0.25, 0.25, 0, c_gray, 1);
1616
draw_sprite_ext(spr_meter, 0, 16, 288, 0.25, 0.25, 0, $80FFFF, pulse_t);
1717

18-
draw_text(640, 256, "Wrap");
19-
draw_text(640, 336, "Blin");
18+
draw_text(640, 256, "Vector Operations");
19+
20+
draw_text(640, 368, "Wrap");
21+
draw_text(640, 448, "Blin");
2022

2123
draw_set_font(fnt_demo);
2224
// Vectors
@@ -40,13 +42,17 @@ draw_text(640, 208, "c x d / |c x d| = " + cross_product_normalized(vec_C, vec_D
4042
draw_text(96, 288, "t: " + string(pulse_counter.v));
4143
draw_text(176, 288, "p(t): " + string(pulse_t));
4244

45+
// Vector Operations
46+
draw_text(640, 288, "a + b = " + string(vec_A.add(vec_B).to_string()));
47+
draw_text(640, 320, "c - d = " + string(vec_C.subtract(vec_D).to_string()));
48+
4349
// Wrap
44-
draw_text(640, 288, "t: " + string(wrap_counter.v));
45-
draw_text(720, 288, "w(t): " + string(wrapped_value));
50+
draw_text(640, 400, "t: " + string(wrap_counter.v));
51+
draw_text(720, 400, "w(t): " + string(wrapped_value));
4652

4753
// Blin
4854
for (var i=0; i<5; i++) {
4955
for (var j=0; j<5; j++) {
50-
draw_text(640 + i*64, 368 + j*32, string(blin_values[# i, j]));
56+
draw_text(640 + i*64, 480 + j*32, string(blin_values[# i, j]));
5157
}
5258
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
original_str = "Lorem|ipsum|dolor|sit|amet|consectetur|adipiscing|elit";
2+
tokens = split_string(original_str, "|");
3+
hide_overflow_str = hide_overflow(original_str, "...", fnt_demo, 320);
Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
draw_set_font(fnt_title);
22
draw_set_halign(fa_center);
33
draw_set_colour(c_white);
4-
draw_text(room_width/2, 16, "Strings Demo");
4+
draw_text(room_width/2, 16, "Strings Demo");
5+
6+
draw_set_halign(fa_left);
7+
draw_text(16, 64, "Split String");
8+
draw_text(640, 64, "Hide Overflow");
9+
10+
draw_set_font(fnt_demo);
11+
12+
// Split String
13+
draw_text(16, 96, original_str);
14+
15+
for (var i=0; i<array_length(tokens); i++) {
16+
draw_text(16, 128+i*32, tokens[i]);
17+
}
18+
19+
// Hide Overflow
20+
draw_text(640, 96, hide_overflow_str);

current-scripts/Demos/useful-scripts/objects/obj_strings_demo/obj_strings_demo.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.

0 commit comments

Comments
 (0)