How do I solve this "slots" feature... Arrays or another way?

  • Hello All,

    I start working on a prototype and I'm not sure how to solve this thing:

    I know that I could just solve it with Animation and set the frames to the value I want, easy...

    BUT! since I have it split in 2 sprites: (32x32)

    ACTIVE Which is a loopable animated glowing orb.

    USED Only 1 frame BEHIND the ACTIVE Orb.

    Each character should have different amount of MAXIMUM Slots to contain the Orbs.

    Whenever an ACTIVE Orb is used, it will be destroyed (special destroy animation), but it needs to show the USED Orbs sprite behind it based on the MAXIMUM number of slots.

    I'm not sure how to approach this:

    1. Each character should start with different MAX Orbs amount. (decide from the character selection part).

    2. It shows visually the ACTIVE animated orbs lined on a raw (x axis) on screen.

    3. In Game: when USING Energy, it should show the used sprite behind it.

    So what do I do?

    Unfortunately, ARRAYS are not user-friendly and very confusing for me to handle in Construct 3

    I tried to mess with the basics of setting them in X but I got super confused as I always get with Arrays and gave up on this solution.

    As I mention on the start, I can only think about making MANY animations for each number of Active Slots and connect it with Variables to control the changes, but I would LOVE to use just one sprite of 32x32 and place them using the X and 32 spaces to add and reduce (which is why I tried Arrays and run away after 2 minutes of confusion in Construct 3).

    I still have a strong feeling that ARRAY will be the easiest way and this is why i'm asking here of HOW exactly to accomplish this.

    So.. how do I connect the VISUAL appearances of the ACTIVE and USED slots using variables or 1D Array?

    Used Slots should probably called MAX Slots, but it's just a start-point anyway:

    Download Clean Example

    Thanks ahead for any help!

    Tagged:

  • Alon

    I would use instance variables on the character - much easier to keep track of how many a character can have, and how many they do have.

    I put the Used_slot animation in the Active_Slot sprite, and renamed it Orb. Then there is only one type of object to worry about, and you can tell its status by what animation it is playing. The orb has an instance variable telling which character it belongs to.

    at the start of the layout, it creates all the slots for each character, and makes the correct number active...

    https://www.rieperts.com/games/forum/orbs.c3p

  • Thank you AllanR for taking the time to make this example file, I appreciate it!

    I will look more deeply in to it to follow how it work.

    I do have a question based on what you describe:

    Let's say that I selected the character and I want to START the game (move to another Layout)

    Since these are not Global Variables, will they "MOVE" with the characters to any other layout?

    I don't want the starting stats of the orbs to reset unless the character is dead, game over.

    Sorry for the confusion, I have much more to learn! :)

  • Thanks sizcoz I think I'll use this persist feature!

    Now.. I'm trying to think this over:

    So my "Character Selection" Layout, is not actually the character sprites, but a different sprites that represent the characters in the next layout (the game itself).

    What is the easiest or most efficient way to "move" or "copy" the Instance Variables I put for each character on the "Character Selection" to the actual characters?

    Since I'm not using Global Variables, and persist will used if I'll actually use the same instances, I need a way to move these variables to the actual characters of the game, so I can change their stats at any time I want during the game.

    The only solution I can think of is to make the selected sprite form the "Character Selection" (which is NOT the actual character but a representative sprite only) to the other layouts and hide them... is this efficient? or there is a simple way doing this?

    Thanks ahead! :)

  • Alon

    in the sample I made, there were only 3 fields for the characters: total_slots, Active_slots, and CharacterName. So with only a few fields like that, it would probably be easiest to set 3 global variables after choosing the character. And then set the player's character from the global variables.

    if the player was picking a team of characters, then an array would be a good option.

    to use a hidden sprite to hold the selected character's variables, you would have to make that sprite a global object (in the Object Type Properties). Then it would still exist on each additional layout...

    I just tested that idea out, and actually, that would be a good way to do a team of characters too - easier to work with then an array.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for sharing AllanR I'm trying to simplify this as much as possible, I actually got it to work with 1 Global Variable (for now) to keep it simple and clean.

    In the attached example, you can see that the STILL version on TOP works perfectly fine, So far so good!

    The issue is that on the ANIMATED version on BOTTOM, when I ADD +1 (HEAL) I get weird results.

    I'm not sure what I missed or did wrong, I tried to do the SAME for what I did on the STILL version, I probably missed something but can't see it.

    Can you please have a quick look?

    I think it's the most simplify version for slots I found not the best, but really simple and clean especially after you DELETE one of the versions that you don't need (Animated or Still).

    Download: Still Slots VS Animated Slots

  • Alon

    yep, just a tiny mistake - event 13 should have "less than or equal" (like event 12), not "greater than"

  • Thanks again AllanR! I had a feeling that I shouldn't mess with construct if I didn't sleep but... that's the the only spare time I got hehe.

    It's still not the best solution because no control on ADDITION MAX slots but as I said it is a very simple version.

    Do you have an idea if there is an action I can add to make the ANIMATED slots play together all the time?

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