Wednesday, April 13, 2022

How to hack chrome dinosaur game

Chrome Dinosaur Game Hack


Setp 1: Open dinosaur game in chrome. Initially, when you collide with the cactus plant, the game is over.


Step 2: Press Ctrl + Shift + j to open the console window.


Step 3: Type the following commands:

Runner.instance_.gameOver = () => {}


Step 4: Press enter.


It's done. Now your dinosaur is not going to collide with the cactus plant and hence, the game is not going to be over.



Watch Video





Sunday, August 22, 2021

Fruit Ninja Game




Codes: 

//Creating Background
var bg = createSprite(200,200);
bg.setAnimation('<Animation Name>');

//Creating Sword
var sword = createSprite(200,200);
sword.setAnimation('<Animation Name>');
sword.scale = 0.2;
sword.visible = false;

//Creating Fruit and Bomb Groups
var fruitGrp = createGroup();
var bombGrp = createGroup();

//Creating Game State
var gameState = 'start';

//Creating Score
var score = 0;

//Creating Ready Logo
var ready = createSprite(200,200);
ready.setAnimation('<Animation Name>')

//Creating Over Logo
var over = createSprite(200,175);
over.setAnimation('<Animation Name>');
over.visible =false;

//Creating Fruits Spawn Function
function Fruits(){
  
 if(frameCount%80===0){
   var fruit = createSprite(random(5,395),-10);
   var r = Math.round(random(1,4));
   fruit.setAnimation('<Animation Name>');
   fruit.scale= 0.13;
   fruit.velocityY = (10+(score/25));
   fruit.lifetime = 50;
   fruitGrp.add(fruit);
   
 }
}

//Creating Bomb Spawn Function
function Bomb(){
  
 if(frameCount%110===0){
   var bomb = createSprite(random(5,395),-10);
   var r = Math.round(random(1,4));
   bomb.setAnimation('<Animation Name>');
   bomb.scale= 0.13;
   bomb.velocityY = (10+(score/35));
   bomb.lifetime = 50;
   bombGrp.add(bomb);
   
 }
}

//Creating Scoring Function
function Score(){
  
  if(sword.isTouching(fruitGrp)){
    
    playSound("sound://category_swish/deep_swish_1.mp3")
    fruitGrp.destroyEach();
    score = score + 5;
  }
}

//Creating Game Over Function
function Over(){
  
  if(sword.isTouching(bombGrp)){
    playSound("sound://category_music/8bit_game_over_1.mp3")
    fruitGrp.destroyEach();
    bombGrp.destroyEach();
    gameState='over'
  }
}


function draw() {
  
//Displaying Sprites
  drawSprites();
  
  if(gameState==='start'){
    
    over.visible =false;
    ready.visible =true;
    
    if(frameCount%50 === 0){
      gameState='play'
     
    }
    
  }
  
  if(gameState==='play'){
    
    sword.visible = true;
    ready.visible = false;
    
//Sword Movement with Mouse
    sword.x = World.mouseX;
    sword.y = World.mouseY;
    
//Calling functions
    Fruits();
    Bomb();
    Score();
    Over();
    
    fill('white');
    textSize(20)
    text("Score: "+score,300,30);
  }
  
  if(gameState==='over'){
    
    sword.visible = false;
    over.visible =true;
    
    
    fill('white');
    textSize(30)
    text('Total Score: '+score,100,250);
    text('Press ENTER to restart',45,300);
    
    if(keyDown('enter')){
      
      gameState = 'start';
      score = 0;
      fruitGrp.destroyEach();
      bombGrp.destroyEach();
    }
    
  }
}
  
 

Plane Adventure Game

Codes:

var plane = createSprite(50,200);

plane.setAnimation('<Animation Name>');

plane.scale = 0.7;

plane.visible = false;


var coinGroup = createGroup();

var cloudGroup = createGroup();


var gameOver = createSprite(200,150);

gameOver.setAnimation('<Animation Name>');

gameOver.visible = false;


var getReady = createSprite(200,200);

getReady.setAnimation("<Animation Name>");

getReady.visible = false;



var gameState = 'start';


var  score = 0;

var hiScore = 0;


function Movement(){

  

  plane.velocityX = 0;

  plane.velocityY = 0;

  

  if(keyDown("up")){

    plane.velocityY = -10

  }

  

  if(keyDown("down")){

    plane.velocityY = 10

  }

  

  if(keyDown("RIGHT_ARROW")){

    plane.velocityX = 10

  }

  

  if(keyDown("LEFT_ARROW")){

    plane.velocityX = -10

  }

}


function SpawnCoins(){

  if(World.frameCount%80 === 0){

    var rand = random(10,390)

    var coin = createSprite(410,rand);

    coin.setAnimation("<Animation Name>");

    coin.velocityX = -5;

    coin.scale = 0.4;

     coin.lifetime = 100;

     

     coinGroup.add(coin)

  }

}


function SpawnClouds(){

  if(World.frameCount%110 === 0){

    var rand = random(10,390)

    var cloud = createSprite(410,rand);

    cloud.setAnimation("<Animation Name>");

    cloud.velocityX = -5;

    cloud.scale = 0.2;

    cloud.lifetime = 100;

    cloudGroup.add(cloud);

  }

}


function Score(){

  

  if(plane.isTouching(coinGroup)){

    score++;

    coinGroup.destroyEach();

  }

}


function HiScore(){

  if(score>hiScore){

    hiScore = score

  }

}


function GameOver(){

  

  if(plane.isTouching(cloudGroup)){

    coinGroup.destroyEach();

    cloudGroup.destroyEach();

    gameState = 'over'

  }

}


function draw() {

  

  background('cyan');

  

  drawSprites();

  

  createEdgeSprites();

  

  plane.collide(edges);

  

  if(gameState === 'start'){

    getReady.visible = true;

    gameOver.visible = false;

    plane.visible = false;


    if(World.frameCount%50 === 0){

      gameState = 'play'

    }

  }

  

  if(gameState === 'play'){

    

  getReady.visible = false;

  plane.visible = true;

    

  Movement();

  SpawnCoins();

  SpawnClouds();

  Score();

  HiScore();

  GameOver();

  

  fill("blue");

  textSize(20)

  text('Score: '+score,300,30)

  }

  

  if(gameState === 'over'){

    plane.visible = false;

    gameOver.visible = true;

    

    fill("blue");

  textSize(30)

  text('High Score: '+hiScore,100,250)

    text('Score: '+score,140,300)

  text('Press ENTER to restart',50,350)

    

    if(keyDown('enter')){

      gameState = 'start';

      plane.x = 50;

      plane.y = 200;

      score = 0;

    }

  }

}


Friday, August 20, 2021

Maze runner game (Part 1)

 


Codes:

// Creating Boundries

var Boundry1 = createSprite(200,5,400,10);

Boundry1.shapeColor = 'red';

var Boundry2 = createSprite(395,200,10,400);

Boundry2.shapeColor = 'red';

var Boundry3 = createSprite(200,395,400,10);

Boundry3.shapeColor = 'red';

var Boundry4 = createSprite(5,200,10,400);

Boundry4.shapeColor = 'red';

// Creating Walls

var wall = createSprite(50,50,5,100);

wall.shapeColor = ("red");

var wall2 = createSprite(75,50,50,5);

wall2.shapeColor = ("red");

var wall3 = createSprite(100,125,5,155);

wall3.shapeColor = ("red");

var wall4 = createSprite(75,150,50,5);

wall4.shapeColor = ("red");

var wall5 = createSprite(100,200,100,5);

wall5.shapeColor = ("red");

var wall6 = createSprite(50,225,5,55);

wall6.shapeColor = ("red");

var wall7 = createSprite(25,300,50,5);

wall7.shapeColor = ("red");

var wall8 = createSprite(50,375,5,50);

wall8.shapeColor = ("red");

var wall9 = createSprite(150,225,5,55);

wall9.shapeColor = ("red");

var wall10 = createSprite(100,275,5,55);

wall10.shapeColor = ("red");

var wall11 = createSprite(125,300,55,5);

wall11.shapeColor = ("red");

var wall12 = createSprite(150,325,5,50);

wall12.shapeColor = ("red");

var wall13 = createSprite(125,350,55,5);

wall13.shapeColor = ("red");

var wall14 = createSprite(100,375,5,50);

wall14.shapeColor = ("red");

var wall15 = createSprite(200,350,5,100);

wall15.shapeColor = ("red");

var wall16 = createSprite(225,350,50,5);

wall16.shapeColor = ("red");

var wall17 = createSprite(200,250,100,5);

wall17.shapeColor = ("red");

var wall18 = createSprite(250,275,5,55);

wall18.shapeColor = ("red");

var wall19 = createSprite(275,300,50,5);

wall19.shapeColor = ("red");

var wall20 = createSprite(300,275,5,55);

wall20.shapeColor = ("red");

var wall21 = createSprite(300,375,5,50);

wall21.shapeColor = ("red");

var wall22 = createSprite(350,300,5,200);

wall22.shapeColor = ("red");

var wall23 = createSprite(275,200,155,5);

wall23.shapeColor = ("red");

var wall24 = createSprite(200,125,5,155);

wall24.shapeColor = ("red");

var wall25 = createSprite(125,100,50,5);

wall25.shapeColor = ("red");

var wall26 = createSprite(225,50,50,5);

wall26.shapeColor = ("red");

var wall27 = createSprite(250,75,5,55);

wall27.shapeColor = ("red");

var wall28 = createSprite(300,100,100,5);

wall28.shapeColor = ("red");

var wall29 = createSprite(300,25,5,50);

wall29.shapeColor = ("red");

var wall30 = createSprite(325,50,55,5);

wall30.shapeColor = ("red");

var wall31 = createSprite(325,150,150,5);

wall31.shapeColor = ("red");


// Creating Player

var player = createSprite(75,75,15,15);

player.shapeColor = 'cyan'


// Creating Groups

var BoundryGroup = createGroup();

var WallGroup = createGroup();


// Adding Boundries in Boundry Group

BoundryGroup.add(Boundry1);

BoundryGroup.add(Boundry2);

BoundryGroup.add(Boundry3);

BoundryGroup.add(Boundry4);


// Adding Walls in Wall Group

WallGroup.add(wall)

WallGroup.add(wall2)

WallGroup.add(wall3)

WallGroup.add(wall4)

WallGroup.add(wall5)

WallGroup.add(wall6)

WallGroup.add(wall7)

WallGroup.add(wall8)

WallGroup.add(wall9)

WallGroup.add(wall10)

WallGroup.add(wall11)

WallGroup.add(wall12)

WallGroup.add(wall13)

WallGroup.add(wall14)

WallGroup.add(wall15)

WallGroup.add(wall16)

WallGroup.add(wall17)

WallGroup.add(wall18)

WallGroup.add(wall19)

WallGroup.add(wall20)

WallGroup.add(wall21)

WallGroup.add(wall22)

WallGroup.add(wall23)

WallGroup.add(wall24)

WallGroup.add(wall25)

WallGroup.add(wall26)

WallGroup.add(wall27)

WallGroup.add(wall28)

WallGroup.add(wall29)

WallGroup.add(wall30)

WallGroup.add(wall31)


function draw() {

  //Assigning player's velocity

  player.velocityX = 0;

  player.velocityY = 0;

  // Player's movement

  if(keyDown('UP_ARROW')){

    player.velocityY = -7;

  }

   if(keyDown('DOWN_ARROW')){

    player.velocityY = 7;

  }

   if(keyDown('LEFT_ARROW')){

    player.velocityX = -7;

  }

  if(keyDown('RIGHT_ARROW')){

    player.velocityX = 7;

  }

  

  // Reset the player

  if(player.isTouching(BoundryGroup)){

    player.x = 75;

    player.y = 75;

  }

  if(player.isTouching(WallGroup)){

    player.x = 75;

    player.y = 75;

  }


  background("black")

  drawSprites();

}

Sunday, August 1, 2021

Virtual Pet (Part 4)

 


Step I: Create variables play, eat, bath and sleep for each buttons.


Step II: In setup() function, create buttons and position them.


Step III: Create different functions for different buttons which will change the gameState in database. You can use updateState() function inside that functions which you have created on previous part.


Step IV: In setup() function, create mousePressed property for all that created buttons and call the functions which you created inside mousePressed() function.


Step V: In draw() function, come to if condition where you wrote that if gameState is not equal to hungry thne you were hiding the add food and feed food button. There you have to add one more line to show eat button and in else part, you hide the eat button.


Step VI: Now come to the if condition where you are updating gameState according to feed time and there change the if condition to gameState === '........' and inside that if condition, remove updateState() function.



Video:~





Tuesday, July 13, 2021

Plinko Game (Part 2)

 



Step I: Create variables score and turn and assign both the values 0.


Step II: Since there will be only one particle while calculating the score, we need to create a variable particle so create a variable particle and assign its value to null and at the same time, remove the array particles we created in last post.


Step III: Display the score at your desire position. In my case, I am placing it at top right corner.



Step IV: In for loop of division in setup() function, change the variable from 5 to 0 the shift the divisions.


Step V:  Specify the points between the divisions using text.



Step VI: Now create a variable gameState and assign its value to play.


Step VII: Then we will use mouseReleased() function to create new particles at the x position similar to mouse x coordinate and y to 10 and assign it to variable particle which we created in step II.


Step VIII: Write the logic given below to determine in which division the particle is. After then, add the scores according to divisions and once the score is calculated, set the particle to null. At the same time, check that if the turn is greater then or equal to 5 or not. If it is greater then or equal to 5 then change the gameState to 'end'.



Step IX: Now, in mouseReleased() function, increase the turn by 1.


Step X: Then, in draw() function, display the text 'Game Over' using if condition when the gameState will be 'end'. Also, write one more if condition inside this if condition which will restart the game when we press 'ENTER' key.


Bug Fixing:

1. When the gameState is 'end', the plinko, divisions, ground and text of score should not be visible. So, for that, write an if condition that if gameState is not end, then inside it, display text of scores, divisions, plinkos and grounds.


2. When you press the mouse button when the particle is visible on screen, that particle goes vanished and new particle falls again or when the game over and you press the mouse button, the particle is created. To fix it, in mouseReleased() function, we have to write condition that if gameState  is not equal to 'end' or the particle is null, then only, a new particle must be created.



Video:-



Monday, July 5, 2021

Plinko Game (Part 1)

 



Step I: First, create a canvas of width 800 and height 600.

Step II: Then create four new files and named it as Ground.js, Division.js, Plinko.js and Particle.js.

Step III: Now, in Ground.js, create a class and name it as Ground and make it a static body.


Step IV: In Division.js, it will be similar tp Ground .js, but it should be taller than its wider so you can copy the codes from Ground.js and paste it in Division.js and change the name of class to Division.


Step V: In Plinko.js, create a Plinko class with every plinko being a circular body of radius 10.


Step VI: In Particle.js, create a Particle class with every particles being a circular body of radius 10. Add a color property for the particle in the constructor then use this color property in the display() method.


Step VII: Now add all these files in index.js.


Step VIII: Now, in Sketch.js, first create a world and engines using matter.js and at the same time, create a ground also.


Step IX: Then create three arrays named particles, plinkos and divisions. Similarly, create a variable divisionHeight and assign its value to 150.


Step X: Now, in setup() function, create multilple divisions using for loop.


Step XI: In draw() function, use for loop to display multiple divisions.


Step XII: Similarly, in setup() function, use for loop to display plinkos also. You have to write four for loops to create four rows.


Step XIII: Same as you displayed divisions using for loop, display plinkos also. The for loop will be same but the name should be different.


Step XIV: In draw() function only, create a new particle after every 60 frames.


Step XV: Same as you displayed plinkos using for loop, display particles also. The for loop will be same but the name should be different.


Step XVI: Check your game that is it working properly or not.


Here this part ends.
In the next part, we will add scoring system.

Video:-




Saturday, July 3, 2021

Virtual Pet (Part 3)

 


Step I: First we will display the last feeding time on screen.


Step II: Open firebase database and create a node named 'gameState' which will take a string value "hungry".


Step III: In sketch.js, create two variables named gameState and readState.


Step IV: In setup() function, we will refer the gameState from database and store its value inside gameState variable.


Step V: Preload the images of bedroom, garden and washroom and more if you want.


Step VI: Now, in Food.js file, create three methods - bedroom(), garden(), washroom() and add background function with their respective images.


Step VII: Change the width and height of canvas and x and y coordinate of dog and bottle(Food.js).



Step VIII: In draw() function write condition for gamestate that if gameState is not hungry then hide the AddFood and FeedFood button else show the AddFood and FeedFood button, food class and dog sprites. For that, move food.display() and drawsprites()  functions in else part of this condition.


Step IX: Now, create a variable currentTime and in setup() function, store the hour in it using hour() function.


Step X: In draw() function, write a condition that if current time is greater than 1 hour of feeding time, the background will be changed to garden. Similarly, if current time is greater than 2 hour of feeding time, the background will be changed to bedroom and if current time is between 3 to 4 hour of feeding time, the background will be changed to washroom. To change the background, we will call the functions which we have created in Food.js where we have loaded the images of background (Step VI).


Step XI: Now, create an updateState() function which will take an argument which we are going to use to update the gameState in database.


Step XII: Come back to the condition where we changed the background (which is created in step x) and after changing the background, update the gameState.


Step XIII: Now, there is a bug that when we press AddFood button the bottle increases and there is no limit to add the bottled which overlaps the dog sprite. To fix it, we will write an if condition so that there will be a limited number of bottles only.  So, in AddFood() function, write an if condition that if bottle is smaller than 60 then only the bottle will increase.


Step XIV: Now, if you want, you can change the time format from 24 hours to 12 hours. For that, you have to write the conditions to display the time.



Now your game is completed and ready to play.

Video: