Centra's Forum Posts

  • I'm not even sure how to title this but I am working on an answer choosing project. One sprite has multiple frames, each representing a different possible answer.

    There is a function that spawns 3 instances every x seconds and randomly selects a unique frame for each instance such that there are no duplicates via an array. After the function is called, an event picks a random instance from the 3 newly created instances and selects one of them to be the answer by setting a boolean on the sprite instance to true.

    What I'd like to do is take the answer instance and save it's current frame and tally how many times it was picked throughout the runtime so that once a limit of x has been hit, that answer (frame) can no longer be picked by the function choosing which unique frames to select while picking the 3 instances.

    I can't seem to wrap my head around how to go about this. If I pop or delete parts of an array the places shift and i can't keep an accurate tally, on top of that I am dealing with two separate arrays which need to talk to each other somehow.

    Looking for suggestions as to a better way to go about this

  • Awesome! The first suggestion made it go crazy but the second one worked. Thank you so much, I would have never guessed that without inside knowledge. Also I checked out your music loops and wanted to say nice work :)

  • Thank you again, I continue to play with it but I feel like you might be babying me at this point.

    So one more question, what needs to be done to pick a random instance of the three new instances?

    <img src="http://i39.tinypic.com/358pero.png" border="0" />

    Do I need to have their UID as part of the array when they are created and pick randomly from one of them? Setting up an XY array where x is the frame and y is the UID? much like the random destroy but with a two dimensional array

    Is it a parameters issue? Where I need to return values in order to pick from those three?

    and about the destroy bit, they will be given bullet later and go off screen, creating 3 more. Though I guess they could just be moved back and bullet across infinity after changing frames and picking a new "answer" block

  • Haha, that's ironic. I upgraded to 145 to access your random destroy example.

    Here is an r139 version. I wanted to know if I was on the right track. I think the problem is with picking the newly created instances. I wasn't sure how to handle it, nor am I certain about the order of operations going on there.

    instancepickconfusion.capx

  • Thank you again for your examples! I will be more careful when I speak of sprites, instances and frames in the future :D

    I wanted to know if I was on the right track. I think it's a problem with picking the instances and adding them to the array.

    In the first example it will generate random frames but they repeat still have duplicates.

    first

    in the second I tried adding UIDs to the array but wasn't sure how to pick them.

    blockuids.capx

  • deleted due to trouble adding capx links

  • That would be very good of you, I greatly appreciate it. Handling multiple instances has been my biggest obstacle ever since I started construct, I feel like once I cross this hurdle things will get much easier.

    So you are suggesting that the shuffle/choose function takes account of the newly created sprite UIDs each time its run and then picks for them? I'm playing with that idea now trying to figure out the order of operations.

    Just a little background:

    ultimately i'm going to choose one of those three sprites each shuffle and prevent it from choosing the same frame more than three consecutive times, and remove certain frames from being chosen after they've been called more than 5 times. But I'll figure that out once this "shuffle" is down.

    It's essentially an educational game and the player is meant to choose the correct answer, the spite placement is also random(got it covered) so I was wondering if it would be easier to use two sprites, essentially two dummies and a dedicated answer for the shuffle function?

  • So I would need to create a function or loop to re-tally all the uids or instance variables to represent the newly created sprites each time they are created and then run the shuffle function that has been edited to look for

    Pick Sprite where Sprite.uid/instance var = loopindex?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you very much! I got it working so long as the objects already exist, but my goal is to spawn new sprites, pick frames, then destroy after an interval. it seems that there is something not taken into account when new objects are created because they are always on the same frame, maybe the iids don't reset? How would one take newly created objects into account?

  • I'd like to be able to choose a number from a dynamic list of numbers, I think in probability it's called a dependent event.

    I have three sprites (or one sprite and two instances of another sprite to save resources), each sprite needs to choose a number but cannot choose from one already chosen.

    For example the list is 0,1,2,3,4

    Sprite instances x y and z each choose in order.

    X picks 0, so y gets 1,2,3,4, it chooses 3. Now z can choose from 1,2,4 and chooses 4.

    so we end with

    x 0, y 3, z 4.   

    then these are destroyed by going off screen and the new instances can choose from 0,1,2,3,4,

    How would I go about doing this?

    I've been working on this problem for a few days now and tried using random trees but it just ends up being indecisive and I can't exit the loop because there is always a duplicate. I'd am looking for a way to set up such a dynamic list.

  • <img src="http://i43.tinypic.com/2n6vg29.png" border="0" />

    Finally got it to run without duplicates, debugging display for frames doesn't work though

  • My main problem seems to be 'some event that picks two sprites'

  • <img src="http://i43.tinypic.com/kei1cp.png" border="0" />

    this one doesn't give a runtime error but it doesn't prevent duplicates either

  • Thank you very much, I appreciate you going the extra mile to explain how picking instances are handled. Following your example at the end, still giving me problems though.

    <img src="http://i42.tinypic.com/2wqcy9v.png" border="0" />

  • Posting your findings does help others who are following in your footsteps, i know it's helped me in a number of unresolved posts when people post their findings even if its not solved at least there's a little more info to go on.

    Shame though, I thought the community was more active.