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();
}
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.
|