Project: Snake & Ladder Game in C++ Programming Language

 Project: SNAKE and Stepping stool GAME





SNAKE and Stepping stool GAME

Project: Snake and Stepping stool Game


Game Standards:


  • Every player enters a name and the player's ostensible position is zero.
  • Throw the dice all together in the game.
  • On the off chance that tokens (saves) tumble to the lower part of the stepping stool, you can move to the highest point of the stepping stool.
  • If a token (score) lands on a snake, it should slide down to the lower part of the snake. Assuming the player's score surpasses 100, that player dominates the match.


Code in C++


#include<iostream>

#include<conio.h>

#include<stdlib.h>

#include<stdio.h>

#include<time.h>

utilizing namespace sexually transmitted disease;

// Draw implies we are Defining boundaries for yield

void Draw( int no , roast ch ) {

for( int I = 0; I <= no ; i++ )

cout << ch ;

}

// Making the Board for Game snake and stepping stool game

void Board( ) {

// system("CLS") This capability is utilized for clear screen of the result

framework( "CLS" ) ;

cout << " \n \n " ;

Draw( 60 , '- ' ) ;

cout << " \n \t \t SNAKE AT POSITION \n " ;

Draw( 60, '- ' ) ;

cout<< " \n \t From 98 to 28 \n \t From 95 to 24 \n \t From 92 to 51 \n \t From 83 to 19 \n \t From 73 to 1 \n \t From 69 to 33 \n \t From 64 to 36 \n \t From 59 to 17 \n \t From 55 to 7 \n \t From 52 to 11 \n \t From 48 to 9 \n \t From 46 to 5 \n \t From 44 to 22 \n \n ";

Draw( 60 , '- ' ) ;

cout << " \n \t \t Stepping stool AT POSITION \n ";

Draw( 60 , '- ' ) ;

cout<< " \n \t From 8 to 26 \n \t From 21 to 82 \n \t From 43 to 77 \n \t From 60 to 91 \n \t From 62 to 96 \n \t From 66 to 87 \n \t From 80 to 100 \n ";

Draw( 60 , '- ' ) ;

cout<< endl;

}

// Making Game Score that shows the situation with the game and furthermore position of players

void Score(char Name_1[], scorch Name_2[], int p_1, int p_2) {

cout<< " \n ";

Draw( 60 , '~' ) ;

cout<< " \n \t \t => GAME STATUS <= \n ";

Draw( 60 , '~' ) ;

cout<< " \n \t - - - >" << Name_1 << " is at position " << p_1 << std::endl;

cout<< " \t - - - >" << Name_2 << " is at position " << p_2 << std::endl;

Draw( 60 , '_' ) ;

cout << endl ;

}

// Making Dice and actually looking at the Game principles for lead or snake

void playDice (int and Score) {

// Use work in capability to causing dice that to produce the dice number 1 to 6 arbitrarily

srand(time(NULL));

int Dice = rand() % 6 + 1;

cout<< " \n => You got => " << Dice << " Point !! ";

Score = Score + Dice;

// really taking a look at position in the event that match than switch case is use

cout<< " _____Now you are at position___ " << Score;

switch (Score) {

case 98:

Score = 28;

break;

case 95:

Score = 24;

break;

case 92:

Score = 51;

break;

case 83:

Score = 19;

break;

case 73:

Score = 1;

break;

case 69:

Score = 33;

break;

case 64:

Score = 36;

break;

case 59:

Score = 17;

break;

case 55:

Score = 7;

break;

case 52:

Score = 11;

break;

case 48:

Score = 9;

break;

case 46:

Score = 5;

break;

case 44:

Score = 22;

break;

case 8:

Score = 26;

break;

case 21:

Score = 82;

break;

case 43:

Score = 77;

break;

case 60:

Score = 91;

break;

case 54:

Score = 93;

break;

case 62:

Score = 96;

break;

case 66:

Score = 87;

break;

case 80:

Score = 100;

break;

case 100:

break;

}  }

int primary( ) {

int Player_1 = 0, Player_2 = 0, Last_pos;

// determining the scope of the name of players

scorch Player_1name[80], Player_2name[80];

Draw(60, '=');

cout << " \n \n \n \n \t \t ___SNAKE and Stepping stool GAME___ \n \n \n \n ";

Draw(60, '=');

cout << " \n \n \n Enter Name of player 1 :";

gets (Player_1name);

cout<< " \n \n \n Enter Name of player 2 :";

gets (Player_2name);

// assuming any of player get less score than hundred than this circle execute

while(Player_1 < 100 && Player_2 < 100) {

Board( ) ;

Score(Player_1name, Player_2name, Player_1, Player_2);

cout<< " \n \n ==>" << Player_1name << " Presently your Turn >> Press any key to play ";

getch();

Last_pos = Player_1;

playDice(Player_1);

if(Player_1 < Last_pos) {

cout<< " \n \a Oh no!!- - - - - - - - - - - - - - - - - - - - - - Snake found !!!! - - - - - - - - - - - - - - - - - - - - - - - - - - Presently You are at postion " << Player_1 << " \n ";}

else if(Player_1 > Last_pos + 6) {

cout<< " \n WellDone!! - - - - - - - - - - - - - - - - - - - - - - - you got a stepping stool !!- - - - - - - - - - - - - - - - - - - - - - - - - Presently You are at position " << Player_1;

}

cout<< " \n \n ==>" << Player_2name << " Presently your Turn - - - - >> Press any key from console to play the Game ";

getch();

Last_pos = Player_2;

playDice(Player_2);

if(Player_2 < Last_pos)

{ cout<< " \n \n \a Uh oh!!- - - - - - - - - - - - - - - - - - - - Snake found !!- - - - - - - - - - - - - - - - - - - - - - - Presently You are at position " << Player_2 << " \n ";}

else if(Player_2 > Last_pos + 6) {

cout<< " \n \n WELLDONE !! - - - - - - - - - - - - - - - - - - - - - - - - - - you got a stepping stool - - - - - - - - - - - - - - - - - - !!Presently You are at position " << Player_2 << " \n ";}

getch();

}

// system("CLS") is utilized for clear screen

system("CLS");

cout<< " \n \n \n ";

Draw( 60 , '+' ) ;

cout<< " \n \n \t \t RESULT \n \n ";

Draw( 60 , '+' ) ;

cout << endl ;

//actually taking a look at champ of the game

Score(Player_1name, Player_2name, Player_1, Player_2);

cout<< " \n \n \n ";

// in the event that player 1 is champ

if(Player_1 >= Player_2)

cout<< Player_1name << " Compliment !!! You are the champ of the

 game \n \n ";

else

cout<< Player_2name << " Compliment !!! You are the champ of the game \n \n ";

Draw( 60 , '+' ) ;

getch( ) ;

}


Result of Above Code


I want to believe that You can undoubtedly Comprehend and Realize this Article


Good luck 😇

Post a Comment

0 Comments