How do I understand max(2+star,levels.At(Currentlevel))

0 favourites
  • 3 posts
From the Asset Store
If you understand BRAAAM then you know exactly what inspires this epic sound library.
  • I don't expect someone to take the time and energy to explain this item, however if someone could point me towards a tutorial or a section I could read to understand it I would appreciate it.

    This is from the level select tutorial here: https://www.scirra.com/tutorials/311/le ... ect?page=3

    max(2+star,levels.At(Currentlevel)) is an array variable given when you meet the win condition of the level. in the tutorial it is the simple click of the win sprite. The problem is I don't understand what I just did. I can copy the even sheet and watch the video and make it work. However if I don't understand what I am writing in the even sheet, I didn't learn anything to help me later on.

    Can anyone help me understand this or point me to where I can learn to understand it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The max function is used to pick the highest number in a set of numbers. In this case, there are only 2 options:

    2 + stars

    levelsat(CurrentLevel)

    The result is the value that is highest. If 2 + stars == 2 and levelsat(CurrentLevel) == 0 then the result of the function will be 2.

    Now, what do 2 + stars and levelsat(CurrentLevel) represent? After a quick read through, this is what I understand the values to mean:

    2 + stars: represents the animation frame to be stored in the array according to the number of stars earned in the level. You add 2 because there are a few frames before the frames with stars so if the player beat the level but didn't earn any stars, the frame to display will be the completed frame with no stars.

    levelsat: appears to be the name of the array storing the information for what frame to show but I don't see any other place this name is used. I think this should be replaced with the name of the array and may just be a typo.

    CurrentLevel: is a global variable representing which level you are on.

    levelsat(CurrentLevel): If my understanding of levelsat is correct, this means get the value of the array at the position matching CurrentLevel.

    Given the above, the condition max(2+star,levels.At(Currentlevel)) means:

    store the number of stars earned (plus the offset) if it is higher than the previous high score already stored in the array. So if a player previously earned 2 stars and this game only earns 1, the number of stars stored remains 2 but if they earn 3 this time, the number changes to 3.

  • Thank you so much.

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