Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Reno, NV
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Some Math Help Needed

    Alright...so I'm making this poker web site and I need a bit of help displaying the chips when a bet is made. I currently am able to calculate how many of each denomination is needed to fulfill the bet, but I don't know how to go about displaying them.

    My denominations are:

    $1, $5, $25, $100, $1000, $5000, $25000, $100000

    I then pass the bet amount to a function that provides me this information:

    Array
    (
    [1] => 0
    [5] => 1
    [25] => 0
    [100] => 7
    [1000] => 0
    [5000] => 0
    [25000] => 0
    [100000] => 0
    )

    This shows how many of each chip is needed to be displayed. On the page for this to be displayed I have two rows of ten stacks. Each stack contains six chips. Stacks are labeled from 0 to 9 and chips are labeled from 0 to 5.

    I have tried for loops and such but just can't seem to get it to work correctly. Does anyone have any ideas?

    Thanks a ton,

    Troy

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,378
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    I would take a CSS graphic approach to this:

    In my example: http://www.catpin.com/poker/

    View the HTML source of my example and see how the height
    is altered in each <div> ... overflow is hidden.

    This is the PHP script:
    PHP Code:
    <html>
    <head><title>poker chip display</title>

    <style>
    .col{
    background: url(chips.gif) no-repeat;
    height:428px;
    width:42px;
    float:left;
    overflow:hidden;
    }
    </style>

    </head>
    <body>
    <?php
    $onechip
    =42// the height of one chip
    $pile1 = array(4,10,2,5,3);
    foreach (
    $pile1 as $count)
    {
    $chips $onechip*$count;
    echo
    "<div class='col' style='height:".$chips."px;'></div> \n";
    }
    ?>
    </body>
    </html>

    I have one graphic image with all 10 chips.
    I then only display a certain amount of the image by
    cutting-off the image with "height" of the <div>.

    This would render very fast and is easy to implement.

    You of course create any graphic images of chips that you want.
    They could be chips from a side-view, or top-view (like I did).

    You could also do it horizontally by creating a horizontal graphic
    and adjusting the width instead of height.


    .
    Last edited by mlseim; 02-06-2007 at 02:49 PM.

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    That's pretty clever mlseim, a very novel approach even.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •