Page 1 of 2

My first sucessfull c++ game!

Posted: Thu Mar 04, 2010 8:26 pm
by mv2112
I can't help but to post this :lol: . This is the first actual game i have ever made, and its entirely MY code :shock2: ! I made a TicTacToe clone. I used the code from my previous post, mvGLIB.h from the multidimensional array post, to create the game grid and i made some functions in another header file that have to do with win checking and stuff like that.
Here is main.cpp:

Code: Select all


#include "ttt.h" //includes mvGLIB.h and all other libs

int main(){
	set_title("Tic Tac Toe");
	cout<<"This is the first ever real game created by MV2112"<<endl;
	cout<<"All source Copyrighted MV2112 2010"<<endl<<endl;
	pause();
	cout<<endl<<"Naaaaa, just kidding, its open source :)"<<endl<<endl;
	pause();
	while(1==1){

	screen bord; //initialize screen
	bord.setup(5,5); //setup grid
	screen* pbord; //create pointer for editing grid
	pbord=&bord; //link pointer to grid
	bord.set_color(1);

	char test; //return value for win function
	char input; //used for game input

	bool wincon=FALSE; //win condition boolean
	bool c; //return value for check function
	bool tcheck=FALSE; //TIE CHECK

	int chc; //return value for insert function

	char ch; //character char
	char play; //play again var

//setting up chars for game table
	bord.point(0,0,'1');
	bord.point(1,0,'|');
	bord.point(2,0,'2');
	bord.point(3,0,'|');
	bord.point(4,0,'3');
	bord.point(0,1,'-');
	bord.point(1,1,'|');
	bord.point(2,1,'-');
	bord.point(3,1,'|');
	bord.point(4,1,'-');
	bord.point(0,2,'4');
	bord.point(1,2,'|');
	bord.point(2,2,'5');
	bord.point(3,2,'|');
	bord.point(4,2,'6');
	bord.point(0,3,'-');
	bord.point(1,3,'|');
	bord.point(2,3,'-');
	bord.point(3,3,'|');
	bord.point(4,3,'-');
	bord.point(0,4,'7');
	bord.point(1,4,'|');
	bord.point(2,4,'8');
	bord.point(3,4,'|');
	bord.point(4,4,'9');

	ch='X'; //player X goes first

//game loop starts here
	while(wincon==FALSE){

	tcheck=tiecheck(pbord);

	if(tcheck==TRUE){
		ch='t';
		break;
	}

	bord.disp();
	cout<<endl<<"Player "<<ch<<": ";
	cin>>input;
		switch(input){
		case '1':
			c=check(0,0,pbord);
			chc=insert(c,0,0,pbord,ch);
			if(chc==1){
				continue;
			}
			break;
		case '2':

			c=check(2,0,pbord);
			chc=insert(c,2,0,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '3':

			c=check(4,0,pbord);
			chc=insert(c,4,0,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '4':

			c=check(0,2,pbord);
			chc=insert(c,0,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '5':

			c=check(2,2,pbord);
			chc=insert(c,2,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '6':

			c=check(4,2,pbord);
			chc=insert(c,4,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '7':

			c=check(0,4,pbord);
			chc=insert(c,0,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '8':

			c=check(2,4,pbord);
			chc=insert(c,2,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '9':

			c=check(4,4,pbord);
			chc=insert(c,4,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
	}

	test=win(pbord);
	if(test=='X'||test=='O'){
		wincon=TRUE;
		break;
	}

	if(ch=='X'){
		ch='O';
	}
	else{
		ch='X';
	}
//game loop ends here
	}
	bord.disp();
	if(ch=='t'){
		cout<<"Nobody wins, it was a tie..."<<endl;
			cout<<endl<<"Play again? Y or N"<<endl;
	cin>>play;
	strlwr(&play);
	if(play=='y'){
		continue;
	}

	if(play=='n'){
		return 0;
	}
	}
	cout<<endl<<"Congratulations!"<<endl<<"Player "<<ch<<" Won!!!"<<endl;
	cout<<endl<<"Play again? Y or N"<<endl;
	cin>>play;
	strlwr(&play);
	if(play=='y'){
		continue;
	}

	if(play=='n'){
		return 0;
	}
	}
}

mvGLIB.h:

Code: Select all

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <time.h>
#include <windows.h>
#include <conio.h>
#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

void MVcls(){
	system("cls");
}

class object{
	//object base class
public:
	void set_char(char character);
	char r_char();
	vector<vector<char>> grid; // grid
	vector<vector<char*>> pgrid; // pointer to grid
	void set_frate(int t);
	void frate();
	void set_color(int num);

protected:
	int x;
	int y;
	int ox;
	int oy;
	char ch;
	int time;
};

void object::set_char(char character){
	ch=character;
}

char object::r_char(){
	return ch;
}

void object::set_frate(int t){
	time=t;
}

void object::frate(){
	Sleep(time);
}

void object::set_color(int num){
	switch(num){
		case 1:
			system("color a");
			break;
		case 2:
			system("color b");
			break;
		case 3:
			system("color c");
			break;
	}
}

class screen:public object{
public:
	void setup(int,int);
	void rend(vector<vector<char*>>pgrid);
	void disp();
	void point(int x, int y, char a);
	int r_x();
	int r_y();
private:
	int xx;
	int yy;
};

void screen::rend(vector<vector<char*>>pgrid){
	*pgrid[oy][ox]=' '; //this function is useless right now
	*pgrid[y][x]=ch;
}

void screen::setup(int x, int y){
	xx=x;
	yy=y;
	grid.resize(y);
	pgrid.resize(y);
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			grid[j].resize(x);
			grid[j][i]=ch;
			pgrid[j].resize(x);
			pgrid[j][i]=&grid[j][i];
		}
	}
}

void screen::disp(){
	MVcls();
	for(int i=0;i<yy;i++){
		for(int j=0;j<xx;j++){
			cout<<grid[i][j];
		}
		cout<<endl;
	}
}

void screen::point(int x, int y, char a){
	*pgrid[y][x]=a;
}

int screen::r_x(){
	return xx;
}

int screen::r_y(){
	return yy;
}

void set_title(string title){
	string t;
	t="title "+title;
	system(t.c_str());
}
void pause(){
system("pause");
}
ttt.h (tictactoe):

Code: Select all

#include "mvGLIB.h"

char win(screen* pbord){
	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[2][0]=='X'&&(*pbord).grid[4][0]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][2]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][2]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][4]=='X'&&(*pbord).grid[2][4]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[0][2]=='X'&&(*pbord).grid[0][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[2][0]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[2][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[4][0]=='X'&&(*pbord).grid[4][2]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][4]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][0]=='X'){
		return 'X';
	}
	// O
	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[2][0]=='O'&&(*pbord).grid[4][0]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][2]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][2]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][4]=='O'&&(*pbord).grid[2][4]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[0][2]=='O'&&(*pbord).grid[0][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[2][0]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[2][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[4][0]=='O'&&(*pbord).grid[4][2]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][4]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][0]=='O'){
		return 'O';
	}

	else{
		return '0';
	}
}

bool check(int x, int y,screen * pbord){
	if((*pbord).grid[y][x]=='X'||(*pbord).grid[y][x]=='O'){
		return FALSE;
	}
	else{
		return TRUE;
	}
}

int insert(bool c,int x, int y, screen * pbord, char ch){
	if(c==TRUE){
		(*pbord).grid[y][x]=ch;
		return 0;
	}
	else{
		return 1;
	}
}

bool tiecheck(screen * pbord){
	if(((*pbord).grid[0][0]=='X'||(*pbord).grid[0][0]=='O')&&((*pbord).grid[0][2]=='X'||(*pbord).grid[0][2]=='O')&&((*pbord).grid[0][4]=='X'||(*pbord).grid[0][4]=='O')&&((*pbord).grid[0][0]=='X'||(*pbord).grid[0][0]=='O')&&((*pbord).grid[0][2]=='X'||(*pbord).grid[0][2]=='O')&&((*pbord).grid[0][4]=='X'||(*pbord).grid[0][4]=='O')&&((*pbord).grid[2][0]=='X'||(*pbord).grid[2][0]=='O'&&(*pbord).grid[2][2]=='X'||(*pbord).grid[2][2]=='O')&&((*pbord).grid[2][4]=='X'||(*pbord).grid[2][4]=='O')&&((*pbord).grid[4][0]=='X'||(*pbord).grid[4][0]=='O')&&((*pbord).grid[4][2]=='X'||(*pbord).grid[4][2]=='O')&&((*pbord).grid[4][4]=='X'||(*pbord).grid[4][4]=='O')){
	return TRUE;
	}
	else{
		return FALSE;
	}
}
What do you guys think of my code?
Any suggestions?
So, what game should i try to re-create next?

EDIT:
Oops, posted too early, forgot to write code for what happens when there is a tie :oops:
EDIT:
Ok, the last function on the ttt.h file with the EXTREMELY long if statement checks for ties. That if statement makes me hate parenthesis! :x

Re: My first sucessfull c++ game!

Posted: Thu Mar 04, 2010 8:49 pm
by TheBuzzSaw
Good work. Now port it to Linux.

Re: My first sucessfull c++ game!

Posted: Thu Mar 04, 2010 8:51 pm
by GroundUpEngine
Well Done man! This is great for a first game ;)

Your code is pretty tight, but here's some suggestions ->
. use cin.get(); instead of system("pause");
. try to use more indentation & spaces in your code, so it's more neat and readable
. if it's purely c++ 'false' instead of 'FALSE' is fine to use, and some compilers highlight it as a keyword :P
TheBuzzSaw wrote:Good work. Now port it to Linux.
:lol: too right!

Re: My first sucessfull c++ game!

Posted: Thu Mar 04, 2010 9:26 pm
by mv2112
TheBuzzSaw wrote:Good work. Now port it to Linux.
Lol i could try to do that.
Will any of these includes not work on linux?

Code: Select all

#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <time.h>
#include <conio.h>
#include <vector>
#include <algorithm>
#include <cstdlib>
Writing this has made me develop a greater respect for what Falco and the ES team are doing. Writing a simple TicTacToe clone for me was hard, i cant even imagine doing what they are doing. LOL

Re: My first sucessfull c++ game!

Posted: Thu Mar 04, 2010 10:09 pm
by dephbokks
conio won't.

There are some possible substitutions though. In the future you may want to look into a more cross platform solution. But, basically I think there is always a better solution than conio. That is old school.

Congrats tho on your game.

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 1:16 pm
by lotios611
You may want to move away from using system() anything once you get the basics. See more here: Why system() is evil (Note: This may be hard for you to understand)

Edit: Good work so far!

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 6:03 pm
by mv2112
I have almost successfully made it work on linux, my problem is that i need a linux version of strlwr();
Any know a strlwr() for linux?

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 6:14 pm
by GroundUpEngine
mv2112 wrote:I have almost successfully made it work on linux, my problem is that i need a linux version of strlwr();
Any know a strlwr() for linux?
ops :lol:

Edit:

Code: Select all

if(play == 'y' || play == 'Y'){
      continue;
}

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 6:21 pm
by mv2112
GroundUpEngine wrote:
mv2112 wrote:I have almost successfully made it work on linux, my problem is that i need a linux version of strlwr();
Any know a strlwr() for linux?
Just use this -> ;)

Code: Select all

if(play == 'y' | 'Y'){
      continue;
}
Works on linux now!

main.cpp:

Code: Select all

#include "ttt.h" //includes mvGLIB.h and all other libs

