Find Item ONLY ONCE! - (Don't find this item AGAIN in the future!)

0 favourites
  • 9 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • On my journey of trying to get used to Array which I always ran away from... thanks to I could finally add a basic working Array to my game.

    Based on the GIF, as you can see the idea is whenever the PLAYER touch that cube-sprite on the left, it will add (push to the Array list) a NEW ITEM to the game which is what I want for my game: something to TRIGGER a NEW ITEM FOUND!

    and add it for the game (even if you quit it, I will learn and use how to SAVE later).

    I used the CHOOSE and put 2 "NEW" items like this: (Items that are not found yet by the player)

    Debug: EVERYTHING Works great, as soon as the player collide with that sprite it's destroyed and one of the two NEW Items will be added to the Array "Arr_Items" list.

    But THE PROBLEM is: next time when I want to add different ITEMS, it may still choose one of the ITEMS that already added.

    MY GOAL: Once a NEW ITEM is added to the Array list, I want NO MORE of this item to add in the future

    The GIF shows an example of what will happen if the PLAYER will FIND A NEW ITEM during a full game.

    I'm aware that the problem is CHOOSE because the names are there to choose from and I can't remove them once chosen... or maybe I can? (it will solve the issue)

    So is there a way to make sure, once an Item added to the list it won't be added again?

    so I won't get huge list with the same Items.

    Have a look:

    Please understand, not only I'm new to Construct 3 but also ARRAYS are new to me and I'm trying my best to learn and understand how it works in C3 while practicing. so far I'm VERY impressed from the powers of Arrays!

  • A choose won't work, you need another array with all of the items you can find pushed to it. Then on finding/unlocking an item you choose a random item from that array and push it to your first array. Then you delete the item found in the second array so it cannot be picked again. You should be able to work that out based on the logic that is there already which picks a random item from the first array.

  • Thanks for the quick reply it sounds like a great solution!

    So if I got the idea:

    1 array for the normal Items who are already found by default, and 2nd Array for the NOT-Found-Yet Items.

    Then push from the 2nd Array list to the 1st one and delete it from the 2nd one.

    It make sense in my visual brain, I can see it "moves" from one to another but I'm not sure if I can accomplish it in C3 yet, Sure I must try it for the learning experience.

    If I'll get stuck, I'll ask for help.

  • OK, I think I'm almost there... but I don't know how to code the RANDOM pick from the 2nd Array to the 1st and remove the one that picked.

    Here is what I got so you'll have an idea and hopefully can guide me through:

    Above are the Items we begin with "Arr_Items" - All items that can be found by default:

    Next is the trigger: Pick a random NEW ITEM from "Arr_Items_LOCKED" and add (push) it to "Arr_Items", Then, Delete that picked Item.

    I don't know how to do that yet, but I did some progress.

    The Debug shows that both Arrays are set EXACTLY with the items I chose, so at least I got that right:

    please help? :)

  • UPDATE: I almost got it to work!

    I Re-Shaped the all thing, renamed the variables so I can follow etc..

    THE ONLY THING that isn't working for me is once an Item Moved from the "arr_Items" (default Items) to the "arr_Items_LOCKED" (Unlocked Items) the item that picked and moved is NOT DELETED after it moved.

    On the Debug: when I press F6 it moves any of the 2 unlocked items randomly which is GREAT!

    But it won't delete so I if I keep pressing F6 it will keep adding them to the list.

    Can someone please have a look at the CODE maybe point me how to fix it? I probably missing something or did some error... just when I started to like Arrays.

    HELP please? :)

  • That should work, I don't see the need for the pop event though so that can be removed.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That should work, I don't see the need for the pop event though so that can be removed.

    With or without the pop event I get the same result.

    Any alternative ideas for solution?

    I'm stuck :(

  • It's because in the screenshots above you're setting values in the secondary array every tick so it's constantly setting the array_items_locked values, so deleting them won't do anything. You need to set the items in the second array once only.

  • I'm not sure if I understand exactly, so I tried something like that:

    I even tried this: (got rid of the sounds to make it easier to follow)

    As you can tell I'm already lost and confused... I have no idea how to fix this mess.

    I'm so close, just need to figure this out and the system I designed should work for the game.

    Any ideas, changes I can tweak will be very appreciated and helpful.

    Thanks ahead!

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