Removing array indexes and keeping accurate tally

Get help using Construct 2

Post » Fri Oct 04, 2013 3:01 am

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
B
10
S
2
Posts: 76
Reputation: 987

Post » Fri Oct 04, 2013 4:38 am

[QUOTE=Centra]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.[/QUOTE] 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.

[QUOTE=Centra]Looking for suggestions as to a better way to go about this[/QUOTE] The 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.tulamide2013-10-04 04:38:27
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Fri Oct 04, 2013 5:28 pm

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
Centra2013-10-04 20:43:57
B
10
S
2
Posts: 76
Reputation: 987

Post » Sat Oct 05, 2013 2:18 am

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.
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests