View Full Version : Actionscript quiz..
Iammontoya
May 22nd, 2002, 02:42 PM
well... I really have no other reason for this excercise other than to try to do it. I have gotten this far.. with your help (thanks, Supra), but it is obviously missing functionality. Now, since you guys are NERDS, just like me... Im looking for some code suggestions.
Basically, I'd like the code to calculate a win. I'm sure you're familiar with the game.. all numbers down, across, or diagonal is a win, but I'm not sure how to go about it.
The swf is here: www.realinteresting.com/k...m_test.swf (http://www.realinteresting.com/kirupa/bingo/gm_test.swf)
the fla is here: www.realinteresting.com/k...m_test.fla (http://www.realinteresting.com/kirupa/bingo/gm_test.fla)
well, what do you think?
upuaut8
May 23rd, 2002, 12:18 AM
That's pretty cool. Still thinking, myself....
are your numbers stored in an array?
Iammontoya
May 23rd, 2002, 07:51 AM
numbers are stored in arrays..
bvalue
ivalue
nvalue
gvalue
ovalue
perhaps I should concat into a new array?
I am not Jubba
May 23rd, 2002, 08:05 AM
Well, you could make it like a real Bingo thing, and make them click on the number that appears. So make a button, or put a movieclip over each box and when they get that number they click and the box changes color, but you would also change the value of a variable...and then have flash detect to see if a bunch of variables are true have it check for like:
b1win
b2win
b3win
b4win
b5win
or something like that...i'm sure there is an easier way but right nwo all ic an think of is this..
Iammontoya
May 23rd, 2002, 10:35 AM
I created a movie clip and put the movie clips "behind" each number slot on the card. I set the visibility to false.
I created a new array that holds all the number values for the card. Now, I just have to figure out how to compare a value against all the values in that array.
That way, if the number exists in the array, the visibility of the mc on the correct slot will be set to true.
Iammontoya
May 23rd, 2002, 02:46 PM
(This message was left blank)
suprabeener
May 23rd, 2002, 03:11 PM
how about using multi dimensional arrays?
bingo = [
[45,76,26,97,23],
[85,28,95,26,64],
[39,217,7,60,35],
[6,87,34,27,56],
[32,9,20,56,31]
];
then mirror it for your hits:
hits = [[],[],[],[],[]];
and mark off the hits as they're drawn:
for(j in bingo){
for(k in bingo[j] ){
if(bingo[j][k] == drawnNumber){
hits[j][k] = 1; // plus mark the sqaure or something
if(hits.checkBingo(j,k)) trace("BINGO!");
}
}
then checking vertical and horizontal is easy:
Array.prototype.checkBingo = function(j,k){
var check;
// check the row
for(n in this[j]){ check+=this[j][n]; };
if(check == 5) return true;
check = 0;
// check the column
for(n in this){ check += this[n][k]; };
if(check == 5) return true;
return false;
}
the diagonals i'll leave to you. too hard! ;)
this is untested so most likely has bugs in it.
edit boy that italics thing is annoying...
Iammontoya
May 23rd, 2002, 04:22 PM
Dude.. you are FREAKIN me ouT!
thanks for the reply..
I'll go get me another box of ColonBlow (SNL reference) and try to work this one out.
You crack me up. You really do. I appreciate the help! I guess if my questions are getting harder, the answers get harder too.
suprabeener
May 23rd, 2002, 05:03 PM
you know, i'd probably just hard code the diagonal check, and check everytime regardless of which square was being marked.
Array.prototype.diagBingoCheck = function(){
var c,j=0; var k=5;
while(k--){
c += this[j++][k];
if(c==5) return true;
c=0;
while(j--){
c += this[j][k++];
}
if(c==5) return true;
return false;
}
suprabeener
May 23rd, 2002, 05:12 PM
actually, even cooler. you can tell if the square is on a diagonal because either j will equal k, or j+k will equal 4. so we can add to checkBingo:
Array.prototype.checkBingo = function(j,k){
var check;
// check the row
for(n in this[j]){ check+=this[j][n]; };
if(check == 5) return true;
check = 0;
// check the column
for(n in this){ check += this[n][k]; };
if(check == 5) return true;
if(j==k || j+k == 4) return( this.diagCheckBingo(); );
return false;
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.