Giter Site home page Giter Site logo

fruit-catcher-1's Introduction

class Game { constructor(){

}

getState(){
    var gameStateRef = database.ref('gameState');
    gameStateRef.on("value",function(data){
        gameState = data.val();
    });
}


update(state){
    database.ref('/').update({
        gameState: state
    });
}

async start(){ if(gameState===0){ player=new Player(); var playerCountRef=await database.ref('playerCount').once("value"); if(playerCountRef.exists()){ playerCount=playerCountRef.val(); player.getCount(); } player.getCount(); form = new Form(); form.display(); } car1= createSprite(100,200); car1.addImage(carImg1); car2= createSprite(300,200); car2.addImage(carImg2); car3= createSprite(500,200); car3.addImage(carImg3); car4= createSprite(700,200); car4.addImage(carImg4);

        cars=[car1,car2,car3,car4];
}

play(){
    form.hide();
   
    Player.getPlayerInfo();
    if(allPlayers!==undefined){
        background("brown");
        image(trackImg,0,-displayHeight*4,displayWidth,displayHeight*5);
        var index=0;
        var x=200;
        var y;
        for(var p in allPlayers){
            index=index+1;
            x=x+230;
            y=displayHeight-allPlayers[p].distance;
            cars[index-1].x=x;
            cars[index-1].y=y;
            if(index===player.index){
                cars[index-1].shapeColor="red";
               camera.position.x=displayWidth/2;
               camera.position.y=cars[index-1].y;
            }
        }
    }

    if(keyIsDown(UP_ARROW)&&player.index!==null){
        player.distance+=50;
        player.update();            
    }
   if(player.distance>4500){
       game.update(2);
   }
    drawSprites();
}

end(){
    console.log("Game Ends");
}

}

fruit-catcher-1's People

Contributors

aatreyee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.