Control that programmee with key

Assignment Help Basic Computer Science
Reference no: EM13162699

 

Please control that programmee with key (left ,right ,up and down ) and also make a chain of snake when eat egg,and game over when snake strike with hurdel.

#include<iostream>
#include<conio.h>
#include <windows.h>
using namespace std;
class snake
{
public:
void gotoxy(int x,int y) // x is column number and y is row number
{
   HANDLE console_handle;
   COORD cursor_coord;
   cursor_coord.X=x;
   cursor_coord.Y=y;
   console_handle=GetStdHandle(STD_OUTPUT_HANDLE);
   SetConsoleCursorPosition(console_handle,cursor_coord);
}
void board()
{
   char s=83,c=67,o=79,r=82,e=69,l=76,ee=69,v=86,eee=69,ll=76,one=48,two=48,equal=61;
   gotoxy(2,3);
   cout<<s<<c<<o<<r<<e<<equal<<one<<" "<<l<<ee<<v<<eee<<ll<<equal<<two<<endl;
   for(int i=0;i<70;i++)
   {
       gotoxy(1+i,4);
       char a=223;

       cout<<a;
       gotoxy(1+i,4);
  
       cout<<a;
  
       gotoxy(1+i,4);
       cout<<a;
   }
   //for vertical line
   for(int i=0;i<45;i++)
   {
       gotoxy(1,4+i);
  
       char b=219;
       cout<<b;
   }
   //for downline line
   for(int i=0;i<70;i++)
   {
       gotoxy(1+i,48);
       char c=223;

       cout<<c;
       gotoxy(1+i,48);

       cout<<c;
       gotoxy(1+i,48);

       cout<<c;
   }
   //for right hand line
   for(int i=0;i<44;i++)
   {
       gotoxy(70,i+4);
       char d=219;

       cout<<d;
   }
}
void track()
{
   //five track system 1
   for(int i=0;i<4;i++)
   {
       gotoxy(7,18+i);
       char qq=178;
       cout<<qq;
   }
   for(int i=0;i<4;i++)
   {
       gotoxy(7+i,21);
       char qq=178;
       cout<<qq;
   }
   //five track system 2
   for(int i=0;i<4;i++)
   {
       gotoxy(50,18+i);
       char qq=178;
       cout<<qq;
   }
   for(int i=0;i<4;i++)
   {
       gotoxy(50+i,17);
       char qq=178;
       cout<<qq;
   }
   //five track system 3
   for(int i=0;i<4;i++)
   {
       gotoxy(7,35+i);
       char qq=178;
       cout<<qq;
   }
   for(int i=0;i<4;i++)
   {
       gotoxy(7+i,35);
       char qq=178;
       cout<<qq;
   }
   //five track system 4
   for(int i=0;i<4;i++)
   {
       gotoxy(50,35+i);
       char qq=178;
       cout<<qq;
   }
   for(int i=0;i<4;i++)
   {
       gotoxy(50+i,38);
       char qq=178;
       cout<<qq;
   }
   //five track system 5
   for(int i=0;i<4;i++)
   {
       gotoxy(25,23+i);
       char qq=178;

       cout<<qq;
   }
   for(int i=0;i<4;i++)
   {
       gotoxy(25+i,22);
       char qq=178;
       cout<<qq;
   }
}
void shape()
{
   char B=111;
   gotoxy(4,8);
   cout<<B<<B<<B<<B<<B<<B;
}
void Right()
{
   char B=111;
    for(int i=0;i<56;i++)
   {
   gotoxy(4+i,8);
   cout<<" "<<B<<B<<B<<B<<B<<B;
   if(i==55)
   {
       gotoxy(4+55,8);
       cout<<" "<<" "<<" "<<" "<<"   ";
   }
   Sleep(200);
   }
   for(int i=0;i<34;i++)
   {
       gotoxy(67,8+i);
   cout<<" ";
   gotoxy(67,9+i);
   cout<<B;
   gotoxy(67,10+i);
   cout<<B;
   gotoxy(67,11+i);
   cout<<B;
   gotoxy(67,12+i);
   cout<<B;
   gotoxy(67,13+i);
   cout<<B;
   gotoxy(67,14+i);
   cout<<B;
   if(i==33)
   {
       gotoxy(67,14+33);
       cout<<" ";
       gotoxy(67,13+33);
       cout<<" ";
       gotoxy(67,12+33);
       cout<<" ";
       gotoxy(67,11+33);
       cout<<" ";
       gotoxy(67,10+33);
       cout<<" ";
       gotoxy(67,9+33);
       cout<<" ";

   }
   Sleep(200);
   }
   for(int i=0;i<54;i++)
   {
   gotoxy(57-i,47);
   cout<<B<<B<<B<<B<<B<<B<<" ";
   Sleep(200);
   if(i==53)
   {
       gotoxy(3,47);
       cout<<" "<<" "<<" "<<" "<<"   ";
   }
   }
   for(int i=0;i<33;i++)
   {
   gotoxy(3,41-i);
   cout<<B;
   gotoxy(3,42-i);
   cout<<B;
   gotoxy(3,43-i);
   cout<<B;
   gotoxy(3,44-i);
   cout<<B;
   gotoxy(3,45-i);
   cout<<B;
   gotoxy(3,46-i);
   cout<<B;
   gotoxy(3,47-i);
   cout<<" ";
   Sleep(200);
   if(i==32)
   {
       gotoxy(3,41-i);
       cout<<" ";
       gotoxy(3,42-i);
       cout<<" ";
       gotoxy(3,43-i);
       cout<<" ";
       gotoxy(3,44-i);
       cout<<" ";
       gotoxy(3,45-i);
       cout<<" ";
       gotoxy(3,46-i);
       cout<<" ";
       gotoxy(3,47-i);
       cout<<" ";
   }
   }
   for(int i=0;i<1;i++)
   {
       gotoxy(3+i,8);
       cout<<" "<<B<<B<<B<<B<<B<<B;
       Sleep(200);
   }
}
};
void main()
{
   system("color 35");
   snake s1;
   s1.board();
   s1.track();
   s1.shape();
   for(int i=0;i<3;i++)
   {
   s1.Right();
   }
   getch();
}

 

 

 

