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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JavaScript Game - Onclick Not Working...

    Hey, I am having a problem with a javascript game I made. It works great except for the fact that sometimes when you shoot a target it doesn't always turn into a check mark. What am I doing wrong?

    Stophon4 - Stophon4.com
    http://www.stophon4.com

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    LOL........your links dont work for me either.

    I tried clicking the links you gave above, and they dont work.
    LovesWar

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, i turns into a mark. You just have to like hit the middle of the target. i got all 4. Not a bad game.
    LovesWar

  • #4
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well sometimes it doesn't, and sometimes it does, but it always does if you hit it in the center, weird...
    http://www.stophon4.com

  • #5
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    post the main part of the code.

    Well, if you deconstruct the code for us, someone might be able to help you.
    LovesWar

  • #6
    Regular Coder
    Join Date
    Mar 2004
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK, here's the code for level three, it usually only happens on this level
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <
    HTML>
    <
    HEAD>
    <
    TITLE>Shooting Game Level 2 Stophon4.com</TITLE>
    <
    Style type='text/css'>
    BODY {
        
    overflowhidden;
        
    cursorurl("test.ani");
        
    background-colorblue;
    }
    </
    STYLE>
    <
    SCRIPT type='text/javascript'>
    var 
    xpos 50;
    var 
    ypos 50;
    var 
    hits 0;

    function 
    walk(){
        
    xpos++;
        
    xpos++;
        
    xpos++;
        
    target.style.left xpos;
        
    target2.style.left xpos;
        
    target3.style.left xpos;
        
    target4.style.left xpos;
        if(
    xpos >= 1500){
            
    end();
        }else{
            
    window.setTimeout("walk();",1);
        }
    }
    function 
    hit(){
        
    hits++;
        if(
    hits == 4){
            
    window.setTimeout("end();",1000);
        }
    }
    function 
    end(){
        if(
    hits == 0){
            
    alert("Your percentage is 0% !");
            
    alert("That Stinks!!");
        }else if(
    hits == 1){
            
    alert("Your percentage is 25% !");
            
    alert("Come On! You can do better than that!");
        }else if(
    hits == 2){
            
    alert("Your percentage is 50% !");
            
    alert("Your half as good as you should be!");
        }else if(
    hits == 3){
            
    alert("Your percentage is 75% !");
            
    alert("3/4, That's not good enough!");
        }else if(
    hits == 4){
            
    alert("Your percentage is 100% !");
            
    alert("You got a perfect score! Congratulations!");
            
    alert("Here we go on level three!");
        }
        if(
    hits == 4){    
            
    document.location "game3.htm";
        }else{
            var 
    contin confirm("Play Again?");
            if(
    contin){
                
    document.location.reload();
            }else if(!
    contin){
                
    document.location "http://www.stophon4.com";
            }
        }
    }
    </SCRIPT>
    </HEAD>
    <BODY OnLoad="walk()">
    <img src='targets.gif' id='target' Style='top:5%;;left:100;position:absolute;visibility:visible;' Onclick='hit();this.src = "done.gif";'>
    <img src='targets.gif' id='target2' Style='top:25%;;left:100;position:absolute;visibility:visible;' Onclick='hit();this.src = "done.gif";'>
    <img src='targets.gif' id='target3' Style='top:45%;;left:100;position:absolute;visibility:visible;' Onclick='hit();this.src = "done.gif";'>
    <img src='targets.gif' id='target4' Style='top:65%;;left:100;position:absolute;visibility:visible;' Onclick='hit();this.src = "done.gif";'>
    </BODY>
    </HTML> 
    http://www.stophon4.com


  •  

    Posting Permissions

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