Jump to content

I need you.


Foobar
 Share

Recommended Posts

 

Hello, here I created game but I have a problem with a function. When did the party begin to have a message that says "Go!" and I would like it to change when the player reaches 100 points. My last try script that absolutely does not work.

function textChange() {
    updateScore();
    if (player.score == 100) {
        updateText("Good!");     
    }
}

Thanks all

Link to comment
Share on other sites

What does the `updateScore` function do?

When do you call `textChange`?

How I imagine something like this would work:

* Game renders

* User input, play the game

* Game renders, this top bit is a loop

* When the user does something, then somehow you update the score, maybe you call `updateScore`?

* When the score has been updated you want to check if you should change the text, maybe by calling 'textChange`?

* This checks the current score and calls `updateText` if necessary

* As the game is on a loop, the game will render and the text on screen will have changed

There are lots of ways to accomplish the above steps, but I imagine pretty much any way of doing it will do roughly those steps, probably in that order.

I think that maybe you're not calling functions in the right place, or, more accurately, at the right time.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...