Please help with Tron like game

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am to program a "tron like " game I am using Dev c++ here are the requirements :
a well structured game loop and a memory map (80x23) Use Xs for player one and *s for player two define 4 directions "North", "South", "East", and "West" this I think I have done effectively in the code below. However I have no idea how to set up a memory
map, and display the characters suggested. Here is the code I have so far: We are also to come up with a way for multiplayers and the code must prevent the human player backtracing and I dont have alot of time Any suggestions Would be soooo helpful Thank
You !!!

<pre>/use a well structured game loop and a memory map (80 x 23). Use Xs for Player 1 and *s for Player 2.
#include<iostream>
#include<string>
#include <vector>
#include <conio.h>

using namespace std;
struct TronBike1 {Point head, Point tail, unsigned length};// Makes the first class Tron bike1
struct TronBike2 {Point head, Point tail, unsigned length}; // makes the 2nd class Tron bike2
int main()
{
const int



int gameBoard[23][80];
cout << "Gameboard/t";
char YourDirection;

cout <<" ########## Welcome to Tron ##########/n";
cout <<" You will be using the keyboard for your directions/n";
cout <<" n- for North/t , s- South/t,e- East/t and w-West/n";
cout <<" hit any direction key to start/n";

{
while(1)
{
if(kbhit())
{
break;
}
}
}
char ch = getch();
enum YourDirection; {n , s , e , w;}; // setting up vector for directions
cin >> YourDirection;

While {(sel ==n || sel == e || sel == w||sel == s)}
switch (YourDirection) {
case n:
// make up screen addition to the north need a iter for adding to the tron bike stream
break;
case s:
break;
case e:
break;
case w:
break;}

if (YourDirection!=n||s||e||w)
cout <<" That is not an option use the n,s,e,w keys on the keyboard. Ensure Caps lock is OFF/n";


START_X = 10; // I am thinking this may set a start point for the bikes
const int
START_Y = 10;
const TronBike1::Direction
START_DIR = TronBike1::UP; // for North
const unsigned int

TronBike1 tronBike1(START_X, START_Y, START_DIR, );
TronBike1.moveHead(TronBike1::UP); // for North
TronBike1.moveHead(TronBike1::UP);
TronBike1.moveHead(TronBike1::LEFT); // For East
TronBike1.moveHead(TronBike1::UP);
TronBike1.moveHead(TronBike1::UP);
TronBike1.moveHead(TronBike1::RIGHT); // For West
TronBike1.moveHead(TronBike1::DOWN); // For South
TronBike1.moveHead(TronBike1::LEFT);
cout << "TronBike1 length: " << TronBike1.size() << "n"; // testing lenght of stream from tronbike.
cout << "Is head colliding: "; // testing collision
if (TronBike1.isHeadColliding())
{ std::cout << "Yes" << std::endl; }
else { std::cout << "No" << std::endl; }
cin.get(); //
TronBike2 tronBike2(START_X, START_Y, START_DIR, );
TronBike2.moveHead(TronBike2::UP); // for North
TronBike2moveHead(TronBike2::UP);
TronBike2.moveHead(TronBike2::LEFT); // For East
TronBike2.moveHead(TronBike2::UP);
TronBike2.moveHead(TronBike2::UP);
TronBike2.moveHead(TronBike2::RIGHT); // For West
TronBike2.moveHead(TronBike2::DOWN); // For South
TronBike2.moveHead(TronBike2::LEFT);
cout << "TronBike2 length: " << TronBike2.size() << "n"; // testing lenght of stream from tronbike.
cout << "Is head colliding: "; // testing collision
if (TronBike2.isHeadColliding())
{ std::cout << "Yes" << std::endl; }
else { std::cout << "No" << std::endl; }
cin.get();

// the code below is to check for collision
double X = 0; // code generously supplied by my classmember Jason Schmit I may take this out
double Y = 0;
int A = 0; int A2 = 0; int A3 = 0; int A4; int A5 = 0;
int B = 0; int B2 = 0; int B3 = 0;int B4 = 0;
int C = 0; int C2 = 0; int C3 = 0; int C4;int C5 = 0;
int D = 0; int D2 = 0;

A3 = (D*A);B3 = (D*B);C3 = (D*C);

A4 = (D2*A2); B4 = (D2*B2); C4 = (D2*C2);
A5 = (A3-A4); C5 = (C3-C4);

X = (C5 / A5);

Y = (((C-(A*X))/B));


system ("PAUSE");
return 0;}

[/code]

<hr class="sig bob schmidtz

View the full article
 
Back
Top