int main(){
	cout<<"This is the first ever real game created by MV2112"<<endl;
	cout<<"All source Copyrighted MV2112 2010"<<endl<<endl;
	MVpause();

	cout<<endl<<"Naaaaa, just kidding, its open source :)"<<endl<<endl;
	MVpause();
	while(1==1){

	screen bord; //initialize screen
	bord.setup(5,5); //setup grid
	screen* pbord; //create pointer for editing grid
	pbord=&bord; //link pointer to grid

	char test; //return value for win function
	char input; //used for game input

	bool wincon=false; //win condition boolean
	bool c; //return value for check function
	bool tcheck=false; //TIE CHECK

	int chc; //return value for insert function

	char ch; //character char
	char play; //play again var

//setting up chars for game table
	bord.point(0,0,'1');
	bord.point(1,0,'|');
	bord.point(2,0,'2');
	bord.point(3,0,'|');
	bord.point(4,0,'3');
	bord.point(0,1,'-');
	bord.point(1,1,'|');
	bord.point(2,1,'-');
	bord.point(3,1,'|');
	bord.point(4,1,'-');
	bord.point(0,2,'4');
	bord.point(1,2,'|');
	bord.point(2,2,'5');
	bord.point(3,2,'|');
	bord.point(4,2,'6');
	bord.point(0,3,'-');
	bord.point(1,3,'|');
	bord.point(2,3,'-');
	bord.point(3,3,'|');
	bord.point(4,3,'-');
	bord.point(0,4,'7');
	bord.point(1,4,'|');
	bord.point(2,4,'8');
	bord.point(3,4,'|');
	bord.point(4,4,'9');

	ch='X'; //player X goes first

//game loop starts here
	while(wincon==false){

	tcheck=tiecheck(pbord);

	if(tcheck==true){
		ch='t';
		break;
	}

	bord.disp();
	cout<<endl<<"Player "<<ch<<": ";
	cin>>input;
		switch(input){
		case '1':
			c=check(0,0,pbord);
			chc=insert(c,0,0,pbord,ch);
			if(chc==1){
				continue;
			}
			break;
		case '2':

			c=check(2,0,pbord);
			chc=insert(c,2,0,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '3':

			c=check(4,0,pbord);
			chc=insert(c,4,0,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '4':

			c=check(0,2,pbord);
			chc=insert(c,0,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '5':

			c=check(2,2,pbord);
			chc=insert(c,2,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '6':

			c=check(4,2,pbord);
			chc=insert(c,4,2,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '7':

			c=check(0,4,pbord);
			chc=insert(c,0,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '8':

			c=check(2,4,pbord);
			chc=insert(c,2,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		case '9':

			c=check(4,4,pbord);
			chc=insert(c,4,4,pbord,ch);
			if(chc==1){
				continue;
			}

			break;
		default:
			continue;
			break;
	}

	test=win(pbord);
	if(test=='X'||test=='O'){
		wincon=true;
		break;
	}

	if(ch=='X'){
		ch='O';
	}
	else{
		ch='X';
	}
//game loop ends here
	}
	bord.disp();
	if(ch=='t'){
		cout<<"Nobody wins, it was a tie..."<<endl;
			cout<<endl<<"Play again? Y or N"<<endl;
	cin>>play;

	if(play=='y'||play=='Y'){
		continue;
	}

	if(play=='n'||play=='N'){
		break;
	}
	}
	cout<<endl<<"Congratulations!"<<endl<<"Player "<<ch<<" Won!!!"<<endl;
	cout<<endl<<"Play again? Y or N"<<endl;
	cin>>play;

	if(play=='y'||play=='Y'){
		continue;
	}

	if(play=='n'||play=='N'){
		break;
	}
	}
}



ttt.h:

Code: Select all


#include "mvGLIB.h"

char win(screen* pbord){
	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[2][0]=='X'&&(*pbord).grid[4][0]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][2]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][2]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][4]=='X'&&(*pbord).grid[2][4]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[0][2]=='X'&&(*pbord).grid[0][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[2][0]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[2][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[4][0]=='X'&&(*pbord).grid[4][2]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][0]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][4]=='X'){
		return 'X';
	}

	if((*pbord).grid[0][4]=='X'&&(*pbord).grid[2][2]=='X'&&(*pbord).grid[4][0]=='X'){
		return 'X';
	}
	// O
	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[2][0]=='O'&&(*pbord).grid[4][0]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][2]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][2]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][4]=='O'&&(*pbord).grid[2][4]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[0][2]=='O'&&(*pbord).grid[0][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[2][0]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[2][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[4][0]=='O'&&(*pbord).grid[4][2]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][0]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][4]=='O'){
		return 'O';
	}

	if((*pbord).grid[0][4]=='O'&&(*pbord).grid[2][2]=='O'&&(*pbord).grid[4][0]=='O'){
		return 'O';
	}

	else{
		return '0';
	}
}

bool check(int x, int y,screen * pbord){
	if((*pbord).grid[y][x]=='X'||(*pbord).grid[y][x]=='O'){
		return false;
	}
	else{
		return true;
	}
}

int insert(bool c,int x, int y, screen * pbord, char ch){
	if(c==true){
		(*pbord).grid[y][x]=ch;
		return 0;
	}
	else{
		return 1;
	}
}

