Skip to content

Commit

Permalink
Added draw_get_resolutions(), trace() and particle functions
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxyOfJungle committed Jun 1, 2023
1 parent e6f0138 commit bf56336
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 49 deletions.
29 changes: 3 additions & 26 deletions objects/obj_tests/Create_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ tests = 0;
pseudo_action_list = [];


array = array_create_ext(3, function(index) {return index;});

show_debug_message(array);
trace("Hello World!");


//show_message(aspect_ratio_gcd(1280, 1280));
Expand All @@ -43,8 +41,8 @@ clipboard_set_text(string(files.GetContents()));



//audio = audio_create_stream_wav("music_s16_pcm_48000.wav");
//audio_play_sound(audio, 0, false);
//sound_struct = audio_load_wav("explosion3.wav");
//audio_play_sound(sound_struct.audio, 0, false);



Expand All @@ -61,12 +59,6 @@ var aa = struct_get_variable(struct, "array", 2);
show_debug_message(aa);*/


//days = undefined;
//day = 10;
//day = days ?? day;

//show_debug_message(day);



/*var _list = ds_list_create();
Expand Down Expand Up @@ -103,18 +95,3 @@ show_debug_message(ds_debug_print(_queue, ds_type_queue));*/


















34 changes: 17 additions & 17 deletions objects/obj_tests/Draw_0.gml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ draw_debug_button(40, 40, "TEST");
draw_debug_slider(40, 100, 200, "Test", 0.5, -5, 5);*/


var _a = smoothstep(0, 255, gui_mouse_x_normalized*255); // returns 0 - 1
var _b = linearstep(0, 255, gui_mouse_x_normalized*255); // returns 0 - 1
var _c = lerp(0, 255, gui_mouse_x_normalized); // returns 0 - 255
var _d = step(0.5, gui_mouse_x_normalized); // returns 0 or 1
var _e = relerp(0, 1, gui_mouse_x_normalized, 0, room_width); // returns 0 - 255

draw_text(10, 200, _a);
draw_text(10, 220, _b);
draw_text(10, 240, _c);
draw_text(10, 260, _d);
draw_text(10, 280, _e);

draw_circle(room_width*_a, 200+10, 8, true);
draw_circle(room_width*_b, 220+10, 8, true);
draw_circle(room_width*(_c/255), 240+10, 8, true);
draw_circle(room_width*_d, 260+10, 8, true);
draw_circle(_e, 280+10, 8, true);
//var _a = smoothstep(0, 255, gui_mouse_x_normalized*255); // returns 0 - 1
//var _b = linearstep(0, 255, gui_mouse_x_normalized*255); // returns 0 - 1
//var _c = lerp(0, 255, gui_mouse_x_normalized); // returns 0 - 255
//var _d = step(0.5, gui_mouse_x_normalized); // returns 0 or 1
//var _e = relerp(0, 1, gui_mouse_x_normalized, 0, room_width); // returns 0 - 255

//draw_text(10, 200, _a);
//draw_text(10, 220, _b);
//draw_text(10, 240, _c);
//draw_text(10, 260, _d);
//draw_text(10, 280, _e);

//draw_circle(room_width*_a, 200+10, 8, true);
//draw_circle(room_width*_b, 220+10, 8, true);
//draw_circle(room_width*(_c/255), 240+10, 8, true);
//draw_circle(room_width*_d, 260+10, 8, true);
//draw_circle(_e, 280+10, 8, true);


