Results 1 to 2 of 2

Thread: Setting a time change interval?

  1. #1
    Join Date
    Dec 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Setting a time change interval?

    Hello, I was wondering if someone cold show me how to make my game so that every 2 seconds, the image changes to a different cell if the user does not click it. But if the user does click the image before the 2 seconds are up, then the image changes to a different cell. Thank you very much

    PHP Code:
    <html>
    <
    head>
        <
    STYLE type="text/css">


    TD
    {
        
    FONT-WEIGHTbold;
        
    FONT-SIZE75pt;
        
    WIDTH75pt;

        
    COLORblack;
        
    FONT-FAMILYWingdings;
        
    HEIGHT20pt;

        
    TEXT-ALIGNcenter
    }

    H5
    {
        
    MARGIN-TOP0px;
        
    MARGIN-BOTTOM0px
    }

        </
    STYLE>
    <
    script style="text/javascript">


    var 
    score=0;
    var 
    now=scoreDate.valueOf();
            var 
    imgSrc "mole.jpg";
            var 
    imgCell;


    function 
    putscore()
        {
            
    scoreDate=new Date()
            if (
    document.getElementById
            
    document.getElementById("score").innerHTML=score ;  
        }

    function 
    reset()
        {
            
    score=0;
            
    putscore();
        }

    function 
    highlight(cell)
        {
            var 
    oncell false;
            var 
    r=Math.round(9*Math.random()) +10;

            if (
    document.getElementById) {
            
    cell document.getElementById(cell);
            if (
    cell && cell.innerHTML != "&nbsp;") {
                
    cell.innerHTML "&nbsp;";
                    
    oncell true;
            }
            
    if (
    oncell) {
                
                
    imgCell document.getElementById("cell_"+r);
                if (
    imgCell
            {
                    
    imgCell.innerHTML '<img src="mole.jpg" border="0" alt="Picture Unavailable">';
                } 
            else 
            {
                    
    document.getElementById("cell_10").innerHTML '<img src="mole.jpg" border="0" alt="">';
                }
                
                
    score++;
                
    putscore();
            }
        }
    }
    </script>
    </head>

    <body>

    <h2 align="center">Whack the Mole</h2>

    <h4 align="center">Hits=<span id="score">0</span></h4>

    <table border="1" align="center" cellspacing="0" cellpadding="0">
        <tr>

            <td id="cell_10" onclick="highlight('cell_10');return true;"><img src="mole.jpg"></td>
            <td id="cell_11" onclick="highlight('cell_11');return true;">&nbsp;</td>
            <td id="cell_12" onclick="highlight('cell_12');return true;">&nbsp;</td>
            
        </tr>
        <tr>
            <td id="cell_13" onclick="highlight('cell_13');return true;">&nbsp;</td>
            <td id="cell_14" onclick="highlight('cell_14');return true;">&nbsp;</td>
            <td id="cell_15" onclick="highlight('cell_15');return true;">&nbsp;</td>
            
        </tr>
        <tr>
            <td id="cell_16" onclick="highlight('cell_16');return true;">&nbsp;</td>
            <td id="cell_17" onclick="highlight('cell_17');return true;">&nbsp;</td>
            <td id="cell_18" onclick="highlight('cell_18');return true;">&nbsp;</td>
        
        </tr>

        

    </table>
    <p align=center><input type="reset" onclick="javascript:reset(); return true;"></p>

            
    </body>
    </html> 

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,475
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Last edited by jscheuer1; 12-06-2007 at 12:25 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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