Problem with displaying results in HIGHSCORE

Hi everyone,
I have two problems with HIGHSCORE

1.
He only writes one record of my scores to HIGHSCORE, but should save me my TOP 10 scores.
I've already checked if the save file to HIGHSCORE exists..and this file is there.



2.
When I load the game and then quit the game and go to the HIGHSCORE room, the only result that saves disappears and nothing appears


Maybe one of you will guide me to what I'm doing wrong ... thank you


Here below code




scripts

score_add


GML:
///score_add(name,score)
if(ds_exists(highscores, ds_type_list)) {
    var m=ds_map_create();
    m[?"name"]=argument0
    m[?"score"]=argument1
    ds_list_add(highscores, m)
    ds_list_mark_as_map(highscores, ds_list_size(highscores)-1)
    score_sort()
   
    if(ds_list_size(highscores)>10) {
        ds_list_delete(highscores,10)
    }
}
[B]
score_save[/B]


GML:
///score_save

var f=file_text_open_write("save.dat");
if(f>-1) {
    var m=ds_map_create();
    ds_map_add_list(m,"default",highscores)
    var s=json_encode(m);
    file_text_write_string(f,s)
    file_text_close(f)
    //ds_map_destroy(m)
}
score_sort


GML:
///score_sort
if(ds_exists(highscores, ds_type_list) && ds_list_size(highscores)>1) {
    for(var _i=ds_list_size(highscores)-2; _i>=0; _i--) {
        var m1=highscores[|_i];
        var m2=highscores[|_i+1];
        if(m1[?"score"]<m2[?"score"]) {
            ds_list_replace(highscores,_i,m2)
            ds_list_replace(highscores,_i+1,m1)
            ds_list_mark_as_map(highscores, _i)
            ds_list_mark_as_map(highscores, _i+1)
        }
       
    }

obj_highscore (perssistent) in the first game room before the game starts

creacion code room

GML:
global.Score=0

globalvar highscores;
highscores=ds_list_create()

//Load points from disk
var f=file_text_open_read("save.dat")
if(f>-1) {
    var s=file_text_read_string(f)
    //show_debug_message(s)
    s=json_decode(s)  
    if(s!=-1 && ds_exists(s, ds_type_map) && ds_map_exists(s,"default")) {
        var m=s[?"default"];
        for(var _i=0; _i<ds_list_size(m); _i++) {
            if(ds_exists(m[|_i], ds_type_map)) {
                var _m=ds_map_create();
                ds_map_copy(_m, m[|_i])
                ds_list_insert(highscores, _i, _m)
                ds_list_mark_as_map(highscores, _i)
            }
        }
    }
    ds_map_destroy(s)
    file_text_close(f)
}

obj_game_manager

step


GML:
if (global.life <= 0)


{


    if (can_finish == false)
     {
     
   

    if (alarm[0] == -1) { // only start when it's not already counting down
        alarm[0] = 120; //


}



    } else {
        if (global.Score >= 500) //the condition must be met to write the minimum result to the table
        {
            var s=highscores[| ds_list_size(highscores) - 1];
           
            //Do the points qualify for the top 10
            if (ds_list_size(highscores) < 10 || s[?"score"] <= global.Score) {
           
                    room_goto(rm_save_score);
                    exit; // complete the execution of the step event in this frame
            }
        }
        room_goto(rm_game_over);
    }
}

obj_menu

step


GML:
if keyboard_check_pressed(vk_enter) {
    if(selected=0) {
        room_goto(room_stage1)
    } else if(selected=1)  {
   
     
       if(file_exists("save.dat")){
     
            game_load( "Save.dat" );
         
       } else {
          show_message("Cannot find Save.dat file. Please start a new game.");
        }
        audio_stop_sound (sounds_global);
    } else if(selected=2) {
        room_goto(room_highscore)
    } else if(selected=3) {
        room_goto(room_options)
    } else if(selected=4) {
        room_goto(room_credits)
    } else if(selected=5) {
        game_end()
    }
}
 
Last edited:

Yal

šŸ§ *penguin noises*
GMC Elder
Why don't you use the built-in highscore system that handles all of this for you automatically?
 

Yal

šŸ§ *penguin noises*
GMC Elder
Then this version of the manual should have the relevant info:


Highscores are stored in a file in the game's appdata folder between runs automatically (you don't need to do anything specific to update it). highscore_add submits a highscore (and automatically sorts the table, ignoring the submission if it didn't make it onto the list), and you can read names and scores to display the list with highscore_name / highscore_value. The list is 1-indexed so the highest score is obtained with highscore_value(1)
 
Thank you..but what am I going to do with my highscore now if I have it implemented? I would have to remove everything and do some extra work ...
 
I think the problem might be here ..
because this was the only place where I modified the code ... Earlier in the code there was no condition that if a player gets 500 points, it is entered into the scoreboard after the game is over.

GML:
if (global.life <= 0)


{


    if (can_finish == false)
     {
    
  

    if (alarm[0] == -1) { // only start when it's not already counting down
        alarm[0] = 120; //


}



    } else {
        if (global.Score >= 500) //the condition must be met to write the minimum result to the table
        {
            var s=highscores[| ds_list_size(highscores) - 1];
          
            //Do the points qualify for the top 10
            if (ds_list_size(highscores) < 10 || s[?"score"] <= global.Score) {
          
                    room_goto(rm_save_score);
                    exit; // complete the execution of the step event in this frame
            }
        }
        room_goto(rm_game_over);
    }
}

earlier the code looked like this ... and here I was creating a list of the top 10 results ... But I wanted to keep the player meeting the 500 point point condition so that it was entered into the results table.
this solution below worked and made a top 10 list of results


GML:
if (global.life=0)
{
game_end();
var s=highscores[|ds_list_size(highscores)-1];
//top 10 points
if(ds_list_size(highscores)<10 || s[?"score"]<=global.Score) {
    room_goto( rm_save_score );
} else {
    room_goto( rm_game_over );
}
}

how to get it all together so that I can have more than one results . and that the 500 point condition is met, so that after the game is finished, it will be entered into the results table?

Thanks
 
Last edited:
I will refresh this my thread

Hi everyone,
I have two problems with HIGHSCORE

1.
He only writes one record of my scores to HIGHSCORE, but should save me my TOP 10 scores.
I've already checked if the save file to HIGHSCORE exists..and this file is there.



2.
When I load the game and then quit the game and go to the HIGHSCORE room, the only result that saves disappears and nothing appears

earlier I forgot to throw in the whole result table code .. Maybe some of you will find an error .. and help me guide me where the cause of this error is

I don't know why I don't write more than one result on the scoreboard ... Before that everything worked ... it's hard for me to find the cause


I'm sorry that I pasted such a large amount of code ... but I have been working on this problem for a long time and I cannot locate the cause

scripts



score_add

GML:
///score_add(name,score)
if(ds_exists(highscores, ds_type_list)) {
    var m=ds_map_create();
    m[?"name"]=argument0
    m[?"score"]=argument1
    ds_list_add(highscores, m)
    ds_list_mark_as_map(highscores, ds_list_size(highscores)-1)
    score_sort()
  
    if(ds_list_size(highscores)>10) {
        ds_list_delete(highscores,10)
    }
}

score_save


GML:
///score_save

var f=file_text_open_write("save.dat");
if(f>-1) {
    var m=ds_map_create();
    ds_map_add_list(m,"default",highscores)
    var s=json_encode(m);
    file_text_write_string(f,s)
    file_text_close(f)
    //ds_map_destroy(m)
}
score_sort

GML:
///score_sort
if(ds_exists(highscores, ds_type_list) && ds_list_size(highscores)>1) {
    for(var _i=ds_list_size(highscores)-2; _i>=0; _i--) {
        var m1=highscores[|_i];
        var m2=highscores[|_i+1];
        if(m1[?"score"]<m2[?"score"]) {
            ds_list_replace(highscores,_i,m2)
            ds_list_replace(highscores,_i+1,m1)
            ds_list_mark_as_map(highscores, _i)
            ds_list_mark_as_map(highscores, _i+1)
        }
      
    }
scr_text_input

GML:
var code, def, key, char, count, value, update;


if(keyboard_check(vk_nokey)) {return (true);}

update = argument0;         // ds list index
count = 20;               
def = "Ann Onimous";     
value = ds_list_find_value(global.CH_hiscore_name,update);
keycode = keyboard_lastkey; 

if(keycode == vk_escape || keycode == vk_enter) {
  io_clear();
  if(value == "(Enter Name)" || value == ""){
    ds_list_replace(global.CH_hiscore_name,update,def);
  }
  return (false);
}

if(keycode == vk_delete){

  if(value == def){
    ds_list_replace(global.CH_hiscore_name,update,"");
  }
  io_clear();

  return (true);
}

if(keycode == vk_backspace){

  char = string_copy(value,0,string_length(value)-1);
  ds_list_replace(global.CH_hiscore_name,update,char);
  io_clear()

  return (true);
}

if(string_length(value) >= count){

  return (true);
}

if(string_pos("(",value) > 0 || string_pos(")",value) > 0){
  ds_list_replace(global.CH_hiscore_name,update,"");
  value = "";
  blink = 0;
}


if(keycode > 31 && keycode < 123){

  if(keycode > 47 && keycode < 58 || keycode > 64 || keycode == 32){
  
   str = "";
    if(value == def){
      ds_list_replace(global.CH_hiscore_name,update,"");
    }
    char = value+keyboard_lastchar;
    ds_list_replace(global.CH_hiscore_name,update,char);
  }
}

io_clear();

return (true);

scr_hiscore_save


GML:
// scr_hiscore_save();
var handle, data;

if(file_exists(global.CH_score_fname)){
  file_delete(global.CH_score_fname);
}
data = ds_list_write(global.CH_hiscore_name)+chr(13)+chr(10);
data += ds_list_write(global.CH_hiscore_extra)+chr(13)+chr(10);
data += ds_list_write(global.CH_hiscore_value)+chr(13)+chr(10);
handle = file_text_open_write(global.CH_score_fname);
file_text_write_string(handle,data);
file_text_close(handle);
file_find_close();
// scr_hiscore_config();         // Reset

scr_hiscore_load


GML:
var result, handle, data;

result = false;
if(file_exists(global.CH_score_fname)){
  handle = file_text_open_read(global.CH_score_fname);
  data = file_text_read_string(handle);
  ds_list_read(global.CH_hiscore_name,data);
  file_text_readln(handle);
  data = file_text_read_string(handle);
  ds_list_read(global.CH_hiscore_extra,data);
  file_text_readln(handle);
  data = file_text_read_string(handle);
  ds_list_read(global.CH_hiscore_value,data);
  file_text_readln(handle);
  file_text_close(handle);
  result = true;
}
file_find_close();
return (result);

scr_hiscore_initialize


GML:
scr_hiscore_config(); // Configuring custom settings
//Create your own highscore entries
global.CH_hiscore_name = ds_list_create();
global.CH_hiscore_extra = ds_list_create();
global.CH_hiscore_value = ds_list_create();


if(file_exists(global.CH_score_fname)){
  // file_delete(global.CH_score_fname);
  scr_hiscore_load(); // Load high scores
}
if(!file_exists(global.CH_score_fname)){
  for(i=0; i<10; i+=1){
    ds_list_add(global.CH_hiscore_name,"Player "+string(i+1));
    ds_list_add(global.CH_hiscore_extra,global.CH_extra_default);
    ds_list_add(global.CH_hiscore_value,1000-(100*i));
  }
  scr_hiscore_save(); // Saving default results
}

scr_hiscore_config


GML:
var extra, decimals, reset_score, def_extra;
score = 0;
extra = 0;                            // Extra score points
decimals = 2;                         // Extra decimal points
def_extra = 0;                        // Initial default value extra result
reset_score = false;                  // Resets the result when it returns true
global.CH_score_fname = "Scores.dat"; // File name to save as
global.CH_score_commas = true;        // Using commas in the result display

global.CH_extra_score = def_extra;    // Additional point value
// Defining points in the table
global.CH_header_name = "Name";
global.CH_header_extra = "Coins";
global.CH_header_score = "Score";

/*
        You don't need to change below to do some tests to avoid incompatibility errors
*/
if(is_real(extra)){
  if(is_string(def_extra)){
    global.CH_extra_default = 0;
    global.CH_extra_decimals = 0;
  }else{
    global.CH_extra_default = def_extra;
    global.CH_extra_decimals = decimals; 
  }
}else{
  if(is_real(def_value)){
    global.CH_extra_default = string(def_extra);
    global.CH_extra_decimals = 0;
  }else{
    global.CH_extra_default = def_extra;
    global.CH_extra_decimals = 0;
  }
}
// Checking and removing old data results
if(reset_score && file_exists(global.CH_score_fname)){
  file_delete(global.CH_score_fname);
}

scr_add_hiscore


GML:
var ndx = -1;

for(i=0; i<10; i+=1){
  if(score > ds_list_find_value(global.CH_hiscore_value,i)){
    ndx = i;
    break;
  }
}
if(ndx > -1){
/*
  New index entry
   We should be able to use ds_list but for some reason
   Studio sets the same entry twice which destroys the saved data.
   Instead, we will manually move all the highscores down the list and add
   a new blank entry of which is only 10
*/
  for(i=9; i>ndx; i-=1){
    ds_list_replace(global.CH_hiscore_name,i,ds_list_find_value(global.CH_hiscore_name,i-1));
    ds_list_replace(global.CH_hiscore_extra,i,ds_list_find_value(global.CH_hiscore_extra,i-1));
    ds_list_replace(global.CH_hiscore_value,i,ds_list_find_value(global.CH_hiscore_value,i-1));
  }
  //We add our new entry to the ndx items
  ds_list_replace(global.CH_hiscore_name,ndx,"(Enter Name)");
  ds_list_replace(global.CH_hiscore_extra,ndx,global.CH_extra_score);
  ds_list_replace(global.CH_hiscore_value,ndx,score);
}
return (ndx); // Returns items



scr_add_commas


GML:
/// scr_add_commas(value);
/*
   Returns a string with a comma as a thousand separator
   (May be used over real numbers)
   val = scr_add_commas(10000); // returns a value as a string "10,000"
   val = scr_add_commas("1234567") // returns a value as "1,234,567"
*/
var strScore, n;

//Value string representation.
if(!is_real(argument0)){
  // a string if it was specified to be true value
  strScore = argument0;
}else{
  strScore = string(argument0);
}
n = string_length(strScore)-2;
// Loop through String in reverse order
while (n > 1) {
  strScore = string_insert(",",strScore,n);
  n -= 3;
}
return (strScore);

and now obj_highscore which is placed in the first room before the game starts


obj_highscore

create


GML:
global.Score=0

globalvar highscores;
highscores=ds_list_create()

//Load points from disk
var f=file_text_open_read("save.dat")
if(f>-1) {
    var s=file_text_read_string(f)
    //show_debug_message(s)
    s=json_decode(s) 
    if(s!=-1 && ds_exists(s, ds_type_map) && ds_map_exists(s,"default")) {
        var m=s[?"default"];
        for(var _i=0; _i<ds_list_size(m); _i++) {
            if(ds_exists(m[|_i], ds_type_map)) {
                var _m=ds_map_create();
                ds_map_copy(_m, m[|_i])
                ds_list_insert(highscores, _i, _m)
                ds_list_mark_as_map(highscores, _i)
            }
        }
    }
    ds_map_destroy(s)
    file_text_close(f)
}

in the creacion code in the first room behind him the game will start

GML:
global.checkpoint = noone;
global.checkpointR = 0;
global.checkpointx = 0;
global.checkpointy = 0;

obj_loder which runs the highscore script located in the main menu of the game

obj_loader

events game Start



GML:
scr_hiscore_initialize();

obj_game_controller

step

here added a condition that the player must collect at least 500 points to be entered in the scoreboard ..



GML:
if (global.life <= 0)


{


    if (can_finish == false)
     {
    
  

    if (alarm[0] == -1) { // only start when it's not already counting down
        alarm[0] = 120; //


}



    } else {
        if (global.Score >= 500) //Check if the result is suitable for highscore, but the point condition must be met
        {
            var s=highscores[| ds_list_size(highscores) - 1];
          
            //Do the points qualify for the top 10
            if (ds_list_size(highscores) < 10 || s[?"score"] <= global.Score) {
          
                    room_goto(rm_save_score);
                    exit; // complete the execution of the step event in this frame
            }
        }
        room_goto(rm_game_over);
    }
}

obj_menu_save_score in the room rm_save_score


create



GML:
gp_up=0
gp_down=0
gp_left=0
gp_right=0

player_name=""

selected_column=0
selected_row=0

klawa[0,0]="1"
klawa[0,1]="2"
klawa[0,2]="3"
klawa[0,3]="4"
klawa[0,4]="5"
klawa[0,5]="6"
klawa[0,6]="7"
klawa[0,7]="8"
klawa[0,8]="9"
klawa[0,9]="0"
klawa[0,10]="-"
klawa[0,11]="+"

klawa[1,0]="Q"
klawa[1,1]="W"
klawa[1,2]="E"
klawa[1,3]="R"
klawa[1,4]="T"
klawa[1,5]="Y"
klawa[1,6]="U"
klawa[1,7]="I"
klawa[1,8]="O"
klawa[1,9]="P"
klawa[1,10]="@"
klawa[1,11]="$"

klawa[2,0]="A"
klawa[2,1]="S"
klawa[2,2]="D"
klawa[2,3]="F"
klawa[2,4]="G"
klawa[2,5]="H"
klawa[2,6]="J"
klawa[2,7]="K"
klawa[2,8]="L"
klawa[2,9]=";"
klawa[2,10]="'"
//klawa[2,11]="*"

klawa[3,0]="Z"
klawa[3,1]="X"
klawa[3,2]="C"
klawa[3,3]="V"
klawa[3,4]="B"
klawa[3,5]="N"
klawa[3,6]="M"
klawa[3,7]=","
klawa[3,8]="."
klawa[3,9]="?"
klawa[3,10]="!"

options[0]="Delete"
options[1]="Space"
options[2]="Save"

mode=0

animation_speed=room_speed/4
for(var r=0; r<array_height_2d(klawa); r++) {
    for(var c=0; c<array_length_2d(klawa,r); c++) {
        animation[r,c]=0
    }
}

for(var r=0; r<array_length_1d(options); r++) {
    animation_o[r]=0
}
step

GML:
if(abs(gamepad_axis_value(0,gp_axislv))<0.3 && !keyboard_check(vk_anykey)){
    gp_up=0
    gp_down=0
}
  
if(abs(gamepad_axis_value(0,gp_axislh))<0.3 && !keyboard_check(vk_anykey)){
    gp_left=0
    gp_right=0
}

if(keyboard_check_pressed(vk_down) || gamepad_button_check_pressed(0,gp_padd) || (gamepad_axis_value(0,gp_axislv)>0.7 && !gp_up)) {
    if(mode=0) {
        selected_row++
        if(selected_row>=array_height_2d(klawa)-1) {
            selected_row=array_height_2d(klawa)-1
        }
        if(selected_column>=array_length_2d(klawa, selected_row)) {
            selected_column=array_length_2d(klawa, selected_row)-1
        }
    } else {
        selected_row++
        if(selected_row>=array_length_1d(options)-1) {
            selected_row=array_length_1d(options)-1
        }
    }
    gp_up=true
}

if(keyboard_check_pressed(vk_up) || gamepad_button_check_pressed(0,gp_padu) || (gamepad_axis_value(0,gp_axislv)<-0.7 && !gp_down)) {
    selected_row--
    if(selected_row<0) {
        selected_row=0
    }
    gp_down=true
}

if(keyboard_check_pressed(vk_right) || gamepad_button_check_pressed(0,gp_padr) || (gamepad_axis_value(0,gp_axislh)>0.7 && !gp_right)) {
    if(mode=0) {
        selected_column++
        if(selected_column>=array_length_2d(klawa, selected_row)) {
            selected_column=array_length_2d(klawa, selected_row)-1
            mode=1
            selected_row=1
        }
    }
    gp_right=true
}

if(keyboard_check_pressed(vk_left) || gamepad_button_check_pressed(0,gp_padl) || (gamepad_axis_value(0,gp_axislh)<-0.7 && !gp_left)) {
    if(mode=0) {
        selected_column--
        if(selected_column<0) {
            selected_column=0
        }
    } else {
        mode=0
    }
    gp_left=true
}



if(keyboard_check_pressed(vk_backspace) || gamepad_button_check_pressed(0,gp_face2)) {
    player_name=string_copy(player_name, 1,string_length(player_name)-1)
}

if(keyboard_check_pressed(vk_enter) || gamepad_button_check_pressed(0,gp_face1)) {
    if(mode=0) {
        player_name+=klawa[selected_row,selected_column]
    } else {
        if(selected_row=0) {
            player_name=string_copy(player_name, 1,string_length(player_name)-1)
        } else if(selected_row=1) {
            player_name+=" "
        } else if(selected_row=2) {
            score_add(player_name,global.Score)
            score_save()
            room_goto(rm_highscore)
        }
    }
}

draw


GML:
draw_set_valign(1)
draw_set_halign(1)
draw_set_font(font_highscore)

var line_height=ceil(string_height("M")*1.1);
var line_width=ceil(string_width("M")*1.1);

for(var r=0; r<array_height_2d(klawa); r++) {
    for(var c=0; c<array_length_2d(klawa,r); c++) {
        if(mode=0 && r=selected_row && c=selected_column) {
            //Selected option
            animation[r,c]=clamp(animation[r,c]+(1/animation_speed),0,1)
        } else {
            animation[r,c]=clamp(animation[r,c]-(1/animation_speed),0,1)
        }
        var color=merge_colour(c_white,c_teal,animation[r,c])
    
           draw_text_transformed_color((room_width/2)-(array_length_2d(klawa,0)*line_width/2)+(line_width*c)+(line_width/2*r),y+(line_height*r)+50,klawa[r,c],1+animation[r,c]/5,1+animation[r,c]/5,0,color,color,color,color,1)
     }
  
}

draw_set_halign(0)
for(var i=0; i<array_length_1d(options); i++) {
    if(mode=1 && i=selected_row) {
        animation_o[i]=clamp(animation_o[i]+(1/animation_speed),0,1)
    } else {
        animation_o[i]=clamp(animation_o[i]-(1/animation_speed),0,1)
    }
    var color=merge_colour(c_white,c_teal,animation_o[i])
    var a=1+animation_o[i]/5;
    draw_text_transformed_color((room_width/2)+(array_length_2d(klawa,0)*line_width/2)+64,y+(line_height*i)+50,options[i],a,a,0,color,color,color,color,1)
}

draw_set_halign(1)
var color=c_teal;

draw_text_transformed_color(room_width/2,y+200,"You got "+string(global.Score)+" points",1,1,0,color,color,color,color,1)
draw_text_transformed_color(room_width/2,y+230,"Type your name",1,1,0,color,color,color,color,1)
draw_text_transformed_color(room_width/2,y+15,""+player_name,1,1,0,color,color,color,color,1)


draw_set_halign(1)
//var color=c_white;
//draw_text_transformed_color(room_width/2,y-40,"Save your name!",1,1,0,color,color,color,color,1)

for (var i = 1; i <= inscription_shadow_width; i++) {
        //draw_text_shadow(room_width/2, y-50, "Save your name!", font1, i, c_black, c_white, -1, 120);
        draw_text_shadow(room_width/2, y-50, "Save your name!", font1, i, c_black, -1, 300,1,1,0, c_white,c_white,c_white,c_white, 1 );
    }

obj_menu_score_3F in the room rm_highscore

step



GML:
if(keyboard_check_pressed(vk_enter) || keyboard_check_pressed(vk_escape) || gamepad_button_check_pressed(0,gp_face1) || gamepad_button_check_pressed(0,gp_face2)) {
    if(global.Score > 0 ) {
        room_goto(rm_game_over)
    } else {
        room_goto(roo_menu)
    } 
}

draw


GML:
draw_set_valign(1)
draw_set_halign(1)
draw_set_font(font1)

var line_height=ceil(string_height("M")*0.5)

if(ds_exists(highscores,ds_type_list)) {
    for(var i=0; i<ds_list_size(highscores); i++) {
        var color=c_teal
        var s=highscores[|i];
        var name=s[?"name"];
        var sc=s[?"score"];
        draw_text_transformed_color(room_width/2,y+(line_height*i),string(name)+" - "+string(sc)+" points",0.5,0.5,0,color,color,color,color,1)
    }
}

and main menu room obj_menu_3F
where the game is loaded, e.g. from the save.dat file


step


GML:
if(abs(gamepad_axis_value(0,gp_axislv))<0.3 && !keyboard_check(vk_anykey))
    {
    gp_up=0
    gp_down=0
    }
  
if(abs(gamepad_axis_value(0,gp_axislh))<0.3 && !keyboard_check(vk_anykey))
    {
    gp_left=0
    gp_right=0
    }

if(keyboard_check_pressed(vk_down) || gamepad_button_check_pressed(0,gp_padd) || (gamepad_axis_value(0,gp_axislv)>0.7 && !gp_up)) {
    selected++
    if(selected>=ds_list_size(options)) {
        selected=ds_list_size(options)-1
    }
    gp_up=true
}

if(keyboard_check_pressed(vk_up) || gamepad_button_check_pressed(0,gp_padu) || (gamepad_axis_value(0,gp_axislv)<-0.7 && !gp_down)) {
    selected--
    if(selected<0) {
        selected=0
    }
    gp_down=true
}

if(keyboard_check_pressed(vk_enter) || gamepad_button_check_pressed(0,gp_face1)) {
    if(selected=0) {
        room_goto(rm_difficulty)
    } else if(selected=1)  {
  
       if(file_exists("save.dat")){
    
    
            game_load( "Save.dat" );
        
       } else {
          show_message("Cannot find save.dat file. Please start a new game."); 
        }
        audio_stop_sound (sounds_menu);
    } else if(selected=2) {
        room_goto(rm_highscore)
    } else if(selected=3) {
        room_goto(rm_options)
    } else if(selected=4) {
        room_goto(rm_credits)
    } else if(selected=5) {
        game_end()
    }
}
 
Last edited:
Top