Bingo - Back to Homepage
Bingo Home Search Add to Favorites Contact Us 
 

I created a simple bingo game using java script. How can I have the script alert a player when he gets bingo?

I used an “onclick” command to turn the squares gray when I click a called number so what kind of script could I use to alert me when all of the squares in a single row, column, or diagonal are gray?

Question asked by: Curious George

This post powered by Yahoo! Answers

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!


If you found this page useful, consider linking to it.
Simply copy and paste the code below into your web site (Ctrl+C to copy)
It will look like this: Bingo java script


Top Bingo Picks for Friday, December 15, 2017

 

Comments & Feedback on "Bingo java script"

This post currently has 1 Comment

You are welcome to add new comments. .

Subscribe to the RSS 2.0 feed for comments on this post.

One Response to “Bingo java script”

  1. Rafal Says:

    Caffeinated Content

    You need to declare variables names for each possible 5 in a row.

    row1, row2, row3, row4, row5, col1, col2, col3, col4, col5, diag1, diag2

    and set each variable to equal 0 except for row3, col3, diag1, and diag2 which should be set to 1 because they contain the free square.

    as part of the onclick function for each squares, add 1 to each of the rows, columns or diagonals it affects. So, for example, if you call out N32 and 32 is in the second row of the third( or N) column, then when you click on that box, it should add a value of 1 to row2 and col3.

    The function for each of the squares should call a second function to check all the rows, columns and diagonals to see if there value is equal to 5. and if so, alert the player.

    The method should work but i haven’t done javascript for a long time. I already know the following code doesn’t work but your code should look similar:

    >> Create these variables:

    var row1=0
    var row2=0
    var row3=1
    var row4=0
    var row5=0
    var col1=0
    var col2=0
    var col3=1
    var col4=0
    var col5=0
    var diag1=1
    var diag2=1

    >> Assuming the function 24SquareHit is assigned to square 4 in column 2, add this to that function:

    function 24SquareHit()
    {
    col2 = col2 + 1;
    row4 = row4 + 1;
    check();
    }

    >> Do that for all of the onclick functions, but of course have them change the correct variables.

    >> Create a function that checks if you have 5 in a row:

    check()
    {
    if (row1==5 || row2==5 || row3==5 || row4==5 || row5==5 || col1==5 || col2==5 || col3==5 || col4==5 || col5==5 || diag1==5 || diag2==5)
    {
    alert(“you win”);
    }
    }

    Also you will need to find a way to disable clicking the same square more than once.

    I hope that can help you a bit :)

Leave Your Comments:



Sitemap|Contact Us|Privacy Policy|Disclaimer|Advertising|Webmasters

Newsletter

Sign up to receive our great newsletter today!

Email:
Name:


Search

Copyright

Gamcare Gamblers Anonymous