/*var _xx = 400;
Expand Down
2 changes: 2 additions & 0 deletions objects/obj_tests/Draw_64.gml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

draw_text(10, 10, DELTA_TIME_SCALE);

draw_get_resolutions(10, 10);
8 changes: 4 additions & 4 deletions objects/obj_tests/Step_0.gml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

if keyboard_check_pressed(vk_escape) game_end();

if keyboard_check(ord("U")) DELTA_TIME_SCALE -= 0.02;
if keyboard_check(ord("I")) DELTA_TIME_SCALE += 0.02;
//if keyboard_check(ord("U")) DELTA_TIME_SCALE -= 0.02;
//if keyboard_check(ord("I")) DELTA_TIME_SCALE += 0.02;

if keyboard_check_pressed(ord("J")) test -= 1;
if keyboard_check_pressed(ord("K")) test += 1;
//if keyboard_check_pressed(ord("J")) test -= 1;
//if keyboard_check_pressed(ord("K")) test += 1;



Expand Down
38 changes: 36 additions & 2 deletions scripts/__tgm_core/__tgm_core.gml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
..............................
Special Thanks, contributions:
YellowAfterLife, Cecil, TheSnidr, Xot, Shaun Spalding, gnysek, icuurd12b42, DragoniteSpam,
Grisgram.
Grisgram, There is no Red color, JuJu Adams.
(authors' names written in comment inside the functions used)
Supporters:
Expand All @@ -22,7 +22,7 @@
/*
MIT License
Copyright (c) 2022 Mozart Junior (FoxyOfJungle)
Copyright (c) 2023 Mozart Junior (FoxyOfJungle)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -282,6 +282,14 @@ function point_in_arc(px, py, x, y, angle, dist, fov) {
return (point_distance(px, py, x, y) < dist && abs(angle_difference(angle, point_direction(x, y, px, py))) < fov/2);
}

function point_in_parallelogram(px, py, parallelogram) {
// in first
if point_in_triangle(px, py, parallelogram[0], parallelogram[1], parallelogram[2], parallelogram[3], parallelogram[6], parallelogram[7]) return true;
// in second
if point_in_triangle(px, py, parallelogram[4], parallelogram[5], parallelogram[2], parallelogram[3], parallelogram[6], parallelogram[7]) return true;
return false;
}

/// @desc This function prevents it from returning 0, returning another value instead, if this happen.
/// @param {Real} value The value.
/// @param {Real} zero_value Value to return.
Expand Down Expand Up @@ -1051,6 +1059,17 @@ function print() {
}


#macro trace __trace(_GMFILE_ + "/" + _GMFUNCTION_ + ":" + string(_GMLINE_) + ": ")
function __trace(_location) {
// credits: "There is no Red color", "JuJu Adams"
static __struct = {};
__struct.__location = _location;
return method(__struct, function(_str) {
show_debug_message(__location + ": " + string(_str));
});
}


function print_format(msg, values_array) {
var _final_string = "", _vapos = 0;
var i = 1, isize = string_length(msg);
Expand Down Expand Up @@ -2598,6 +2617,21 @@ function aspect_ratio_maintain(resolution_x, resolution_y, size_x, size_y) {
//}


function draw_get_resolutions(x, y, extra_str="") {
var _sep = "";//string_repeat("-", 40);
var _text =
$"display_get_width: {display_get_width()} \ndisplay_get_height: {display_get_height()} | {display_get_width()/display_get_height()}\n{_sep}\n" +
$"window_get_width: {window_get_width()} \nwindow_get_height: {window_get_height()} | {window_get_width()/window_get_height()}\n{_sep}\n" +
$"browser_width: {browser_width} \nbrowser_height: {browser_height} | {browser_width/browser_height}\n{_sep}\n" +
$"application_get_position(): {application_get_position()} | {(application_get_position()[2]-application_get_position()[0])/(application_get_position()[3]-application_get_position()[1])}\n{_sep}\n" +
$"display_get_gui_width: {display_get_gui_width()} \ndisplay_get_gui_height: {display_get_gui_height()} | {display_get_gui_width()/display_get_gui_height()}\n{_sep}\n" +
$"application_surface width: {surface_get_width(application_surface)} \napplication_surface height: {surface_get_height(application_surface)} | {surface_get_width(application_surface)/surface_get_height(application_surface)}\n{_sep}\n" +
$"view_wport0: {view_wport[0]} \nview_hport0: {view_hport[0]} | {view_wport[0]/view_hport[0]}\n{_sep}\n" +
$"camera_get_view_width0: {camera_get_view_width(view_camera[0])} \ncamera_get_view_height0: {camera_get_view_height(view_camera[0])} | {camera_get_view_width(view_camera[0])/camera_get_view_height(view_camera[0])}\n{_sep}\n" + string(extra_str);
draw_text(x, y, _text);
}


/// @desc Saves a HDR surface to a image file.
/// @param {Id.Surface} surface_id The surface id.
/// @param {string} fname The name of the saved image file.
Expand Down

0 comments on commit bf56336

Please sign in to comment.