How do I refresh properly my scoreboard?

0 favourites
  • 2 posts
  • Hi everyone o/ I need a little help adding more points when the player collides with an object.

    Here's the problem: I created an endless jump game, and the scoreboard is based on the height in meters. The more you jump, the more points you get. Now for example, I want to add an object that increases the score by +10 points. I need the scoreboard to keep increasing without stopping. The issue is that when I use the "Add to" function for my scoreboard spritefont, the score refreshes from "100 to 110" and stays frozen at 110. How can I prevent this? I just want to update the score, ensuring that the meters continue to increase from the added value (like 110) after player collide with the object that awarded the points. After this, the score needs to be updated on the scoreboard without stopping. Can anyone provide me with step-by-step procedures to solve this problem? It would be very helpful.

    I attach 1 screen to make everything clearer.

    Properties that I used of my spritefont scoreboard:

    Character Width: 50

    Character Height: 58

    Character Set: 0123456789

    Spacing Data:[[24," "],[40,"1"],[48,"023456789"]] (from json)

    I'm not sure if this can be helpful or not but I'll put it anyway.

    I understand that for many of you this may seem like a simple issue to resolve, but please note that I've only been using Construct for about a week, so I'm still a beginner. Thank you so much in advance to everyone o7

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I may not be the most qualified to answer this since I am not a programmer. I am positive that there are folks who will correct me, but I will try my best by writing down the pseudocode of what you have posted here.

    This is what the code reads like

    When the game runs - it runs through these instructions just once.

    1. it loads the global variable called 'scoreboard' and assigns the value 0 to it

    2. it loads the second global variable 'meters' and assigs the value 0 to it

    3. the system then runs its first event. The condition is if players y coordinate is less than 0, then tell the system to overwrite the variable 'meter' with a whole number.

    4. As long as Y is less than 0, the run the second condition - If the variable 'meters' is greater than the variable 'scoreboard', then tell the system to rewrite the variable 'scoreboard' with the value of 'meters'

    (i.e if meters is 3, rewrite scoreboard to 3)

    at the same moment of time, update the object "spritefont_scoreboard" with the new update score.

    Now, all these insurtcions are being execuited once. This means that when you run the game, these instructions just run one time only.

    I believe what you need here is a way for the system to check these conditions every x seconds and see if anything changed.

    My suggestion is to add a event condition on the top (line 24)

    System - check every 1 second (or even lesser if you need your game to update faster)

    and then add all those conditions from 24 to 26 under this condition

    What we are instructing the system to do is - for every 1 second, check events - is player's Y less than 0, if less what is the value of the meters (round to a whole number), check if meters is greater than scoreboard, if yes, update scoreboard with the same value as meter, and update the spritefont object to display this

    Now to address your second question - to add +10 points when the player collides with an object

    You can just write that as a separate event - if player collides with an object = add +10 to the scoreboard.

    this does not need to be in the events that you already have.

    Explanation:

    the variable scoreboard is getting its updated values from two places - one is if the player has collided with an object (+10) and the second one is if the meters variable is greater than scoreboard

    I'm a very visual person, so here's a mock of what the code would look like

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)