Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxyOfJungle committed Sep 18, 2024
1 parent 0ec2729 commit 9f9c365
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 47 deletions.
8 changes: 8 additions & 0 deletions TurboGML/notes/ReleaseNotes/ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@

===================[ v4.0.1 ]===================

[CHANGED] Renamed the internal function "__trace" to "__tgmTrace", to prevent name clash with other libraries.

[FIXED] IsNormalized() method error from Vector2() and Vector3().
[FIXED] Small typo fixes.


===================[ v4.0 ]===================

[ADDED] clamp_angle_fov() function. With this function, you can limit the rotation angle based on the target angle.
Expand Down
2 changes: 0 additions & 2 deletions TurboGML/objects/objTests/Step_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
if (keyboard_check_pressed(vk_escape)) game_end();
if (keyboard_check_pressed(ord("R"))) room_restart();



tankAngle -= keyboard_check(vk_right) - keyboard_check(vk_left);
tankAngle = wrap(tankAngle, 0, 360);

Expand Down
62 changes: 31 additions & 31 deletions TurboGML/scripts/TGM_Arrays/TGM_Arrays.gml
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ function array_to_struct(_array) {
/// @param {Array} array The array to check
/// @param {any} value The value to check inside the array.
/// @returns {bool} Description
function array_contains_value(_array, value) {
function array_contains_value(_array, _value) {
var i = 0, isize = array_length(_array);
repeat(isize) {
if (_array[i++] == value) return true;
if (_array[i++] == _value) return true;
}
return false;
}
Expand All @@ -125,8 +125,8 @@ function array_copy_all(_from, _to) {
/// @param {Array} array The array to shift.
/// @param {Array} times How many times to shift array values.
/// @param {bool} reverse Reverse order?
function array_shift_indexes(_array, times, reverse=false) {
if (reverse) {
function array_shift_indexes(_array, times, _reverse=false) {
if (_reverse) {
repeat(times) {
var _old = _array[array_length(_array)-1];
array_pop(_array);
Expand All @@ -145,13 +145,13 @@ function array_shift_indexes(_array, times, reverse=false) {
/// @param {Array} array The array to be used.
/// @param {real} index The array position to swap to another position.
/// @param {real} offset The offset to swap the element. 0 will have no effect, 1 will swap with the next element. -1 will swap with the previous element and so on. You can use other numbers.
function array_swap_index(_array, index, offset) {
function array_swap_index(_array, _index, _offset) {
var _len = array_length(_array)-1;
if (index+offset < 0 || index > _len-offset) exit;
var _current = _array[index];
var _next = _array[index + offset];
_array[index + offset] = _current;
_array[index] = _next;
if (_index+_offset < 0 || _index > _len-_offset) exit;
var _current = _array[_index];
var _next = _array[_index + _offset];
_array[_index + _offset] = _current;
_array[_index] = _next;
}

/// @desc Find the number closest to the reference value in an array.
Expand Down Expand Up @@ -208,43 +208,43 @@ function array_get_random_index_ext(_array, _offset=0, _length=undefined) {
}

/// @desc This function returns creates a 2D array.
/// @param {real} x_size Number of columns.
/// @param {real} y_size Number of lines.
/// @param {real} xSize Number of columns.
/// @param {real} ySize Number of lines.
/// @param {real} value Initial value for each array index.
/// @returns {Array}
function array_create_2d(x_size, y_size, value=0) {
var _grid = array_create(x_size, value);
for (var i = 0; i < x_size; i++) {
_grid[i] = array_create(y_size, value);
function array_create_2d(_xSize, _ySize, _value=0) {
var _grid = array_create(_xSize, _value);
for (var i = 0; i < _xSize; i++) {
_grid[i] = array_create(_ySize, _value);
}
return _grid;
}

/// @desc This function returns creates a 2D array and executes a callback.
/// @param {real} x_size Number of columns.
/// @param {real} y_size Number of lines.
/// @param {real} xSize Number of columns.
/// @param {real} ySize Number of lines.
/// @param {function} func Function to execute for each index.
/// @returns {Array}
function array_create_2d_ext(x_size, y_size, func=undefined) {
var _grid = array_create(x_size);
for (var i = x_size; i >= 0; i--) {
_grid[i] = array_create_ext(y_size, func);
function array_create_2d_ext(_xSize, _ySize, _func=undefined) {
var _grid = array_create(_xSize);
for (var i = _xSize; i >= 0; i--) {
_grid[i] = array_create_ext(_ySize, _func);
}
return _grid;
}

/// @desc This function returns creates a 3D array.
/// @param {real} x_size Number of entries.
/// @param {real} y_size Number of entries.
/// @param {real} z_size Number of entries.
/// @param {real} xSize Number of entries.
/// @param {real} ySize Number of entries.
/// @param {real} zSize Number of entries.
/// @param {real} value Initial value for each array index.
/// @returns {Array}
function array_create_3d(x_size, y_size, z_size, value=0) {
var _grid = array_create(x_size, value);
for (var i = x_size; i >= 0; i--) {
_grid[i] = array_create(y_size, value);
for(var j = y_size; j >= 0; j--) {
_grid[i][j] = array_create(z_size, value);
function array_create_3d(_xSize, _ySize, _zSize, _value=0) {
var _grid = array_create(_xSize, _value);
for (var i = _xSize; i >= 0; i--) {
_grid[i] = array_create(_ySize, _value);
for(var j = _ySize; j >= 0; j--) {
_grid[i][j] = array_create(_zSize, _value);
}
}
return _grid;
Expand Down
12 changes: 6 additions & 6 deletions TurboGML/scripts/TGM_Debug/TGM_Debug.gml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ function print() {
}
}

#macro trace __trace(_GMFILE_ + "/" + _GMFUNCTION_ + ":" + string(_GMLINE_) + ": ")
#macro trace __tgmTrace(_GMFILE_ + "/" + _GMFUNCTION_ + ":" + string(_GMLINE_) + ": ")
/// @desc This function creates a trace method for debugging and displaying location-specific debug messages.
function __trace(_location) {
function __tgmTrace(_location) {
// credits: "Red", "JuJu Adams"
static __struct = {};
__struct.__location = _location;
Expand All @@ -28,13 +28,13 @@ function __trace(_location) {
});
}

/// @desc This function freezes the application for a few milliseconds. It is not recommended to use this function. Only for debug purposes.
/// @desc This function freezes the application for a few milliseconds. It is NOT recommended to use this function. Only for debug purposes.
/// @param {real} [milliseconds]=1000 Description
function sleep(milliseconds=1000, callback=undefined) {
var _time = current_time + milliseconds;
function sleep(_milliseconds=1000, _callback=undefined) {
var _time = current_time + _milliseconds;
while(current_time < _time) {
// idle
if (callback != undefined) callback();
if (_callback != undefined) _callback();
}
}

Expand Down
8 changes: 4 additions & 4 deletions TurboGML/scripts/TGM_DsLists/TGM_DsLists.gml
Original file line number Diff line number Diff line change
Expand Up @@ -93,24 +93,24 @@ function ds_list_median(_list) {
/// @param {Id.DsList} list The list to check.
/// @param {any} value The value to check inside the list.
/// @returns {bool} Description
function ds_list_contains_value(_list, value) {
function ds_list_contains_value(_list, _value) {
var i = 0, isize = ds_list_size(_list);
repeat(isize) {
if (_list[| i++] == value) return true;
if (_list[| i++] == _value) return true;
}
return false;
}

/// @desc With this function, you can sort a ds_list using a function. NOTE: array_sort() is much faster...
/// @param {Id.DsList} list The list to sort.
/// @param {Function} sortFunc The sort function. It should return -1 (a < b), 0 (equal) or 1 (a > b).
function ds_list_sort_ext(_list, _sort_func=SORT_ASCENDING) {
function ds_list_sort_ext(_list, _sortFunc=SORT_ASCENDING) {
// do a sort using the Bubble Sort algorigthm
var i, j, n = ds_list_size(_list);
for (i = 0; i < n; i++) {
for (j = 0; j < n-1-i; j++) {
//if (_list[| j].order > _list[| j+1].order) {
if (_sort_func(_list[| j], _list[| j+1]) > 0) {
if (_sortFunc(_list[| j], _list[| j+1]) > 0) {
var temp = _list[| j];
_list[| j] = _list[| j+1];
_list[| j+1] = temp;
Expand Down
8 changes: 4 additions & 4 deletions TurboGML/scripts/TGM_Files/TGM_Files.gml
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,19 @@ function filename_name_noext(_path) {
/// @desc Write a string to a file.
/// @param {string} filePath File path.
/// @param {any} str Description
function file_write_string(_filePath, str) {
function file_write_string(_filePath, _str) {
var _buff = buffer_create(0, buffer_grow, 1);
buffer_write(_buff, buffer_string, str);
buffer_write(_buff, buffer_string, _str);
buffer_save(_buff, _filePath);
buffer_delete(_buff);
}

/// @desc Write a text to a file.
/// @param {string} filePath File path.
/// @param {any} str Description
function file_write_text(_filePath, str) {
function file_write_text(_filePath, _str) {
var _buff = buffer_create(0, buffer_grow, 1);
buffer_write(_buff, buffer_text, str);
buffer_write(_buff, buffer_text, _str);
buffer_save(_buff, _filePath);
buffer_delete(_buff);
}
Expand Down

0 comments on commit 9f9c365

Please sign in to comment.