Reference no: EM13162699

Questions Cloud

What is the public interface of the counter class : what is the public interface of the counter class in section instance variables and encapsulation? How does it differ from the implementation of the class?
How does it differ from the implementation of the class? : what is the public interface of the counter class in section instance variables and encapsulation?
During the execution of the above code, how many instru : (a) During the execution of the above code, how many instructions are executed? (b) Assuming a standard unicycle machine (CPI = 1) running at 100 KHz, how long will the above code take to complete?
Create an application user to enter the following employee : Create an application that allows the user to enter the following employee data: First Name, Middle Name, Last Name, Employee Number, Department, Telephone Number, Telephone Extension, and E- mail Address. The valid selections for depart-ment are Acc..
Control that programmee with key : Please control that programmee with key (left ,right ,up and down ) and also make a chain of snake when eat egg,and game over when snake strike with hurdel.
We wish to process survey results : Suppose we wish to process survey results that are stored in a file. This exercise requires twoseparate programs. First, create a program that prompts the user for survey responses and outputseach response to a file
Given a 3 millisecond seek time : Given a 3 millisecond seek time for a disk drive and assuming that once you reach the starting track you will write the file as contiguous sectors, how long will it take to write a 1 megabyte file? The disk rotates at 7200 rpm and each sector hold 1 ..
User enters a negative number or a nondigit number : If the user enters a negative number or a nondigit number, throw and handle an appropriate exception and prompt the user to enter another nonnegative number.
Receiver r is conducting an auction : Assume the receiver R is conducting an auction in which two bidders each encrypt their bids using the scheme above and send them to R.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Determine features of ram to include in web server

Determine the features and capacities (RAM, disk storage, processor speed) that Amy should include in the Web server computer that she will need for her site.

  Why is this beneficial to the paging algorithm

Why is this beneficial to the paging algorithm and the performance of the system?

  Finding whether two machines are equivalent

Consider the problem of finding whether two of these machines are equivalent. Formulate this problem as the language, and illustrate that it is undecidable.

  Rbocs in mfj to retain control of yellow pages

One way to provide additional revenues for the RBOCs in the MFJ was to retain control of the Yellow Pages.

  Explain dynamic programming approach-longest weighted path

Assume we have a directed acyclic graph G = (V, E) with real-valued edge weights and two distinguished vertices s and t. Explain a dynamic programming approach for ?nding a longest weighted simple path from s to t.

  Explain specific challenges of facing designer

Explain specific challenges of facing the designer, specifically with regard to limitations of hardware, software and interface design two paragraph each.

  Corporate goal for scr new training activity

We require corporate goal for SCR which refers to new training activity. Create a draft to show Jesse. Draft project scope statement for TIMS system

  Explaining kind of malicious software

What kind of malicious software is this? if username and password are valid return ALLOW_LOGIN else return DENY_LOGIN.

  Future applications will change manufacturing industry

Prepare a response which explains the future applications which will change manufacturing industry, judiciary, and field of sports. Explain at least one application for each field.

  Determine characters in the encyclopedia

The text of the Encyclopedia Britannica is about 44 million words. For a sample of about 2000 words, the average word length was 6.1 characters per word. Approximately how many characters are there in the encyclopedia?

  Explain performance which is boost by new version of chip

Let the following hypothetical news release: "Company will unveil industry's first 5 GHz version of chip, which presents 25% performance boost over company's former speed champ. Explain the definition (or definitions) of performance.

  Which processes were loaded normally is running in safe

Next, boot the system into safe Mode and use Task Manager to list running processes. Which processes that were loaded normally are not loaded when the system is running in safe Mode?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd