Jezla
Member
I'm implementing a local high score system for my new game using a ds_grid. When the player is out of lives, his name and score are saved to a ds_grid and displayed on a high score screen. The ds_grid is written to a string and saved to an ini file. When the game is starts, the ds_grid is created, then set by reading the ssaved string from the ini file. This works fine on a Windows export.
When I export to HTML5, the game freezes or hangs on the ds_grid_read call. The ds_grid is created in a controller object in an initialization room. Here's the oMainController's create event code:
If I comment out the ds_grid_read call, the game runs normally (except that the high scores are not loaded at the start). I've tried running opening the debug console in the browser, and while I can't make much sense of it, it seems to point me at a JSON. parse error. I looked that up and it seems to me that the string that the grid is written to is in an incorrect format or something. This is a little over my head. Am I correct in identifying the problem, and if so, how do I correct it so it works?
EDIT: I should also add that while the game freezes, it's not unresponsive. I can use a keyboard control to advance to the next room (which is not intentional, but is a happy mistake in this case), the start room. I can then proceed with the game, except that the controller's alarm[5] either doesn't run or doesn't execute (it changes the alpha variable value).
When I export to HTML5, the game freezes or hangs on the ds_grid_read call. The ds_grid is created in a controller object in an initialization room. Here's the oMainController's create event code:
Code:
///Initialize game variables
global.level = 1;
global.players = PLAYER_ONE; //One or two players, one by default
global.Waves = 1; //Number of waves, same as level (level 1 = 1 wave, level 2 = 2 waves, etc.)
global.waveNum = 5; //Number of enemies in each wave
global.PlayerOneLives = 5; //Players' lives
global.PlayerTwoLives = 5; //
global.enemy_count = 0;
global.spawn_count = 0;
global.spawn_stack = -1;
global.hp_stack = -1;
spawners = 0;
spawn_rate = (room_speed*3);
score = 0;
global.run = false; //whether the game is running or not
//View settings
base_width = 320;
base_height = 200;
width = base_width;
height = base_height;
//Draw settings
draw_set_color(c_white);
draw_set_font(fnt_main);
lvl_str = "";
draw_str = false;
alpha = 0; //alpha for start text
alarm[5] = room_speed; //alpha alarm
//States
enum st {
normal,
mad,
stunned,
death
}
//High Score indices
enum hs {
name = 0,
val = 1
}
//Create the High Score Table
global.HighScores = ds_grid_create(2, 10);
//Populate the grid
ini_open("hs.ini");
ds_grid_read(global.HighScores, ini_read_string("HS", "scores", ""));
ini_close();
//Go to Game
room_goto_next();
If I comment out the ds_grid_read call, the game runs normally (except that the high scores are not loaded at the start). I've tried running opening the debug console in the browser, and while I can't make much sense of it, it seems to point me at a JSON. parse error. I looked that up and it seems to me that the string that the grid is written to is in an incorrect format or something. This is a little over my head. Am I correct in identifying the problem, and if so, how do I correct it so it works?
EDIT: I should also add that while the game freezes, it's not unresponsive. I can use a keyboard control to advance to the next room (which is not intentional, but is a happy mistake in this case), the start room. I can then proceed with the game, except that the controller's alarm[5] either doesn't run or doesn't execute (it changes the alpha variable value).