speedingbullet
December 23rd, 2007, 03:49 AM
I just started my first C++ program today, not 100% from scratch, I do have a small foundation on C.
I decided to convert a simple text game that I was working on in C to a new C++ version:
cybernetic_reality.c:
/************************************************** *************************
* Copyright (C) 2007 by Richard Belken,,, *
* richard@Shade *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************** *************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include "story.cpp"
unsigned int sleep(unsigned int seconds);
using namespace std;
int choosegame ()
{
int gamechoose;
cin >> gamechoose;
if (gamechoose == 1)
{
prolouge();
}
if (gamechoose == 2)
{
cout <<"soon... man, soon.\n";
return 0;
}
if (gamechoose == 3)
{
return 0;
}
if (gamechoose == 4)
{
cout <<"CYBER REALITY: ANARCHY CHRONICLES\n";
cout <<"Made by Richard B.\n";
cout <<"The stories of cyber reality are C 2007 Richard Belken & Icepick studios\n";
cout <<"The game engine however, is free to modify & redistribute.\n";
sleep(10);
return 0;
}
}
//------------------------------------------
//--------------------------------------------------------------------------------
int main ()
{
cout << "Welcome! This is not even the foundation of this program! 0.01!\n";
sleep(4);
cout << "Welcome Friend, This is cybernetic reality: Anarchy chronicles\n";
cout <<"__________________________________________________ ____________\n";
cout <<" \n";
cout <<" 1. NEW GAME \n";
cout <<" 2. CONTINUE \n";
cout <<" 3. QUIT GAME \n";
cout <<" 4. About game \n";
choosegame ();
}
story.cpp:
/************************************************** *************************
* Copyright (C) 2007 by Richard Belken,,, *
* richard@Shade *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************** *************************/
//Filename: story.c
//This file includes the entire, effing storyline. Major spoiler warning if you havent beaten the game.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
using namespace std;
int prolouge ()
{
cout <<"_______PROLOUGE__________\n";
sleep(5);
cout <<"Our story doesnt occur too long after our present day.\n";
cout <<" \n";
sleep(5);
cout <<" In the year 2030, mankind is no better off then what it is now";
sleep(5);
cout <<" But something ground breaking happens";
sleep(5);
cout <<" One man, inspired by a 31 year old anime series";
sleep(5);
cout <<" Invents a long eries of somewhat harmless commandable robots";
sleep(5);
cout <<" These are aimed at the public, so he makes sure that everything\n";
cout <<" Goes safely.\n";
sleep(5);
cout <<" The robots are quite a big hit, as the concept is to battle other";
cout <<" robots commanded by other people, usually 2 VS 2\n";
sleep(5);
cout <<" But his greatest mistake was the fact that he left himself \n";
cout <<" Off guard.";
sleep(5);
cout <<" It was christmas eve, at the robots factory\n";
cout <<" The factory workers were finally leaving for christmas night\n";
cout <<" And this man was leaving too.\n";
sleep(5);
cout <<" But then... THEY came...";
sleep(5);
cout <<" THEY slaughtered the factory workers";
sleep(5);
cout <<" THEY slaughtered this man";
sleep(5);
cout <<" THEY took over.\n";
sleep(5);
cout <<".------. ____ ___ ______ _____ ______ ";
sleep(5);
cout <<"| .____| ' ' ' ' | || | | __ | | ___ | ";
sleep(5);
cout <<"| | ' '' ' | --.' | ___' | ._ ' ";
sleep(5);
cout <<"| |____. ' ' | ||'. | |___ | | ' ' ";
sleep(5);
cout <<"|______| |__| |____| |_____| |_| '_' ";
sleep(5);
cout <<" | _RE_ _AL_ _I_ _TY_ | ";
sleep(5);
cout <<"______________________________________________ ";
cout <<" ANARCHY CHRONICLES ";
cout <<"______________________________________________ ";
sleep(5);
cout <<"This will be coming soon!";
}
don't mind the copyright thing, its not official since I'll probably have to change the name of the game to something else.
Anyways, according to the results that Kdevelop gave me when I tried to compile this, I'm apparently connecting the choosegame() function to the prolouge() function the wrong way... how would I do this right?
I decided to convert a simple text game that I was working on in C to a new C++ version:
cybernetic_reality.c:
/************************************************** *************************
* Copyright (C) 2007 by Richard Belken,,, *
* richard@Shade *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************** *************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
#include <unistd.h>
#include "story.cpp"
unsigned int sleep(unsigned int seconds);
using namespace std;
int choosegame ()
{
int gamechoose;
cin >> gamechoose;
if (gamechoose == 1)
{
prolouge();
}
if (gamechoose == 2)
{
cout <<"soon... man, soon.\n";
return 0;
}
if (gamechoose == 3)
{
return 0;
}
if (gamechoose == 4)
{
cout <<"CYBER REALITY: ANARCHY CHRONICLES\n";
cout <<"Made by Richard B.\n";
cout <<"The stories of cyber reality are C 2007 Richard Belken & Icepick studios\n";
cout <<"The game engine however, is free to modify & redistribute.\n";
sleep(10);
return 0;
}
}
//------------------------------------------
//--------------------------------------------------------------------------------
int main ()
{
cout << "Welcome! This is not even the foundation of this program! 0.01!\n";
sleep(4);
cout << "Welcome Friend, This is cybernetic reality: Anarchy chronicles\n";
cout <<"__________________________________________________ ____________\n";
cout <<" \n";
cout <<" 1. NEW GAME \n";
cout <<" 2. CONTINUE \n";
cout <<" 3. QUIT GAME \n";
cout <<" 4. About game \n";
choosegame ();
}
story.cpp:
/************************************************** *************************
* Copyright (C) 2007 by Richard Belken,,, *
* richard@Shade *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
************************************************** *************************/
//Filename: story.c
//This file includes the entire, effing storyline. Major spoiler warning if you havent beaten the game.
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <cstdlib>
#include <unistd.h>
unsigned int sleep(unsigned int seconds);
using namespace std;
int prolouge ()
{
cout <<"_______PROLOUGE__________\n";
sleep(5);
cout <<"Our story doesnt occur too long after our present day.\n";
cout <<" \n";
sleep(5);
cout <<" In the year 2030, mankind is no better off then what it is now";
sleep(5);
cout <<" But something ground breaking happens";
sleep(5);
cout <<" One man, inspired by a 31 year old anime series";
sleep(5);
cout <<" Invents a long eries of somewhat harmless commandable robots";
sleep(5);
cout <<" These are aimed at the public, so he makes sure that everything\n";
cout <<" Goes safely.\n";
sleep(5);
cout <<" The robots are quite a big hit, as the concept is to battle other";
cout <<" robots commanded by other people, usually 2 VS 2\n";
sleep(5);
cout <<" But his greatest mistake was the fact that he left himself \n";
cout <<" Off guard.";
sleep(5);
cout <<" It was christmas eve, at the robots factory\n";
cout <<" The factory workers were finally leaving for christmas night\n";
cout <<" And this man was leaving too.\n";
sleep(5);
cout <<" But then... THEY came...";
sleep(5);
cout <<" THEY slaughtered the factory workers";
sleep(5);
cout <<" THEY slaughtered this man";
sleep(5);
cout <<" THEY took over.\n";
sleep(5);
cout <<".------. ____ ___ ______ _____ ______ ";
sleep(5);
cout <<"| .____| ' ' ' ' | || | | __ | | ___ | ";
sleep(5);
cout <<"| | ' '' ' | --.' | ___' | ._ ' ";
sleep(5);
cout <<"| |____. ' ' | ||'. | |___ | | ' ' ";
sleep(5);
cout <<"|______| |__| |____| |_____| |_| '_' ";
sleep(5);
cout <<" | _RE_ _AL_ _I_ _TY_ | ";
sleep(5);
cout <<"______________________________________________ ";
cout <<" ANARCHY CHRONICLES ";
cout <<"______________________________________________ ";
sleep(5);
cout <<"This will be coming soon!";
}
don't mind the copyright thing, its not official since I'll probably have to change the name of the game to something else.
Anyways, according to the results that Kdevelop gave me when I tried to compile this, I'm apparently connecting the choosegame() function to the prolouge() function the wrong way... how would I do this right?