• 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!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

HTML5 html5 freeze bug

S

splendidtank

Guest
HEY!

having a bug atm... when i launch the game in html5 format it works fine with the menu aswell as the cutsceene but, when the first level starts, the image freezes... the game still works tho, i know that because of the sounds. this does that i cant upload games to for example kongregate :( this video example is from kongregate but it happens inside gamemaker studio 2 too... really bugging me...




 

chmod777

Member
So if you disable the sounds, the game no longer freezes? Have you got any issue reported in the browser's console (better to check in debug mode)?
 
S

splendidtank

Guest
So if you disable the sounds, the game no longer freezes? Have you got any issue reported in the browser's console (better to check in debug mode)?
no, it still freezes... what i meant is that it is just the image that is frozen. the game works fine and i can hear that becouse of the sounds. no issue in browser console... gonna try debug mode :)
 
S

splendidtank

Guest
found out it was the camera! do anyone see anything wrong here? (Works fine when runned on windows)

/// @description update camera

//update destination
if (instance_exists(follow))
{
xTo = follow.x;
yTo = follow.y;

if ((follow).object_index == oPdead)
{
x = xTo;
y = yTo;
}
}

//Update object position
x += (xTo - x) / 25;
y += (yTo - y) / 25;


x = clamp(x,view_w_half+buff,room_width-view_w_half-buff);
y = clamp(y,view_h_half+buff,room_height-view_h_half-buff);
//screen shake
x += random_range(-shake_remain,shake_remain);
y += random_range(-shake_remain,shake_remain);
shake_remain = max(0,shake_remain-((1/shake_length)*shake_magnitude));

// update camera view
camera_set_view_pos(cam,x-view_w_half,y-view_h_half);
if (layer_exists("Mountains"))
{
layer_x("Mountains",x/2);
}
 
S

splendidtank

Guest
after som more digging i found out that the line under "//update camera view" is the issue
Code:
camera_set_view_pos(cam,x-view_w_half,y-view_h_half);
 
M

MarceloP

Guest
Are you sure that your "cam" variable has the correct id of a camera on HTML5? When and How are you getting the camera on your "cam" variable?

Another thing, your line:
Code:
//Update object position
x += (xTo - x) / 25;
y += (yTo - y) / 25;
is outside your "if (instance_exists(follow))", is that right? I mean, x and y should be updated by xTo and yTo even though follow doesn't exists?

Try checking the existence and the ID of the camera before trying to change it, sometimes in HTML5 things that are "miscoded" are shown more easily. I also think this should be in the programming section of the forum, not on the Tech Support, unless this is a bug, which doesn't seems to be xD
 
Hi splendidtank and any future readers with this same problem:

I had the exact same issue, and have identified the solution. I made a thread detailing my own experience, research, and experimentation on this problem, which can be found here: https://forum.yoyogames.com/index.p...w_pos-silently-freezes-on-html5-target.66494/

The problem lies with the screenshake code:
Code:
//screen shake
x += random_range(-shake_remain,shake_remain);
y += random_range(-shake_remain,shake_remain);
shake_remain = max(0,shake_remain-((1/shake_length)*shake_magnitude));
When shake_remain is 0 (as it always is when no screenshake is being applied), this code adds random_range(-0, 0) to x & y. This is completely fine on all platforms... except HTML5. While on all other platforms this simply adds 0 to the x & y values, changing nothing and having no effect, for whatever reason HTML5 & JavaScript are unable to process this math. When -0 or whatever other funky math identifier JavsScript is using is added to the x & y values, and then these values are used in camera_view_set_pos in any way, the HTML5 app freaks out, freezes, and crashes. By simply wrapping the screenshake code in an if-statement, this can be avoided. This is a minor (almost pointlessly minor) optimization on all other platforms, but JavaScript has a history of problems with math, and needs this extra protection.

Fixed version:
Code:
if(shake_remain > 0)
{
   // Screen shake
   x += random_range(-shake_remain, shake_remain);
   y += random_range(-shake_remain, shake_remain);
   shake_remain = max(0, shake_remain - shake_magnitude / shake_length);
}

camera_set_view_pos(cam, x - view_w_half, y - view_h_half);
While this is a fixable and avoidable problem, it certainly isn't expected or desired behavior, so hopefully this math problem will be fixed in the future.
 
Top