Removing array indexes and keeping accurate tally

0 favourites
  • 4 posts
From the Asset Store
Customize the animation of character when item changed
  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.First you asked for exactly this, and I made the whole work for you. Now that you had someone done this for you, you're asking for the next step. Why not just asking someone to do the whole game for you?

    You could at least use the examples you got and learn from them. As soon as you understand how they work, you don't have to ask for the next step. It will be easy as pie then.

    Looking for suggestions as to a better way to go about thisThe best solution to your problem isn't good enough for you?

    If you want to make a game and realize that it's beyond your capabilities, try an easier game mechanic first and go back to your idea when you are a bit more skilled.

  • It seems to be that I need a 2 dimensional array, width set to be the number of frames in the animation and height at 1 which will increment the number of times a given frame is chosen. Now because the frame is chosen outside of the function I need to know how to pass this information back to function in a meaningful way so that it will exclude those frames who have reached the limit.    Just wanting to make sure i'm thinking of this in the right way

    The purpose of this project is to learn this stuff. I try to give specific background because there are many ways to do things and the more scope you have the easier it is to see the best method to go about it. I debated posting expecting this response but opted to because it doesn't hurt to ask. If you say I have everything I need to figure it out, great! Did not intend any disrespect and didn't want to bother you anymore

  • I didn't think of you disrespecting. My proposal was honest. If you can't work it out based on the examples you already got, it's a better way to start something smaller until you are more familiar with the programming aspects, one of it being the object oriented aspect.

    I'm sure you'll work it out, it might just not be today or this week. <img src="smileys/smiley1.gif" border="0" align="middle" />

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