lionz's Forum Posts

  • Key presses are triggers that trigger once without the need for adding a trigger once. The key press I added is in place of what would be your logic for unlocking the item.

  • I think what you might be missing here is you can see the array in debug mode, so you can view the list of items and when you press 1 see it added to the list of items.

    It's all in the manual about push but basically the array in your game is a list of found items at co-ordinates 1,0 2,0 3,0 4,0 etc. When you push something at the 'back' you are adding to the list, so when you push it becomes 5,0. Run your game in debug layout, you can see the array there as a list. When you press 1 it is pushed to the array, added to the list. There is not much to it, just think of it is a list and you are adding this item to the bottom.

    When you find an item it is pushed to the array/list. This means it is available to pick from with the picking code, as the picking floor(random(1, array.width)) picks an item from the list. Instead of setting it to a certain value as you did with the default items, push just adds it to the back of the queue.

    1. When you start the game, only the ones set exist, the ones you put in your on start of layout set the default items.

    2.You set the default items. Anything you find/unlock later is pushed to the back

    3. Explained above

  • Ok I've cut down my original file a bit. You don't have any logic to grant a new item and i'm assuming F5 is to mimic a new run? So if you load my file and press 1, you will mimic an unlock of purple helmet and itll be available for future run. 2 is gold helmet etc. Essentially all you do is when you unlock an item, you push it to the array. The array is a list of all found items.

    dropbox.com/s/z52yhok12qd4b3c/arraytest.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's interesting that you created a visual representation that looks like an array. Anyway, now that you've broken down the logic I've noticed it doesn't make too much sense or there is a step missing somewhere. You say that items 1-3 are picked from because they are default/found. Items 4-5 are skipped. Items 4-5 should only appear in future runs if they are found, so how are they found?

  • Salman_Shh that looks good and fun to play :)

  • I can see why you had a problem with arrays. You are filling the array on start of layout as I mentioned but you have something in your game that restarts the layout and fills the array again, that's not great but I see it's 'debug'.

    Check out : dropbox.com/s/z52yhok12qd4b3c/arraytest.c3p

    You can see how I've done the following :

    - Got rid of item_number, used a local variable to pick something random from the array and set it to equippedItem

    - Set animation to equippedItem, this takes out a chunk of code

    - Remove the equippedItem from the array so it can't be picked again

    - Added an arrayblock variable so you only fill the array once (the F5 thing mentioned above)

    Hopefully you can view that file and see how it works. All you would need to do now is add more stuff to the array and add more equippedItem = blocks like you have already. It is better if you understand it and know what is going on.

  • I can take a look but I can't find a download link, just lots of adverts and nowhere to download from.

  • you could add to a variable every second until it hits 20 but I feel like this is accomplishing the same thing.

  • I don't think anyone can help you with that other than construct staff so this is probably in the wrong place.

  • You do not have permission to view this post

  • Object > Pick top/bottom

  • Our roguelike platformer is well underway. Just me and an artist doing the indie thang.

  • The issue may be the scope of your game. What you're describing in the original post requires a certain initial approach and a certain expected knowledge of what you're doing in code. There is a significant difference between making a mobile game or infinite runner where you tap the screen and an RPG with an inventory system where you randomly unlock items during a game and need to store these values. Usually you would need to know how to use arrays for this type of game. As you move into save slots and storing this data you may find that you have too many things going on and too many variables just because of the initial approach you took.

    Before you can do this :

    2) - Once the Player UNLOCKED an item, ONLY THEN The specific item can appear in a future "RUN" randomly like the rest of the items.

    You need to push unlocked items to an array of all available items. They can then be picked from an array in future runs like with my examples above. You look at the array or list of items and pick one.

    Your function for changing item was picking a random number.

    This should become picking a random number which relates to an item in an array.

    Arrays will give you more control over what items are available in the game if you are doing something such as 'runs' where things unlock and applying stats to the item that was chosen, but that's partly just my opinion on how to approach this.

  • Sure I can break down a few more of the ideas i was trying to put across.

    Firstly, 0 will be present in the array always unless you change 0,0 and pushing 'adds' to the array, so you do not need to push an empty item, 0,0 is just 0.

    floor(random(1,array.width)) is to choose an item.

    When you push those items to a 1,1 array you will notice that the first item is at 1, because 0 is populated by 0, that's why I choose to start from 1, however the 0 still counts towards the width.

    array.width is indeed the number of X or items in the array however random does not include the second number, it is up to but not including the high range value (see manual). So if you pushed 3 items to the array, the width is 4 but the items are at 1,2,3. Because it would now pick from 1-4 not including 4 then random(1, array.width) works fine for any number of items. random(1,4) picks from 1 - 3.9. floor rounds whole numbers down hence 1-3. This is an explanation of why I used this however you can just assume floor(random(1,array.width)) will always work if you want.

    As for grabbing the item since it's important i'll have to explain it more in depth. When you choose an item you are setting an int variable, lets call it 'int' to floor(random(1,array.width)). Let's say the result is 2.

    Now you set a TEXT variable, lets call it 'pickedItem' to array.at(int,0).

    This means according to your example. TEXT would now be (assuming you have removed redundant NO_ITEM as mentioned above) "Rock_Helmet". Now you have this text variable to play with.

    You now say delete array.at(int,0) which will remove "Rock_Helmet" i.e. it cannot be picked again, resolving that you wanted to remove an item from being picked again.

    Remember the array is only for storing what items are to be picked, anything else for the item can be on the event sheet. So you could now say if pickedItem=Rock_Helmet then equip it. Or set currentItem to pickedItem. Whatever you want to do. If it was to appear in the level as a pick up you could say set pick up type to pickedItem. If it was to set an anim you could say set animation to pickedItem and it would appear as a Rock_Helmet. To summarise, all this is doing is replacing your ITEM_NUMBER with a text variable called pickedItem which = the name of the item, but has also allowed for picking a random item.

    Edit: I just saw that you wanted NO_ITEM to be a default weapon, well it won't be picked right so i'm not sure why it would be in the array, but if you want to pick it then set 0,0 to NO_ITEM, do not push.

  • This looks very convoluted now and I'm not sure item_found global variable can apply to a specific item. This is the time to move onto the array, but i'll guide you through it.

    Set the array size to 1,1,1.

    At start of game push to the back of X all items in your game, so it will look like this :

    push back "helmet" on x axis

    push back "sword" on x axis

    push back "shield" on x axis

    Now you have a list of items where helmet is 1,0. Sword is 2,0. Shield is 3,0. Do not think of arrays as scary, look in debug mode and you will see it as simply a list of items.

    To pick at random you run the action to set a variable to floor(random(1,array.width)), this will pick a number from 1 to 3 including 3.

    The number that is returned you can then grab the data by setting a text variable to array at (variable,0). So if it is 2,0 you can now reference the "sword" at variable,0 of the array.

    Delete x,y (variable,0) from the array. This deletes the item at 2,0.

    Now next time you come to pick a random item, sword is not there. Helmet is at 1,0. Shield is at 2,0. When you run the random command it will pick either 1 or 2. This is all visible in debug mode, you can see the items as they are removed.

    I would play around with that. Obviously as well as removing you can reference the item so 'variable' from the random command is "sword". You can use this to compare, i.e. if variable=sword then create sword in the level or equip sword.

    Let me know if you have any problems.