bool tiecheck(screen * pbord){
	if(((*pbord).grid[0][0]=='X'||(*pbord).grid[0][0]=='O')&&((*pbord).grid[0][2]=='X'||(*pbord).grid[0][2]=='O')&&((*pbord).grid[0][4]=='X'||(*pbord).grid[0][4]=='O')&&((*pbord).grid[0][0]=='X'||(*pbord).grid[0][0]=='O')&&((*pbord).grid[0][2]=='X'||(*pbord).grid[0][2]=='O')&&((*pbord).grid[0][4]=='X'||(*pbord).grid[0][4]=='O')&&((*pbord).grid[2][0]=='X'||(*pbord).grid[2][0]=='O'&&(*pbord).grid[2][2]=='X'||(*pbord).grid[2][2]=='O')&&((*pbord).grid[2][4]=='X'||(*pbord).grid[2][4]=='O')&&((*pbord).grid[4][0]=='X'||(*pbord).grid[4][0]=='O')&&((*pbord).grid[4][2]=='X'||(*pbord).grid[4][2]=='O')&&((*pbord).grid[4][4]=='X'||(*pbord).grid[4][4]=='O')){
	return true;
	}
	else{
		return false;
	}
}


mvGLIB.h:

Code: Select all


#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
#include <time.h>

#ifdef WIN32
#include <windows.h>
#endif

#include <vector>
#include <algorithm>
#include <cstdlib>

using namespace std;

void MVcls(){
#ifdef WIN32
	system("cls");
#else
	system("clear");
#endif
}

class object{
	//object base class
public:
	void set_char(char character);
	char r_char();
	vector<vector<char> > grid; // grid
	vector<vector<char*> > pgrid; // pointer to grid
	void set_frate(int t);
	void frate();
	void set_color(int num);

protected:
	int x;
	int y;
	int ox;
	int oy;
	char ch;
	clock_t time;
};

void object::set_char(char character){
	ch=character;
}

char object::r_char(){
	return ch;
}

void object::set_frate(int t){
	time=t;
}

void object::frate(){
	clock_t timer=time+clock();
	while(timer>clock()){
	}
}

class screen:public object{
public:
	void setup(int,int);
	void rend(vector<vector<char*> >pgrid);
	void disp();
	void point(int x, int y, char a);
	int r_x();
	int r_y();
	int xx;
	int yy;
};

void screen::rend(vector<vector<char*> >pgrid){
	*pgrid[oy][ox]=' '; //this function is useless right now
	*pgrid[y][x]=ch;
}

void screen::setup(int x, int y){
	xx=x;
	yy=y;
	grid.resize(y);
	pgrid.resize(y);
	for(int i=0;i<x;i++){
		for(int j=0;j<y;j++){
			grid[j].resize(x);
			grid[j][i]=ch;
			pgrid[j].resize(x);
			pgrid[j][i]=&grid[j][i];
		}
	}
}

void screen::disp(){
	MVcls();
	for(int i=0;i<yy;i++){
		for(int j=0;j<xx;j++){
			cout<<grid[i][j];
		}
		cout<<endl;
	}
}

void screen::point(int x, int y, char a){
	*pgrid[y][x]=a;
}

int screen::r_x(){
	return xx;
}

int screen::r_y(){
	return yy;
}

void MVpause(){
	cout<<"Press Enter to Continue...";
cin.get();
}



Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 6:35 pm
by CC Ricers
Boy, that was quick :P

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 6:39 pm
by mv2112
CC Ricers wrote:Boy, that was quick :P
I had to take out a function that colored text to make it work completely :cry:
Now its always the default console color.

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 7:11 pm
by K-Bal
What's with all this hate against system("") :cry: Don't you want to call your OS from time to time? ;)

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 7:32 pm
by mv2112
K-Bal wrote:What's with all this hate against system("") :cry: Don't you want to call your OS from time to time? ;)
Its a pain in the ass when some people *cough* TheBuzzSaw *cough* want you program to work multiplatform, Windows AND Linux.

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 8:17 pm
by K-Bal
And where is the Mac version? :lol: Keeping code platform independent is a good habit. ;)

Re: My first sucessfull c++ game!

Posted: Fri Mar 05, 2010 8:30 pm
by mv2112
K-Bal wrote:And where is the Mac version? :lol: Keeping code platform independent is a good habit. ;)
Lol, i dont have a mac on which i can test my code. I guess ill have to develop for windows and linux instead :roll:
:lol: