how to make score

A

Aite

Guest
Hello I want my score to increase each second. I'm new with coding so I don't know. That's with what i came up but it stays with "Score: 1".
obj_game

Create:
score =1;

Draw:
case rm_game:
draw_text(20, 20,"SCORE: " +string(score));
break;
 
R

robproctor83

Guest
If your game is 60fps then you just need to make an alarm that triggers once every 60 steps. So in step u just say if(!alarm_get(0)) alarm[0] = 60!
 

Slyddar

Member
You are drawing the score, and you've set it to 1. You now need some code which increases the score. If you want to increase the score by 1 per second, you could use an alarm, which will run it's code at the end of a set time. In the create event add:
CREATE
Code:
alarm[0] = room_speed;
Then create an alarm 0 event, with this:
ALARM 0
Code:
score += 1;
alarm[0] = room_speed;
This will then add 1 to the score, and set the alarm to go off again in 1 second. You can also add a case statement if required, to only add to the score if you are in the rm_game room.

Code:
switch(room) {
case rm_game:
  score += 1;
break;
}
alarm[0] = room_speed;
 

TheouAegis

Member
time = current_second;

if abs(current_second - time) {
time = current_second;
score++; }


Or if you use get_timer(), check if the abs() is greater than 999999.
 
Top