14 Replies Latest reply on Mar 28, 2007 3:10 PM by kglad

    Making a Flash Game - Help/Advice

    bobby2156
      Hi, i took a look through some of the tutorials before posting but couldn't find much related to the game i wanted to make, so decided to post hoping someone could help with any advice or even experience making something similar!

      I am making a educational flash game based on maths. The user is presented say 30 movieclips, 10 of these 30 movie clips equals two movie clips added together. For example, the user would click 1 and 3, and then another clip with a value of four, these clips would then disappear until the user worked there way down to no movie clips left and completed the game.

      I have been able to create the variables using the following code:

      for (i=1; i<7; i++) {
      _root["q"+i+"a"].sum = random(20)+1;
      _root["q"+i+"b"].sum = random(20)+1;
      _root["ans"+i].sum = _root["q"+i+"a"].sum+_root["q"+i+"b"].sum;
      }

      My problems are after that... How would i allow the user to select two movie clips and an answer, and if it was correct it would remove the clips, otherwise it would reset and allow the user to select other clips. Also my answer movie clips are coloured blue and i want to implement code so that the user can only select these blue movie clips if they have selected two normal ones first? Any help would be greatly appreciated...

      Bobby
        • 1. Re: Making a Flash Game - Help/Advice
          kglad Adobe Community Professional & MVP
          are each of the ten movieclips (that are equivalent to two other movieclips) equivalent to a unique pair or can there be more than one pair of movieclips that are equivalent to one of the ten?
          • 2. Re: Making a Flash Game - Help/Advice
            bobby2156 Level 1
            Thanks for helping me yesterday with the for loop kglad :)

            With the code i put above, it has defined a total of 18 movie clips... 6 of them being the answer to two of the other 12 added together. I suppose because it is random... It isn't unique, if i am understanding your question correctly, but if my thinking is correct, i'm hoping it doesnt matter.

            It does however if the user selects two of the answers as it would break the game as they couldn't finish the game. My assumption - with limited actionscript knowledge - is some sort of function which creates an array with the three values which checks if the first two values equals the third one, but i'm puzzled and its hard to find tutorials etc relating to this.

            Bobby
            • 3. Re: Making a Flash Game - Help/Advice
              kglad Adobe Community Professional & MVP
              no, you didn't understand. let's try it this way.

              there are 30 movieclips on stage. some pairs of the movieclips are "summands" that taken together equal another movieclip (the sum).

              does each movieclip, that's a sum, have unique summands? or is it possible for a sum movieclip to have more than 1 one pair of summands?

              as an example, in ordinary arithmetic, every counting number greater than 3 has more than one pair of counting number summands:

              5=2+3;
              5=1+4;
              • 4. Re: Making a Flash Game - Help/Advice
                bobby2156 Level 1
                for (i=1; i<7; i++) {
                _root["q"+i+"a"].sum = random(20)+1;
                _root["q"+i+"b"].sum = random(20)+1;
                _root["ans"+i].sum = _root["q"+i+"a"].sum+_root["q"+i+"b"].sum;
                }

                this code puts a random number in a dynamic text box called sum within the q1a and q1b instance of a movie clip. It then puts the total of these added together into the ans1 movieclip. As its random, its possible for example that q2a and q4b could equal the answer q1b for example, so yes, it could have more than one pair of summands

                Would this make checking more difficult?
                • 5. Re: Making a Flash Game - Help/Advice
                  kglad Adobe Community Professional & MVP
                  you're approach or my understanding is making this difficult.

                  i think you should just copy your first message and make another thread because i'm unable to help you and others are less likely to answer a thread that has responses.
                  • 6. Re: Making a Flash Game - Help/Advice
                    kglad Adobe Community Professional & MVP
                    ok, that upload helped clarify things, i think.

                    so, if a user picks movieclip1 and movieclip2 and then movieclip3, those 3 movieclips should be removed, correct? movieclips with containing a number N, i'm going to refer to as movieclipN:

                    what if a user picks movieclip2 and then movieclip1 and then movieclip3? all 3 movieclips should still be removed, correct?

                    what if a user picks movieclip1, movieclip16 and then movieclip 17? should those movieclips be removed? if not, why not? why is that trio incorrect and the above correct?
                    • 7. Re: Making a Flash Game - Help/Advice
                      bobby2156 Level 1
                      In your first two instances yes, it would work. For the third instance - 1 and 16 to make 17 - is a mistake on my part in my selection of numbers.. i quickly did it and had a slight oversight in my numbers.. in my game when i am finished i would have say 5 different sets of arrays which would be selected with a random number and would make sure that each answer can only have a unique two clips which could equal that total.

                      I have got a bit further with the game today, but i am finding strange errors, if you want to have a look.. this is the link:

                      http://www.megaupload.com/?d=64MDU1X6

                      The game now tallies up when the user gets something correct but for some reason when it matches them all, it doesn't go to another frame. It also doesn't remove the movie clips. Also the game stops working if the user clicks on the wrong answers and freezes, you have any tips as to why this is happening?

                      Bobby
                      • 8. Re: Making a Flash Game - Help/Advice
                        kglad Adobe Community Professional & MVP
                        stop. there's a better way to do this.

                        in fact, it's almost always a good idea to think through the logic of your project before starting to program or create it.

                        the one exception is graphics creation. you can always start creating the graphics that you're going to use before you've fleshed-out the logic that will be used.

                        now, back to your project: you're making an arithmetic tutorial, correct? and this is for young children, correct? if this is for adolescents or older, then you can ignore the following. otherwise:

                        you will accept, as a correct answer allowing removal of 3 movieclips, any 3 consecutive selections of movieclips where the first 2 sum to equal the third, correct?

                        and finally, how are you determing which movieclips will be presented on-stage for the students? there will be some amount of randomness that you want, correct?

                        you have an idea that you'd like to present 30 movieclips that can be removed. i assume you want to prevent leaving on-stage movieclips that cannot be removed, correct?

                        if that last statement is true, that's the part you need to think about. how do you propose presenting your 30 movieclips so there's not movieclips remaining that cannot be removed?

                        just because you present a user with movieclips 1,2,3 and movieclips 7,10,17 and 16,12,28 doesn't mean they are going to pick those 3 trios. they may start with 1,16,17 and 3,7,10 and be left with 2,12,28.

                        so, if this is for young children you need to put some thought into how to present these trios with possibly leaving the children with an insolvable problem. if this is for more sophisticated users then you may want them to plan ahead so they don't leave themselves with an insolvable problem.
                        • 9. Making a Flash Game - Help/Advice
                          bobby2156 Level 1
                          As you can see from the example, graphics etc havnt been taken into consideration.. lol.

                          Yes, i'm going to use the game to help younger children with mathematics. The user will be able to remove any three clips as long as they add up but instructions would tell them that they would have to use two reds to get one blue. Ideally i would like it so they can't select a blue until they have selected two reds, but i'm not sure if this is outwith my capabilities.

                          In regards to the randomness, although time consuming, as you can see in my actions layer, i create the numbers with an Array. Once the game becomes functional, i would have a variable called gameselction which would select a number between one and 10 for example, then an if statement.. so if gameselect=2 then use the following array variables etc. Although my example doesn't demonstrate it, each answer would only have two numbers on screen which could be used to equal it. I'm not going to have 30 movieclips, but rather 18, simply because i think it would be too difficult to ensure that each one could only be answered by two clips.

                          I have fixed the game thankfully, it doesn't freeze when they enter the wrong answers and it goes to the frame when they have completed it. Do you have any suggestions as to how i could do it so that they can only select blue on their third selection? And also remove the movieclips from the screen? "mc3.removeMovieClip();" doesn't seem to work.

                          http://www.megaupload.com/?d=YLN7LYKW

                          Bobby
                          • 10. Re: Making a Flash Game - Help/Advice
                            kglad Adobe Community Professional & MVP
                            you still have the problem of ensuring all movieclips are removable. that is the only significant issue that you need to resolve.

                            to remove movieclips with actionscript they must be in a removable depth ( between 0 and 2**20). you can use swapDepths() to move a movieclip to a removable depth.

                            but again, focus your attention on the issue in the first sentence. that problem needs to be resolved.
                            • 11. Re: Making a Flash Game - Help/Advice
                              bobby2156 Level 1
                              You are absolutely right, but i am going to carefully select the numbers myself so that they are each answer can only be answered by two specific movie clips. Every other combination would not work. Its a painstaking solution, but hopefully one thats achievable. The game will be part of a bigger mathematical game, so the user will only play through a few times, therefore it doesn't have to be randomly generated.

                              I got the game working so that the user can only select blue after selecting two reds and vice versa. I was thinking it was alot more difficult than it was.. i realised something like this on the button could be used:

                              on (release) {
                              if (_root.selectedTiles.length <=1) {
                              _root.revealTile(this);
                              } else {
                              _root.feed = "Now select a blue answer which equals the two tiles combined";
                              }
                              }

                              How would i use the swapdepths within my script? Thanks,

                              Bobby
                              • 12. Re: Making a Flash Game - Help/Advice
                                kglad Adobe Community Professional & MVP
                                if you want to remove q3a, for example, you could use:

                                • 13. Re: Making a Flash Game - Help/Advice
                                  bobby2156 Level 1
                                  Brilliant. It worked, thanks very much for your time kglad. I appreciate it no end as it has helped in my thinking and completion of the game. Now i just need to get the arrays to they are unique and implement some design. If you are interested, this is the final swf game i've made. If you have any suggestions please let me know, the feedback dynamic text is something i put in to alert the user but the wording etc isn't something i'd actually give to the user.

                                  http://www.megaupload.com/?d=5JAKZYMK
                                  • 14. Re: Making a Flash Game - Help/Advice
                                    kglad Adobe Community Professional & MVP
                                    you're welcome.