Project Overview This is the first of two short course projects. Your first proj
ID: 3559336 • Letter: P
Question
Project Overview
This is the first of two short course projects. Your first project is to use C++ to develop the programming for the game Tron.
Most, if not all of us, have seen the movie Tron. If you have not see it, in the movie, you observe two bikes that race around in a digital word, leaving a trail behind them. Borrowing from the film, the object of the Tron game is to race our bike against a competitor and in doing so, create a box using our trail to trap the other player, thereby causing them to crash and be eliminated.
Due Date
Your Tron Game is due Module 06. Please submit your individual project in sections throughout the next few modules as outlined in the time line below.
Time Line
Module
Assignment
02
Introduction
03
Submit Your Game Loop
04
Submit First Tron Work in Progress
05
Submit Second Tron Work in Progress
06
Peer Review of Final Solution to Tron
Requirements
In developing your Tron game, using C++ programming, remember to use a well structured game loop and a memory map (80 x 23). Use Xs for Player 1 and *s for Player 2.
Your standard screen is 80 x 23
You need to define 4 directions 'North' 'South' 'East' West'
enum direction {'North' , 'South' , 'East' , 'West'};
switch (myDirection) {
case 'North':
Module
Assignment
02
Introduction
03
Submit Your Game Loop
04
Submit First Tron Work in Progress
05
Submit Second Tron Work in Progress
06
Peer Review of Final Solution to Tron
Explanation / Answer
//code
#include "winbgim.h"
void HumanMovement();
int nX = 320;
int nY = 240;
char cKey = 'd';
void ComputerMovement();
int nCompX = 320;
int nCompY = 360;
char cCompKey = 'r';
void Border();
int main()
{
initwindow(640,480);
Border();
do
{
HumanMovement();
ComputerMovement();
}while (cKey != 'q');
closegraph();
return 0;
}
void HumanMovement()
{
do
{
if (kbhit())
cKey = getch();
delay(20);
switch(cKey)
{
case 'a': case 'A':
if(getpixel(nX,nY) != BLACK)
outtextxy(320,240,"Game Over");
putpixel(nX,nY,WHITE);
nX--;
break;
case 'd': case 'D':
if(getpixel(nX,nY) != BLACK)
outtextxy(320,240,"Game Over");
putpixel(nX,nY,WHITE);
nX++;
break;
case 'w': case 'W':
if(getpixel(nX,nY) != BLACK)
outtextxy(320,240,"Game Over");
putpixel(nX,nY,WHITE);
nY--;
break;
case 's': case 'S':
if(getpixel(nX,nY) != BLACK)
outtextxy(320,240,"Game Over");
putpixel(nX,nY,WHITE);
nY++;
}
}while (cKey != 'q');
}
void ComputerMovement()
{
do
{
if (kbhit())
cCompKey = getch();
delay(20);
switch(cCompKey)
{
case 'l':
if(getpixel(nCompX,nCompY) != BLACK)
outtextxy(320,260,"Game Over");
putpixel(nCompX,nCompY,GREEN);
nCompX--;
break;
case 'r':
if(getpixel(nCompX,nCompY) != BLACK)
outtextxy(320,260,"Game Over");
putpixel(nCompX,nCompY,GREEN);
nCompX++;
break;
case 'u':
if(getpixel(nCompX,nCompY) != BLACK)
outtextxy(320,260,"Game Over");
putpixel(nCompX,nCompY,GREEN);
nCompY--;
break;
case 'b':
if(getpixel(nCompX,nCompY) != BLACK)
outtextxy(320,260,"Game Over");
putpixel(nCompX,nCompY,GREEN);
nCompY++;
}
}while (cCompKey != 'q');
putpixel(320,360,GREEN);
}
void Border()
{
setfillstyle(1,WHITE);
bar(0,0,640,30);
setfillstyle(1,WHITE);
bar(0,30,30,480);
setfillstyle(1,WHITE);
bar(610,0,640,480);
setfillstyle(1,WHITE);
bar(0,440,640,480);
}
//code
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.