7 Replies Latest reply on Jun 26, 2006 10:18 PM by kglad

Want to make a Game in Flash

HI

I want to build the following game:

- There is a 10-by-10 grid of numbers from 1 to 10 distributed randomly
- User clicks on a number and the 9th, 18th, 27th, 36th, 45th, & 54th numbers from the user's selection in the grid are selected
- Below the grid are the various 7-digit permutation & combinations such as 4356452, 5423678, etc
- I want the the 7-digit sequence corresponding to the 7 digits clicked by the user to be highlighted

I would like to know:
1) Is this possible?
2) If yes, I would appreciate a hint or two on the plan I should follow

~wirefree101
• 1. Re: Want to make a Game in Flash
first, there are over 1/2 million 7 digit permutations of the digits 1 to 10 and i don't think that's going to fit below your grid.

second, what do you mean by every 9th number "from" the user's selection are selected? how do you count "from" a selection and what's the point? what happens after a 2nd selection etc?
• 2. Want to make a Game in Flash
Appreciate the enquiry.

- "first, there are over 1/2 million 7 digit permutations of the digits 1 to 10 and i don't think that's going to fit below your grid.
-- The game involves not all half million permutations but only about 15-20. Only if the 7 digits selected by the user appear in my list, would it be highlighted.
- "second, what do you mean by every 9th number "from" the user's selection are selected? how do you count "from" a selection and what's the point? what happens after a 2nd selection etc?"
-- Consider the mock grid I have up on http://www.gauravsobti.com/fuzzylogic/mock_grid.htm . Say the user clicks on 8 (highlighted in blue) in the 2nd row-4th column. The game should recognise the following sequence (highlighted in yellow) as a result: 8-1-4-0-1-3-6 where '1' is on the 9th position from '8' in the grid, '4' is on the 9th position from '1' in the grid, and so on...

Thx,
wirefree101 Text
• 3. Re: Want to make a Game in Flash
it's easy to setup that grid of 10x10 that's populated by numbers randomly selected from integers 1,...,10. it's easy to highlight every 9th grid entry starting from a user's choice and counting left to right, down to up and stopping after 7 entries are highlighted.

now what happens?
• 4. Re: Want to make a Game in Flash
Appreciate the thoughts.

Here's the execution plan:

- I want to use static .jpegs which are converted into symbol 'Buttons' as each of the squares of the grids. This is simply because the use of numbers was just to explain the overall concept to you. The final grid looks something like this:

http://www.gauravsobti.com/fuzzylogic/tableFX.html

- On http://www.gauravsobti.com/fuzzylogic/meaningFX.html are surprisingly all permutations&combinations of the 5-to-7 letter long 'phrases' dervived from the user's selection (& every 9th letter succeeding that)

My problem area is as follows:

- Since any letter on the grid (tableFX.html) appears more that once in the grid itself as well as on the meaningFX.html page, how would I refer to it? In other words, how do I finally highlight (i.e. recognize) the sequence of letters on the meaningFX.html page?

Would appreciate some thoughs.

Best,
wirefree101
• 5. Re: Want to make a Game in Flash
create an empty movieclip with a linkage id (say mcID) and now attach your 10x10 table of 100 movieclips each with a unique instance name. for convenience i would name them mc1,...,mc100.

give your jpg "letters" linkage ids, say letterID. attach to each movieclip mc1,...,mc100 one "letter" chosen randomly for the total number of letters. use a variable so each movieclip can recall what letter is attached to it, say mcX.letterVar=letterID; for each X=1,...100.

you now have your table setup. if a user clicks on mcX, your 7-sequence letters are:

• 6. Re: Want to make a Game in Flash
Appreciate the help!

I have looked at your explanation but found it hard to follow. Here are my questions:

1) "create an empty movieclip with a linkage id (say mcID)"
---I did this by right-clicking the MC in the library, selecting Linkage, checking 'Export for ActionScript' and then typing 'mcID' in the 'Identifier' field. Is this the movieclips you refer to in the point 2 below? Should I name these mc1 to mc100?

2) "and now attach your 10x10 table of 100 movieclips each with a unique instance name. for convenience i would name them mc1,...,mc100."
--- By attaching do you mean placing them side-by-side? Or do I attach these to a parent_mc referred to in point 1 above?

3) "give your jpg "letters" linkage ids, say letterID. attach to each movieclip mc1,...,mc100 one "letter" chosen randomly for the total number of letters."
--- Could you please clarify the procedure for attaching jpegs to movieclips.

4) "use a variable so each movieclip can recall what letter is attached to it, say mcX.letterVar=letterID; for each X=1,...100."
--- Is >>mcX.letterVar=letterID; for each X=1,...100<< the exact code I insert in Actions?

5) As I understand, your code will surely figure out the 7 letters corresponding to my user's selection in the grid. However, does it pinpoint the exact location of these 7 letters in the meaningFX.html? (refer to point 4 in my first post where I say " I want the the 7-digit sequence corresponding to the 7 digits clicked by the user to be highlighted.")

Best,
wirefree101
• 7. Re: Want to make a Game in Flash
1. correct. just leave that movieclip in your library. you'll bring all 100 to the stage using actionscript.

2. use attachMovie() to "instantiate" you 100 movieclips. for example, the code below will position your 100 movieclips into a 10x10 table:

letterIDA=["alephID","bethID",...,]; //<- you have different letters
dep=0;
for(var i=1;i<=100;i++){
_root.attachMovie("mcID","mc"+i,dep);
dep++;
letterID=letterIDA[Math.floor(Math.random()*letterIDA.length)]
_root["mc"+i].attachMovie(letterID,"letter",dep);
dep++;
_root["mc"+i].letterVar=letterID;
_root["mc"+i].ivar=i;
_root["mc"+i].onPress=function(){
highlightEvery9thMCF(this.ivar);
}
_root["mc"+i]._x=(_root["mc"+i]._width+5)*(i%10);
_root["mc"+i]._y=(_root["mc"+i]._height+5)*Math.floor(i/10);
}

3. assigning a linkage id for a pic is the same as assigning a linkage id for a movieclip. attaching a pic is the same as attaching a movieclip.

4. yes, it's been done already in 2. above

5. the code i gave in my first message attaches the 7-digit "word" that is formed by taking every 9th letter starting with the 9th letter after the users selection.

if you want to do something with the movieclips that correspond to every 9th movieclip from the user's selection of mcX they are:

for(var i=1;i<=7;i++){
_root["mc"+(X+9*i)%100];
}

so,

function highlightEvery9thMCF(X){
for(var i=1;i<=7;i++){
_root["mc"+(X+9*i)%100]._alpha=30; // would fade every 9th movieclip.
}
}