Saturday, May 25, 2013

    I have been working on a game in the tradition of gorillas.bas using html5 and Javascript (stubbornly refusing to use jquery for this project. next time.).

Here's a remake:

http://www.kongregate.com/games/moly/gorillas-bas

Here is the source in qBasic:

http://hem.passagen.se/hedsen/prg/games/gorilla.bas 

    (be careful with this site; it likes to bombard you with bullshit)


My version at the request of my girl friend will feature monkeys throwing exploding baby monkeys at each other instead of bananas. As of now it is a complete mess. It actually won't work at a all. I had it sort of working for just one gorilla then i tried to make it to player before I put the final animations and stuff in and added the generation of the skyline and stuff. I was riding high after fixing a bug that would cause gorillas to explode inappropriately; I went too far; I destroyed the whole thing.

    <form id ="shotInput">
        Angle: <input type="hidden">
        Power: <input type="hidden">
       
        <input id="fireB" type="hidden" onclick="taketurn(this.form)" value="FIRE">
    </form>

That is where the problem starts. The shooting information is entered into those input boxes on this form.  They become visible when you click the "start game button. That was not a problem (doesn't work everywhere though).  The problem came when I decided I wanted another box on the form that would store which player was shooting. Like this:

<input type ="hidden" value="player1">
Then I had my taketurn()  look like this:

function taketurn(form){
            //starts a turn by passing the initial vector states from <form> to a missile object 
            alert('hello!');
            console.log('taking a turn');
            alert(form[2].value);
           
            if(form[2]== 'player1'){
                this.angle = Number(form[0].value);
                this.power = Number(form[1].value);
                this.whichGor = 0;
            }
            else if(form[2] =='player2'){
                this.angle = Number(180 - form[0].value);
                this.power = Number(form[1]* -1);
                this.whichGor = 1;
            }
           
            var missile = new aMissile(this.whichGor, this.angle, this.power);
            //alert(missile.yVector);
            missile.shoot();
            if(missile.hitMonkey){
                cleanUp();
            }
        }
Previously my taketurn() had looked like this:

      function taketurn(form){
            //set up html on form
            //alert("take turn is executing");
            this.angle = Number(form[0].value);
            this.power = Number(form[1].value);
            var missile = new aMissile(this.angle,this.power);
            //alert(missile.yVector);
            missile.shoot();
        }
   
This worked. I added in cleanUp(). That worked too. All it does is clear the screen. I am scrapping my last bit of coding and redoing this mess. I am too stupid too figure out what is wrong. I did too much work before I tested it. When you are trying things you've never done before you really need to test after every little step.

Here is the full broken program:

 https://c9.io/dogmeethorse/monkey

Here is the recovered backup old version:

https://c9.io/dogmeethorse/turnt-octo-lana

No comments:

Post a Comment