How do I improve these events

0 favourites
From the Asset Store
City ride is a game to improve your memory.You have to focus and remember the information related to passengers of previ
  • It doesn't look like will be a good option because I'll have hundreds of levels.

    1Level2 => "1" is the epsode and "Level 2" is it's respective level.

  • Instead of Webstorage use Dictionary for example and then use Webstorage only for saving loading the game.

    I'll make my example on dictionary object.

    Make a Dictionary key for episodes and one for levels.

    Something like:

    "Episodes" : 1

    "Levels": 1

    and for each new episode/level simply add a new key. For example if you start level 2 of episode 1 - add a key "1Level2" with a value = to score.

    then you could do something like that

    on start of layout

    Is animation "Level" & Dictionary.Get("Levels") -> Set score to Dictionary.Get(Dictionary.Get("Episodes") & "Level" & Dictionary.Get("Levels"))

    If your current episode is 4 and level is 3 then the last one will set score to key named "4Level3" - which holds a value of your score.

  • shinkan

    Thanks man. I'll try it.

    shinkan

    Do I need to create all the keys for all episodes and levels before and manually?And how will I create more than one Episode key without overwrite it

  • No, and thats the beauty of Dictionary object. You can simply do:

    Dictionary: Add key "your_key_name" with value "your_key_value"

    any time you want. If key with that name do not exist, new key will be created. If key with that name already exist value will be overwritten.

    So you can do stuff like this:

    On left mouse click -> Dictionary: Add key "click count" with value Dictionary.Get("click count")+1

    On first click it will create a new key "click count" with value 1

    on second click it will set key "click count" to 2

    on third "click count" will set it to 3 etc.

    Think of it as a global variables that can be added/set/removed on runtime any time you want

    Oh and key values can be anything. Integers (1, 2, 34, 56..), floats (1.2, 44.34, 4.666...) or strings ("aaa", "bb bb"...)

    EDIT: But if you want you can make a text file with all your keys and values already typed in and then use AJAX to load that file into a Dictionary object. This way you starts your game will all necessary data you need for your game!

  • And how will I create more than one Episode key without overwrite it

    You probably always start on episode one. So you can make a counter to keep count of episodes (1,2,3,4...) - this can be a dictionary key as well.

    Then on start of each new episode you can add a new key: Add key "Episode" & counter - in this case value of the key is not important, You only need a key to exist.

    and then if you finish last level of current episode simply add 1 to counter.

    This will make a new key every time you start new episode automatically - "Episode1" key, "Episode2" key etc.

    If you want later to check if current episode was started/finished or whatever you can simply use

    Dictionary: Has key "Episode1" -> do your events.

  • you can simply use

    Dictionary: Has key "Episode1" -> do your events.

    Dictionary: Has key "Episode2" -> do your events.

    Dictionary: Has key "Episode3" -> do your events.

    Dictionary: Has key "Episode4" -> do your events....

    ....and you have 100 events again

  • nope

    Dictionary: Has key "Episode" & counter -> do your events.

    And if you run it through a loop you will only have one event to rule them all

  • Ok.. I believe you...but .. i do not understand (see my signature )

    how you check "Episode" ..if E=1 do..If E=2 do..... ?

    Edit: you dont need webstorage for all levels just for last.. webstorage key "last level" & global variable" Last level"....if player "win" on level 1 ..set "last leve" tol 1..

  • shinkan

    I'm sorry but I'm too stupid to understand it =´[ I don't know dictionary very well. I'll try to explain where i'm stuck. For example, when the player accomplish the level 2 of the episode 1 I'll save it with webstoreage => "Set Local Key LayoutName (which is 1Level2) to ScoreTemp (which is a global variable that holds scores until it get saved) Ok, then I get lost. When do I need to add keys to episode and levels?I mean, the value will be the string episode and the key will be my "value"? and...Sorry I would add more questions but i'm too lost to even know what is it LOL

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • let's make it simpler. Imagine you have 3 variables:

    1. Number variable [episode] = 1 - this will keep track of current episode you are playing

    2. Number variable [level] = 1 - this will keep track of current level you are playing

    3. Number variable [score] = 0 - to keep track of current player score

    When player finish any level you make an event:

    Dictionary: Add key "[episode] & "level" & [level]" with value [score]

    So when player finish level 2 of the episode 1 and his score is 1234 it will add a key [ "1level2": 1234 ]

    when he finish level 5 of episode 3 with score 5432 it will add a key [ "3level5": 5432 ]

    so key name is made of a combination of: variable [episode] a string "level" and a variable [level] - which gives for example "3level1". And value of that key will be a variable [score].

    korbaach

    if you know how many levels and episodes you have you can make a simple loops

    For example there is 5 episodes with 4 levels each and you already have finished all 4 levels of episode 1 and 2 levels of episode 2. Each level have it's own score.

    "1level1": 1234,

    "1level2": 567,

    "1level3": 432,

    "1level4": 674,

    "2level1": 33,

    "2level2": 8,

    Now on start of the layout you want to create and set text to score for each level:

    +On start of layout

    ++For "ep" from 0 to 5

    ++For "lvl" from 0 to 4

    ++ Dictionary: Has key [ loopindex("ep") & "level" & loopindex("lvl") -> Create Text on layer "zzz" at (X,Y) - > Set text to Dictionary.Get(loopindex("ep") & "level" & loopindex("lvl")) Hope I make any sens, it's almost 4 AM over here ^^ EDIT: and yes you only need Webstorage if you are actually want to save/load current game state. With Dictionary it's super easy. You only need one event Webstorage: Set local key "key name" to Dictionary.AsJSON. This will save entire dictionary object as a one webstorage key.

  • Hope I make any sens, it's almost 4 AM over here ^^

    Same here... Wesolych Swiat shinkan

    Thanks!...

  • >

    > Hope I make any sens, it's almost 4 AM over here ^^

    >

    >

    Same here... Wesolych Swiat shinkan

    Thanks!...

    Haha, nice! Wesolych to You too

  • let's make it simpler. Imagine you have 3 variables:

    1. Number variable [episode] = 1 - this will keep track of current episode you are playing

    2. Number variable [level] = 1 - this will keep track of current level you are playing

    3. Number variable [score] = 0 - to keep track of current player score

    When player finish any level you make an event:

    Dictionary: Add key "[episode] & "level" & [level]" with value [score]

    So when player finish level 2 of the episode 1 and his score is 1234 it will add a key [ "1level2": 1234 ]

    when he finish level 5 of episode 3 with score 5432 it will add a key [ "3level5": 5432 ]

    so key name is made of a combination of: variable [episode] a string "level" and a variable [level] - which gives for example "3level1". And value of that key will be a variable [score].

    Thats the point. The only thing that say what episode and level I am is my layout name. I have only one Event Sheet for all levels and 2 more (for now) that will handle the first screen and the level select screen. So the only way to know where I am is using Layout's name.

    Edit: Is there a way to break the characters of layout's name?

  • This makes it even simpler.

    Instead of this Dictionary: Add key "[episode] & "level" & [level]" with value [score]

    use Dictionary: Add key "Layoutname" with value [score]

  • This makes it even simpler.

    Instead of this Dictionary: Add key "[episode] & "level" & [level]" with value [score]

    use Dictionary: Add key "Layoutname" with value [score]

    Thats what I'm doing now. I save with webstorage (set local key LayoutName to ScoreTemp)

    and for the dictionary (add key LayoutName with value ScoreTemp) but when I refresh the game, the data is gone

    Edit: shinkan that's how I did it. So far It's working and saved me tons of unnecessary events. So cool. Thanks for the patience.

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