how to make score

Discussion in 'Programming' started by Aite, Jan 16, 2020.

Tags:
  1. Aite

    Aite Member

    Joined:
    Jan 13, 2020
    Posts:
    4
    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;
     
  2. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    219
    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!
     
  3. TheSly

    TheSly Member

    Joined:
    Jan 16, 2017
    Posts:
    1,016
    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;
    
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,372
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice