• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HTML5 [Solved. Glitch?] Path changing functions in HTML5

MeBoingus

Member
Hi guys,

I'm running into an issue using path changing functions in HTML5.

I am making a simple test project that uses this code:

Create:
Code:
move_path = path_add();
path_set_closed(move_path, 0);
Step:
Code:
if (mouse_check_button_released(mb_left))
{
    path_clear_points(move_path);
    path_add_point(move_path, x, y, 100);
    path_add_point(move_path, mouse_x, mouse_y, 100);
    path_start(move_path, 5, 0, 0);
}

if (path_position == 1 && path_get_number(move_path) > 0)
{
    path_end();
    path_clear_points(move_path);
}
To handle a simple "click to move" system. I know that there are other ways of achieving this, but I am simple using this as a demonstration for my issue.


In Windows, when the mouse is clicked - the object moves to that location and stops.
In HTML5, when the mouse is clicked - the object simply vanishes.


I added this code to the Spacebar Pressed event:
Code:
show_message("X: " + string(x) + "#Y: " + string(y));
In Windows - the object shows a correct X and Y value.
In HTML5 - the object outputs a value such as:
X: 100100116.8341732483NaN
Y: 1009937.187918894826NaN
And an extra "NaN" is appended to the end of the value every time the mouse is clicked.


Any idea as to why this is happening?
 

chmod777

Member
Trying your code in both GMS1 and GMS2 (runtime 2.1.4.218), I cannot reproduce this issue. So maybe it's just a matter of upgrading.
 

MeBoingus

Member
This is very unusual.

It turns out that this is due to the object's x and y position being read as that incredibly unusual float value.

However, if I add the path point at x - 1 and y - 1, it works perfectly.


The objects are created by a loop in an async event, that is the only 'unusual' thing going on. Other than that I cannot fathom what could be causing this.


EDIT:

After some further investigation; this doesn't even solve it. The first time the mouse is clicked, the path is created from the correct location to the mouse_x and mouse_y.

The 2nd time - the random coordinates to mouse_x and mouse_y.

The 3rd time onwards - 0,0 to the mouse_x and mouse_y.


I am running the latest version of GMS1.


EDIT EDIT:

The most unusual thing was happening. I was originally using a custom string_split script to split an x and y value that I was getting from a URL. I was neglecting to convert these values to real, and instead setting the x and y value of the object to the string of each position.

On PC this caused no hang-ups and worked fine, and on HTML5 it absolutely destroyed everything.


Very unusual. Not to say that it should have worked at all, but surely an error should have been thrown by at least one version of the compiled code?
 
Last edited:
Top