Zebbi's Forum Posts

  • Zebbi I'll try to get something up that can be shared in the next day or two when I get a chance. I'll post it in tutorials or something, but I'll let you know.

    Looking forward to it!

  • For instance:

    How can I run a countdown timer into the sprites, with separation marks?

  • Is there a plugin that can live switch the scaling in node?

  • I've also sorted out the max-ammo by using the third column:

    I set the ammo amount in the first condition, and force the amount in column 0 to not exceed the amount in column 2, seems okay!

    Haven't quite worked out if all of this will work when ammo is depleted by firing, I'll find out soon enough though!

  • Solved this here:

  • I'm not certain if I understand correctly what you think to achieve by using an array. An array is useful if you don't want to deal with a huge amount of variables or you need something that change its size dynamically. Also you can go through all elements of an array very easily. A bad Idea is to change the size of an array every tick by inserting or deleting elements. It will have to reorder the index. Depending of the size of the array it could take some time to do this.

    If you store all your Weapons by name or number in an array in the beginning and you want only to cycle through the weapons in the game, you can do this by using the index or use the 'for each element' loop to go through all weapons at once, but I wouldn't use push and pop.

    Excellent, I'm using a global variable to control which column is being shown, so that confirms I shouldn't be pushing and popping. Here's the finished result:

  • Probably something like this to set column 1 to column 0:

    set array at (1,0) to array.at(0,0)

    set array at (1,1) to array.at(0,1)

    set array at (1,2) to array.at(0,2)

    set array at (1,3) to array.at(0,3)

    set array at (1,4) to array.at(0,4)

    ...

    set array at (1,array.height-1) to array.at(0,array.height-1)

    But that just screams "use a loop", so...

    repeat array.height times

    ---set array at (1,loopindex) to array.at(0,loopindex)

    Thank you so much!! I can't thank you enough for helping me with those loops, I've learned a lot from this. Here's the finishing code:

    That keeps a second columns (I changed it around so they're columns rather than how I had it with rows, too hard for me to visualize!) updating and I just update the score like so:

    Works well so far! Any side-effects I might encounter, performance-wise?

  • That sounds like it would work. There isn't really a best way.

    Seems to be working well so far! Is there a way of cloning one column of cells into a duplicate second column? I want to do the old counting counter trick (usually done with two variables, one that staggers the total and adds/subtracts it in nanoseconds until it reaches the sum of the other) but I need to do it with the array, is this possible?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I want to have two array columns, one at X=0 and one at X=1, and all 6 cells at X=0 need to duplicate themselves one space to the right. This way, if there's a difference between them (say, a number is added to or subtracted from X=0), I can have X=1 count up or down to the figure in X=0, and the sprite counter will count up or down to match. How do I do this?

  • Depth of your array has to be set as least to 1, otherwise the whole array has no size. You can see that, if you look at your array in debug.

    Thank you! I was thinking the depth started at 0, so it works now! I was thinking it might be better to switch weapons by pushing the array, I think that's what it's called? Where you shift the cells in a cycle, so the game reads from the fixed cell, but the array shifts the cells around. Would that be a better way of doing it? And I should I be doing all this on every tick for performance?

  • Depth of your array has to be set as least to 1, otherwise the whole array has no size. You can see that, if you look at your array in debug.

    Thank you! I was thinking the depth started at 0, so it works now! I was thinking it might be better to switch weapons by pushing the array, I think that's what it's called? Where you shift the cells in a cycle, so the game reads from the fixed cell, but the array shifts the cells around. Would that be a better way of doing it? And I should I be doing all this on every tick for performance?

  • Trying to figure out how to set the default ammo amounts, I have a counter that should return the value to the HUD here:

    And here is the array, I'm playing around with the cells, trying to figure out how to bring in the right value:

    Where am I going wrong?

  • >

    > > purplemonkey Nope. It's impossible to do without a custom or event-based behavior. I had one person who was interested in doing this but it was never finished.

    > >

    > Dang it, thanks for trying though! Ah well, I guess I have to implement some dank code instead..

    >

    Zebbi

    I found a quick solution for disabling collisions on specific objects, etc. and would be willing to share it! Its a stupid trick but gets the job done.

    Would love it please! Not sure if it's okay to put all this in this thread, but it still fits in with the ethos that we need this kind of thing in an alternative platform behavior. Please share!

  • [quote:hnctqkjx]Would it be better practice if I only had things happen when they changed, either by putting it in a function or testing for a keypress? I could be wrong, just seeing if every tick is expensive in processing terms or not?

    I'd say it's irrelevant for something as simple as setting a variable.

    That's what I thought, thanks for clarifying. Can this method be used to recall data from an aray? I was going to have a 2d array that has the ammo amount and the max ammo for each weapon. Would this be the best way of storing and recalling the info for 6 weapons, or would it be better to use 6 different variables for storing?

  • For the first one if the value of CurrentWeap never exceeds 9 you could do this:

    every tick
    --- set animation frame to int(mid("0123345", CurrentWeap, 1))[/code:nqvtjblm]
    
    Or you could do this if you want to handle double digit values:
    [code:nqvtjblm]every tick
    --- set animation frame to int(tokenat("0,1,2,3,3,4,5", CurrentWeap))[/code:nqvtjblm]
    
    For the second bit I'd utilize key codes.
    "1" has a key code of 49
    "2" has one of 50
    ..
    "9" has one of 57
    
    You can make a simple capx to inspect the keycode values of certain keys if you wish or there's probably a reference online somewhere.
    
    So basically you then can do this:
    [code:nqvtjblm]on any key pressed
    system: Keyboard.LastKeyCode is between values (49,57)
    --- set CurrentWeap to Keyboard.LastKeyCode-49[/code:nqvtjblm]
    

    Thanks for that! I'm still working out how to use mid, int, str, zeropad, etc, so this is really helpful to have it examplified for me. Is using every tick a good idea for this kind of thing? Would it be better practice if I only had things happen when they changed, either by putting it in a function or testing for a keypress? I could be wrong, just seeing if every tick is expensive in processing terms or not?