help with collecting items please

chicopchicop Member Posts: 263
edited November -1 in Working with GS (Mac)
ok ive gotten my self into a tricky one (again)

i have a highscore thats specific to each individual level.. also i collect items.. 3 per level..
the levels can be played over and over again.. keeping track of each levels high score and number of items collected... they never add up with other levels.. this is what i wanted. no more then 3 items per level.. score is what ever is greatest...

however now i would like to be able to add the items collected in each level into one display.. but adding them so say level 1 has 3 items level 2 has 1 item.. total items is 4... so then when i replay level 2 to get 3 items it would have to know that 2 were added and total is now 6

i dont know if this is possible... so far i dont get any further then continuously adding more items.. also when replaying.. which means you can collect unlimited amount of items by replaying level 1.. which is not what im after...

hope this makes sense any feedback is appreciated

cheers

Comments

  • AppTrainer.comAppTrainer.com Member Posts: 42
    Photobucket

    Hey Chicop, I assume you are creating a new integer attribute to keep track of your items.
    For now we will call that attribute "items"

    I also assume that when you collect an item you are doing something simple like this.
    Change Attribute "game.items" to "game.items.+1"

    The problem you are having is that when a player goes back and plays a level over and over again, they can keep collecting items going way past the 3 items per level you want.

    I can suggest two ways of resolving this...

    1. Make sure that items already collected aren't there when a player replays a level. Although I can guess this won't work for what you want.

    or

    2. Do a check to see how many items have been collected before adding the +1 to the "items" attribute.

    For example: You have three items on level one that can be collected, and your default value for your "items" attribute is "0"

    When a player collects the first item you will do the following:
    Change attribute "game.items" to "game.items.+1" if "game.items" is equal/less then 1

    When a player collects the second item you will do the following:
    Change attribute "game.items" to "game.items.+1" if "game.items" is equal/less then 2

    When a player collects the third item you will do the following:
    Change attribute "game.items" to "game.items.+1" if "game.items" is equal/less then 3

    You see with the rules listed above a player can never collect more then 3 items. Now what I just explained is based on the limited information I know about your game, like weather or not each item is unique or just another item. The more I know the more I can help you with an exact answer.

    Please let me know if the above information helps you out. And if you need more help then please don't hesitate to ask. I would be happy to make a video tutorial that explains everything you need.
  • UtopianGamesUtopianGames Member Posts: 5,692


    Darren.
  • chicopchicop Member Posts: 263
    great info guys! really help full stuff.

    for my game I have a high score i keep track of per level... i also keep track of items collected.. 3 per level.

    then on my level select screen there is info under each cleared level that states the score and the amount of items collected for that specific level.

    All this bit works. levels can be re played to get a higher score or when you have less then 3 items you can go back and collect all of them. it saves and loads and works when replayed.

    now the idea is that there are 10 levels in each world.. (4 worlds) so you can collect a max of 30 items per world.. what i am trying to do is add the 3 items collected per level to all the other level items in that world.. and if you don't have all the items, that there is a display that reads 21-30 items collected.

    the idea being i can then tie an achievement to when it reads 30-30 items collected

    hope this makes sense
  • floydianspiralfloydianspiral Member, PRO Posts: 308
    I am trying to do the same thing and I have a question, which might help out chicop too: I'm trying to get three stars per level...I assume I have to change "items" to 0 at the beginning of the level each time but then I only want to save if the player gets more stars than the previous attempt.

    Is there any way to check if the current amount of stars is greater than the attribute "items" that I loaded? Thanks.
Sign In or Register to comment.