Wednesday, May 19, 2021

【GAMEMAKER】Highscore

 Information about object: objHighScore

Sprite: sprController
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
set variable ScoreName to "Score1"
set variable ShowX to 250
set variable ShowY to 50
set variable ShowScore to false
execute code:

Score = 0
Keyboard Event for <Space> Key:
execute code:

//Set Score to the players score, then call AddScore.
Score = get_integer("Type in the score",0);
if (Score > 0){AddScore();}
Draw Event:
execute code:

if ShowScore = false exit;
draw_rectangle(ShowX,ShowY,ShowX+150,ShowY+250, true);

GetScores(objHighScore.ScoreName);

for (i=1; i<11; i+=1) {
  if ScoreName[i]="" then ScoreName[i]="**Nobody**";
  draw_text(ShowX+10,ShowY-20+(i*25),ScoreName[i]);
  draw_text(ShowX+100,ShowY-20+(i*25),string(ScoreValue[i]));
}
Key Press Event for H-key Key:
set variable ShowScore to false
Key Press Event for S-key Key:
set variable ShowScore to true

No comments:

Post a Comment