• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Saint Squireen

Checking my Progress in Game Programming

19 posts in this topic

Hello! Today I want to find out if I am ready to start moving along in my learning by showing you guys the coding of my 2 and a half games. Basically my "Question" is, am I ready to move on based on the style of programming in these games? Also, if not, then what kind of tips can you give me to push me in the direction of Industrial Qualified style of game programming? Thanks!

[source lang="cpp"]#include <iostream>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
using namespace std;

int number,guess=0,maximum=0,choice=0,restart=1,tries=0,gameRun=1,times=0,compare=0,go=0;

void personGuess(){
while(restart==1){
tries=0;
cout<<"\n\n\n\n\nWhat do you want the maximum number to be?\n";
cin>>maximum;
srand(time(0));
number=((rand()%maximum)+1);
cout<<"\n\nWhats your Guess?\n";
guess=-1;
while(guess!=number){
cin>>guess;
tries++;
cout<<"\n\n\n\n\n";
cout<<endl<<endl;
if(guess>number){cout<<"Too high, try again.\n";}
if(guess<number){cout<<"Too low, try again.\n";}
}
cout<<"You found the random number, "<<number<<"!!! Good job!!\n\nTries: "<<tries<<"\n\n\n\n\nWould you like to try again? 1} Yes 2} No\n\n";
restart=0;
while(restart!=1 and restart!=2){
cin>>restart;
}
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
}


void compGuess(){
restart=1;
while(restart==1){
times=1,compare=0,go=0,tries=0;
cout<<"Choose the number that your computer will have to guess.\n\n";
cin>>number;
cout<<"\n\n\n";
cout<<"\n\n\n\n\nAlso choose the number that will be the maximum number your computer can pick.\n\n";
cin>>maximum;
cout<<"\n\n\n";
srand(time(0));
guess=((rand()%maximum)+1);
cout<<guess<<endl;
tries++;
while(guess!=number){
if(guess>number){
if(times==1){
guess=guess-maximum/4;
}
if(times==2){
guess=guess-maximum/4/4;
}
if(times==3){
guess=guess-100;
}
if(times==4){
guess=guess-50;
}
if(times==5){
guess=guess-25;
}
if(times==6){
guess=guess-10;
}
if(times==7){
guess=guess-5;
}
if(times==8){
guess--;
}
compare=1;
tries++;
cout<<guess<<endl;
}
if(compare==1 and guess<number and times!=8){
times=times+1;
}
if(guess<number or go==2){
if(times==1){
guess=guess+maximum/4;
}
if(times==2){
guess=guess+maximum/4/4;
}
if(times==3){
guess=guess+100;
}
if(times==4){
guess=guess+50;
}
if(times==5){
guess=guess+25;
}
if(times==6){
guess=guess+10;
}
if(times==7){
guess=guess+5;
}
if(times==8){
guess++;
}
compare=2;
tries++;
cout<<guess<<endl;
}
if(compare==2 and guess>number and times!=8){
times=times+1;
}
}
cout<<"\n\n\n\aYour computer found your number, "<<number<<"!!! It found it in "<<tries<<" tries.\n\n\n";
cout<<"Would you like to restart? (1) for Yes and (2) for No.";
restart=0;
while(restart!=1 and restart!=2){
cin>>restart;
}
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
}
int main()
{
while(gameRun==1){
choice=0;
cout<<"Do you want to try and guess a computer generated number (1),\nor have the computer guess a number of your choice (2)?\n\n";
while(choice!=1 and choice!=2){
cin>>choice;
}
cout<<"\n\n\n\n\n";
if(choice==1){
personGuess();
}
if(choice==2){
compGuess();
}
cout<<"Do you want to repick the game type (1),\nor completely quit the game (2)?\n\n";
gameRun=0;
while(gameRun!=1 and gameRun!=2){
cin>>gameRun;
}
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
cout<<"Guessing Game script finished.\n\n";
system("pause");
}








\\\\This line is not part of the code, just me saying there is a total of 149 lines in my Guessing Game Program. :D \\\\[/source]

[source lang="cpp"]#include <iostream>
#include <cstdlib>
using namespace std;

int n=0,m=0;

int main()
{
cout << "Choose a number to run the Matrix.\n\n";
n=0;m=0;
while(n<100000 or n>999999998){
cin>>n;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
if(n<100000){cout<<"Number is too small, try again.\n\n\n";}
if(n>999999998){cout<<"Number is too big try again.";}
if(n>999999999){cout<<"Number is so big you just crashed the Matrix. Just saying.";}
}
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nMake sure to look for patterns!!! ;D";
while(m!=100000000){m++;}
while(1){cout<<n;}
cout<<"Matrix program script finished.\n\n";
system("pause");
}










\\\\This line is not part of the code, just me saying there is a total of 21 lines in my Matrix Program. :D \\\\[/source]

[source lang="cpp"]#include <iostream>
#include <cstdlib>
#include <ctime>
#include <stdio.h>
using namespace std;

int topLeft=0,topCenter=0,topRight=0,middleLeft=0,middleCenter=0,middleRight=0,bottomLeft=0,bottomCenter=0,bottomRight=0,turn=0,restart=1,playerMove=0,compMove=0,playerMoveAccept=0,compMoveAccept=0,win=0,fourCorners=0,care=0,chance=0,difficulty=0,placement=0;


void compAI(){
care=1;
srand(time(0));
chance=((rand()%10)+1);
if(chance>=difficulty){
if(middleCenter==1 and topLeft==0 and topRight==0 and bottomLeft==0 and bottomRight==0){
srand(time(0));
placement=((rand()%4)+1);
if(placement==1){topLeft=2;care=0;}
if(placement==2){topRight=2;care=0;}
if(placement==3){bottomLeft=2;care=0;}
if(placement==4){bottomRight=2;care=0;}
}

if(fourCorners==1 and care==1){
if(topLeft==0 and topRight==2 and bottomLeft==2 and bottomRight==2 and care==1){topLeft=2;care=0;}
if(topLeft==2 and topRight==0 and bottomLeft==2 and bottomRight==2 and care==1){topRight==2;care=0;}
if(topLeft==2 and topRight==2 and bottomLeft==0 and bottomRight==2 and care==1){bottomLeft=2;care=0;}
if(topLeft==2 and topRight==2 and bottomLeft==2 and bottomRight==0 and care==1){bottomRight==2;care=0;}
}
if(topLeft==2 and topRight==2 and bottomLeft==2 and bottomRight==2 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topCenter==2 and bottomCenter==2 and middleLeft==2 and middleRight==2 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topLeft==2 and topCenter==0 and topRight==2 and middleCenter==2 and bottomCenter==2 and care==1){topCenter=2;care=0;}
if(bottomLeft==2 and bottomCenter==0 and bottomRight==2 and middleCenter==2 and topCenter==2 and care==1){bottomCenter=0;care=0;}
if(topLeft==2 and middleLeft==0 and bottomLeft==2 and middleCenter==2 and middleRight==2 and care==1){middleLeft=2;care=0;}
if(topRight==2 and middleRight==0 and bottomRight==2 and middleCenter==2 and middleLeft==2 and care==1){middleRight=2;care=0;}
if(topLeft==2 and middleLeft==0 and bottomLeft==2 and care==1){middleLeft=2;care=0;}
if(topCenter==2 and middleCenter==0 and bottomCenter==2 and care==1){middleCenter=2;care=0;}
if(topRight==2 and middleRight==0 and bottomRight==2 and care==1){middleRight=2;care=0;}
if(topLeft==0 and middleLeft==2 and bottomLeft==2 and care==1){topLeft=2;care=0;}
if(topCenter==0 and middleCenter==2 and bottomCenter==2 and care==1){topCenter=2;care=0;}
if(topRight==0 and middleRight==2 and bottomRight==2 and care==1){topRight=2;care=0;}
if(topLeft==2 and middleLeft==2 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
if(topCenter==2 and middleCenter==2 and bottomCenter==0 and care==1){bottomCenter=2;care=0;}
if(topRight==2 and middleRight==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==2 and topCenter==2 and topRight==0 and care==1){topRight=2;care=0;}
if(middleLeft==2 and middleCenter==2 and middleRight==0 and care==1){middleRight=2;care=0;}
if(bottomLeft==2 and bottomCenter==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==2 and topCenter==0 and topRight==2 and care==1){topCenter=2;care=0;}
if(middleLeft==2 and middleCenter==0 and middleRight==2 and care==1){middleCenter=2;care=0;}
if(bottomLeft==2 and bottomCenter==0 and bottomRight==2 and care==1){bottomCenter=2;care=0;}
if(topLeft==0 and topCenter==2 and topRight==2 and care==1){topLeft=2;care=0;}
if(middleLeft==0 and middleCenter==2 and middleRight==2 and care==1){middleLeft=2;care=0;}
if(bottomLeft==0 and bottomCenter==2 and bottomRight==2 and care==1){bottomLeft=2;care=0;}
if(topLeft==2 and middleCenter==0 and bottomRight==2 and care==1){middleCenter=2;care=0;}
if(topLeft==0 and middleCenter==2 and bottomRight==2 and care==1){topLeft=2;care=0;}
if(topLeft==2 and middleCenter==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topRight==2 and middleCenter==0 and bottomLeft==2 and care==1){middleCenter=2;care=0;}
if(topRight==0 and middleCenter==2 and bottomLeft==2 and care==1){topRight=2;care=0;}
if(topRight==2 and middleCenter==2 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}

if(fourCorners==1 and care==1){
if(topLeft==0 and topRight==1 and bottomLeft==1 and bottomRight==1 and care==1){topLeft=2;care=0;}
if(topLeft==1 and topRight==0 and bottomLeft==1 and bottomRight==1 and care==1){topRight==2;care=0;}
if(topLeft==1 and topRight==1 and bottomLeft==0 and bottomRight==1 and care==1){bottomLeft=2;care=0;}
if(topLeft==1 and topRight==1 and bottomLeft==1 and bottomRight==0 and care==1){bottomRight==2;care=0;}
}
if(topLeft==1 and topRight==1 and bottomLeft==1 and bottomRight==1 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topCenter==1 and bottomCenter==1 and middleLeft==1 and middleRight==1 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topLeft==1 and topCenter==0 and topRight==1 and middleCenter==1 and bottomCenter==1 and care==1){topCenter=2;care=0;}
if(bottomLeft==1 and bottomCenter==0 and bottomRight==1 and middleCenter==1 and topCenter==1 and care==1){bottomCenter=0;care=0;}
if(topLeft==1 and middleLeft==0 and bottomLeft==1 and middleCenter==1 and middleRight==1 and care==1){middleLeft=2;care=0;}
if(topRight==1 and middleRight==0 and bottomRight==1 and middleCenter==1 and middleLeft==1 and care==1){middleRight=2;care=0;}
if(topLeft==1 and middleLeft==0 and bottomLeft==1 and care==1){middleLeft=2;care=0;}
if(topCenter==1 and middleCenter==0 and bottomCenter==1 and care==1){middleCenter=2;care=0;}
if(topRight==1 and middleRight==0 and bottomRight==1 and care==1){middleRight=2;care=0;}
if(topLeft==0 and middleLeft==1 and bottomLeft==1 and care==1){topLeft=2;care=0;}
if(topCenter==0 and middleCenter==1 and bottomCenter==1 and care==1){topCenter=2;care=0;}
if(topRight==0 and middleRight==1 and bottomRight==1 and care==1){topRight=2;care=0;}
if(topLeft==1 and middleLeft==1 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
if(topCenter==1 and middleCenter==1 and bottomCenter==0 and care==1){bottomCenter=2;care=0;}
if(topRight==1 and middleRight==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==1 and topCenter==1 and topRight==0 and care==1){topRight=2;care=0;}
if(middleLeft==1 and middleCenter==1 and middleRight==0 and care==1){middleRight=2;care=0;}
if(bottomLeft==1 and bottomCenter==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==1 and topCenter==0 and topRight==1 and care==1){topCenter=2;care=0;}
if(middleLeft==1 and middleCenter==0 and middleRight==1 and care==1){middleCenter=2;care=0;}
if(bottomLeft==1 and bottomCenter==0 and bottomRight==1 and care==1){bottomCenter=2;care=0;}
if(topLeft==0 and topCenter==1 and topRight==1 and care==1){topLeft=2;care=0;}
if(middleLeft==0 and middleCenter==1 and middleRight==1 and care==1){middleLeft=2;care=0;}
if(bottomLeft==0 and bottomCenter==1 and bottomRight==1 and care==1){bottomLeft=2;care=0;}
if(topLeft==1 and middleCenter==0 and bottomRight==1 and care==1){middleCenter=2;care=0;}
if(topLeft==0 and middleCenter==1 and bottomRight==1 and care==1){topLeft=2;care=0;}
if(topLeft==1 and middleCenter==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topRight==1 and middleCenter==0 and bottomLeft==1 and care==1){middleCenter=2;care=0;}
if(topRight==0 and middleCenter==1 and bottomLeft==1 and care==1){topRight=2;care=0;}
if(topRight==1 and middleCenter==1 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
}
}


void gameDisplay(){
if(topLeft==0){cout<<" ";}
if(topLeft==1){cout<<"X";}
if(topLeft==2){cout<<"O";}
cout<<"|";
if(topCenter==0){cout<<" ";}
if(topCenter==1){cout<<"X";}
if(topCenter==2){cout<<"O";}
cout<<"|";
if(topRight==0){cout<<" ";}
if(topRight==1){cout<<"X";}
if(topRight==2){cout<<"O";}
cout<<endl;
cout<<"_____"<<endl;
if(middleLeft==0){cout<<" ";}
if(middleLeft==1){cout<<"X";}
if(middleLeft==2){cout<<"O";}
cout<<"|";
if(middleCenter==0){cout<<" ";}
if(middleCenter==1){cout<<"X";}
if(middleCenter==2){cout<<"O";}
cout<<"|";
if(middleRight==0){cout<<" ";}
if(middleRight==1){cout<<"X";}
if(middleRight==2){cout<<"O";}
cout<<endl;
cout<<"_____"<<endl;
if(bottomLeft==0){cout<<" ";}
if(bottomLeft==1){cout<<"X";}
if(bottomLeft==2){cout<<"O";}
cout<<"|";
if(bottomCenter==0){cout<<" ";}
if(bottomCenter==1){cout<<"X";}
if(bottomCenter==2){cout<<"O";}
cout<<"|";
if(bottomRight==0){cout<<" ";}
if(bottomRight==1){cout<<"X";}
if(bottomRight==2){cout<<"O";}
cout<<endl<<endl<<endl<<endl<<endl;
}


void playerInput(){
playerMoveAccept=0;
while(playerMoveAccept==0){
playerMove=0;
while(playerMove!=1 and playerMove!=2 and playerMove!=3 and playerMove!=4 and playerMove!=5 and playerMove!=6 and playerMove!=7 and playerMove!=8 and playerMove!=9 and playerMove!=99){
cin>>playerMove;
if(playerMove==1 and topLeft==0){topLeft=1;playerMoveAccept=1;}
if(playerMove==1 and topLeft==1 and topLeft==2){playerMove=0;}
if(playerMove==2 and topCenter==0){topCenter=1;playerMoveAccept=1;}
if(playerMove==2 and topCenter==1 and topCenter==2){playerMove=0;}
if(playerMove==3 and topRight==0){topRight=1;playerMoveAccept=1;}
if(playerMove==3 and topRight==1 and topRight==2){playerMove=0;}
if(playerMove==4 and middleLeft==0){middleLeft=1;playerMoveAccept=1;}
if(playerMove==4 and middleLeft==1 and middleLeft==2){playerMove=0;}
if(playerMove==5 and middleCenter==0){middleCenter=1;playerMoveAccept=1;}
if(playerMove==5 and middleCenter==1 and middleCenter==2){playerMove=0;}
if(playerMove==6 and middleRight==0){middleRight=1;playerMoveAccept=1;}
if(playerMove==6 and middleRight==1 and middleRight==2){playerMove=0;}
if(playerMove==7 and bottomLeft==0){bottomLeft=1;playerMoveAccept=1;}
if(playerMove==7 and bottomLeft==1 and bottomLeft==2){playerMove=0;}
if(playerMove==8 and bottomCenter==0){bottomCenter=1;playerMoveAccept=1;}
if(playerMove==8 and bottomCenter==1 and bottomCenter==2){playerMove=0;}
if(playerMove==9 and bottomRight==0){bottomRight=1;playerMoveAccept=1;}
if(playerMove==9 and bottomRight==1 and bottomRight==2){playerMove=0;}
if(playerMove==99){cout<<"\n\nDo you want to Quit? 1} Yes 2} No\n\n";
while(playerMove!=1 and playerMove!=2){
cin>>playerMove;
}
if(playerMove==1){playerMove=99;win=8;}
if(playerMove==2){playerMove=0;cout<<"\n\n\n\n\n";gameDisplay();}
}
cout<<"\n\n\n\n\n";
}
}
}


void compInput(){
compAI();
compMoveAccept=0;
if(care==1){
while(compMoveAccept==0){
srand(time(0));
compMove=((rand()%9)+1);
if(compMove==1 and topLeft==0){topLeft=2;compMoveAccept=1;}
if(compMove==1 and topLeft==1 and topLeft==2){compMove=0;}
if(compMove==2 and topCenter==0){topCenter=2;compMoveAccept=1;}
if(compMove==2 and topCenter==1 and topCenter==2){compMove=0;}
if(compMove==3 and topRight==0){topRight=2;compMoveAccept=1;}
if(compMove==3 and topRight==1 and topRight==2){compMove=0;}
if(compMove==4 and middleLeft==0){middleLeft=2;compMoveAccept=1;}
if(compMove==4 and middleLeft==1 and middleLeft==2){compMove=0;}
if(compMove==5 and middleCenter==0){middleCenter=2;compMoveAccept=1;}
if(compMove==5 and middleCenter==1 and middleCenter==2){compMove=0;}
if(compMove==6 and middleRight==0){middleRight=2;compMoveAccept=1;}
if(compMove==6 and middleRight==1 and middleRight==2){compMove=0;}
if(compMove==7 and bottomLeft==0){bottomLeft=2;compMoveAccept=1;}
if(compMove==7 and bottomLeft==1 and bottomLeft==2){compMove=0;}
if(compMove==8 and bottomCenter==0){bottomCenter=2;compMoveAccept=1;}
if(compMove==8 and bottomCenter==1 and bottomCenter==2){compMove=0;}
if(compMove==9 and bottomRight==0){bottomRight=2;compMoveAccept=1;}
if(compMove==9 and bottomRight==1 and bottomRight==2){compMove=0;}
cout<<"\n\n\n\n\n";
}
}
}


void winCheck(){
if(topLeft==1 and topCenter==1 and topRight==1){win=1;}
if(middleLeft==1 and middleCenter==1 and middleRight==1){win=1;}
if(bottomLeft==1 and bottomCenter==1 and bottomRight==1){win=1;}
if(topLeft==1 and middleLeft==1 and bottomLeft==1){win=1;}
if(topCenter==1 and middleCenter==1 and bottomCenter==1){win=1;}
if(topRight==1 and middleRight==1 and bottomRight==1){win=1;}
if(topLeft==1 and middleCenter==1 and bottomRight==1){win=1;}
if(topRight==1 and middleCenter==1 and bottomLeft==1){win=1;}
if(topLeft==1 and bottomLeft==1 and topRight==1 and bottomRight==1 and middleCenter==1){win==5;}
if(topCenter==1 and bottomCenter==1 and middleLeft==1 and middleRight==1 and middleCenter==1){win=5;}
if(topLeft==1 and topCenter==1 and topRight==1 and middleCenter==1 and bottomCenter==1){win=5;}
if(bottomLeft==1 and bottomCenter==1 and bottomRight==1 and middleCenter==1 and topCenter==1){win=5;}
if(topLeft==1 and middleLeft==1 and bottomLeft==1 and middleCenter==1 and middleRight==1){win=5;}
if(middleLeft==1 and middleCenter==1 and middleRight==1 and topRight==1 and bottomRight==1){win=5;}
if(fourCorners==1){
if(topLeft==1 and bottomLeft==1 and topRight==1 and bottomRight==1){win=7;}
}

if(topLeft!=0 and topCenter!=0 and topRight!=0 and middleLeft!=0 and middleCenter!=0 and middleRight!=0 and bottomLeft!=0 and bottomCenter!=0 and bottomRight!=0){win==3;}

if(topLeft==2 and topCenter==2 and topRight==2){win=2;}
if(middleLeft==2 and middleCenter==2 and middleRight==2){win=2;}
if(bottomLeft==2 and bottomCenter==2 and bottomRight==2){win=2;}
if(topLeft==2 and middleLeft==2 and bottomLeft==2){win=2;}
if(topCenter==2 and middleCenter==2 and bottomCenter==2){win=2;}
if(topRight==2 and middleRight==2 and bottomRight==2){win=2;}
if(topLeft==2 and middleCenter==2 and bottomRight==2){win=2;}
if(topRight==2 and middleCenter==2 and bottomLeft==2){win=2;}
if(topLeft==2 and bottomLeft==2 and topRight==2 and bottomRight==2 and middleCenter==2){win=4;}
if(topCenter==2 and bottomCenter==2 and middleLeft==2 and middleRight==2 and middleCenter==2){win=4;}
if(topLeft==2 and topCenter==2 and topRight==2 and middleCenter==2 and bottomCenter==2){win=4;}
if(bottomLeft==2 and bottomCenter==2 and bottomRight==2 and middleCenter==2 and topCenter==2){win=4;}
if(topLeft==2 and middleLeft==2 and bottomLeft==2 and middleCenter==2 and middleRight==2){win=4;}
if(middleLeft==2 and middleCenter==2 and middleRight==2 and topRight==2 and bottomRight==2){win=4;}
if(fourCorners==1){
if(topLeft==2 and bottomLeft==2 and topRight==2 and bottomRight==2){win=6;}
}
}


int main(){
while (restart==1){
cout<<"What Difficulty do you want? 1} Easy 2} Medium 3} Hard\n\n";
difficulty=0;
while(difficulty!=1 and difficulty!=2 and difficulty!=3){
cin>>difficulty;
}
cout<<"\n\n";
if(difficulty==1){
difficulty=7;
}
if(difficulty==2){
difficulty=6;
}
if(difficulty==3){
difficulty=0;
}
cout<<"NOTE: Type 99 on your turn for an option to quit mid-game.\n\n\n\n\n";
cout<<"Do you want to play with the extra 'Four Corners' rule?\n(Press '1' for yes or '2' for no.)\n\n";
fourCorners=0;
while(fourCorners!=1 and fourCorners!=2){
cin>>fourCorners;
}
cout<<endl<<endl<<endl<<endl<<endl;
win=0;topLeft=0;topCenter=0;topRight=0;middleLeft=0;middleCenter=0;middleRight=0;bottomLeft=0;bottomCenter=0;bottomRight=0;
srand(time(0));
turn=((rand()%2)+1);
gameDisplay();
while(win==0){

while (turn==1 and win==0){
cout<<"Your turn!\n\n";
playerInput();
turn=2;
gameDisplay();
winCheck();
}

while (turn==2 and win==0){
cout<<"Computer's turn!\n\n\n\n\n";
compInput();
turn=1;
gameDisplay();
winCheck();
}

}
if(win==1){
cout<<"Hurrah!! You won against your computer!!!\n\n\n";
}

if(win==2){
cout<<"You lost against your own computer!!!\n\n\n";
}

if(win==3){
cout<<"Wow! You tied against your computer!!!!\n\n\n";
}

if(win==4){
cout<<"What the...... Your computer just owned you!!!!!! Your computer got a double win!!!!!!!!!!\n\n\n";
}

if(win==5){
cout<<"Dang! You just double beat your own computer!!! ppppsssshhh So much for Artificial Intelligence hahaha:)\n\n\n";
}

if(win==6){
cout<<"Woah!! Your computer used the Four Corners rule against you!!!\n\n\n";
}

if(win==7){
cout<<"Woah!! You used the Four Corners rule againt your computer!!!\n\n\n";
}

if(win==8){cout<<"You quit the game? Hopefully not because of a bug...;D\n\n\n";}

cout<<"Would you like to retart?\n(Press '1' for yes or '2' for no.)\n";
restart=0;
while(restart!=1 and restart!=2){cin>>restart;}
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

}
cout<<"Tic-Tac-Toe game script finished.\n\n";
system("pause");
}











\\\\This line is not part of the code, just me saying there is a total of 337 lines in my Tic-Tac-Toe Program. :D \\\\[/source]


Feel free to plug this into any compiler/debugger and check to see how it runs and plays.

P.S.~ I'm pretty sure you know which one of these games is the "Half Game":D
0

Share this post


Link to post
Share on other sites
[attachment=11019:Guessing Game Source Code.txt][attachment=11020:Matrix Source Code.txt][attachment=11021:Tic-Tac-Toe Source Code.txt]
0

Share this post


Link to post
Share on other sites
Your code is okay.

First of all, this is mostly basic C, not C++. You don't have any classes and use global variable. Learning object-oriented development would be the next logical step in your training. You do use std (cin and cout) but that's about it. Try using containers like list, map and vectors.
Your tictactoe source use a whole lot of "if" lines. I didn't analyse it, but I'm pretty sure it could be resumed to a clearer algorithm taking much less lines of code using mathematics and logic instead of handling every possible possibilities individually.
Also, I know it was not a need in these games, but you only used variables of type int. Always try to select the best type who use the less memory for the data you handle. Instead of validating maximum using a made-up value (99999999), try using constant that means something like INT_MAX available in <limits.h>

Also, what do you mean by "move on"? You always improve while programming, it never stop. If you mean learn new things, only you can answer that. Do you understand the code you wrote? If so, go ahead because it can only help learning new ways of thinking and doing that same thing in a more efficient manner. Edited by Dunge
0

Share this post


Link to post
Share on other sites
Your code is kinda bad.

Why are you seeding rand multiple times?
In the first code, you are calling srand in a loop and in the third one, you are calling srand twice.
And there is something wrong with your excessive use of if statements.
Even such heavy if statements were necessary, you should always comment the code so that you don't have to waste time figuring out what you intended in your code.
0

Share this post


Link to post
Share on other sites
Don't be so hard on him.

Saint Squireen, What is your goal?
What would you like to program? I assume games? Do you want to work in a game company?

I'm not trying to be rude but I'll give you an honest answer:
[quote]Am I ready to move on based on the style of programming in these games?[/quote]
Answer: No, you are not ready to move on with that style of programming. It is bad coding.

[quote]What kind of tips can you give me to push me in the direction of Industrial Qualified style of game programming[/quote]
The tips I can give is: Write neat. Use classes, tons of methods, etc.
Also learn the theory about everything.

In your response I want 2 answers from you:
Could you explain me, in a neat/technical sentence, how a pointer works?
Could you explain me what the difference is between a local, global, member variable? Also in in neat sentence.

These things you are supposed to know as programmer. Knowing what you are writing.

I've found this pdf yesteday, I recommend you to have a look at this:
[url="http://www.angelfire.com/art2/ebooks/teachyourselfcplusplusin21days.pdf"]http://www.angelfire...lusin21days.pdf[/url]


~EngineProgrammer
0

Share this post


Link to post
Share on other sites
The last block of code makes my eyes bleed, but let's all be honest - most of us also started like this, hardcoding every possible state with a bunch of if/then's. Then we noticed/got told that these states could be logically grouped into categories, and eventually you end up with beautiful code with only a couple conditionals per line and no more than two nested loops, all isolated in a single flexible method that you can put into a code library for easy reuse in your other projects.

However, it takes time, experience, and practice to discover, identify, and make use of these patterns, so the only advice I could give you is, pick one your more harder games, and try and rewrite it more elegantly. You'll instinctively know when you're doing it right: good code should be beautiful to read.

----------

If you would like more specific feedback, look at your "guess the number" game. First, lay off the \n's! If you really need formatting, try and group these into some form of constant. And instead of the fifteen or so newlines at the end of the PersonGuess() method, why not just erase the console screen to start over? That would make more sense in my opinion, it would be more intuitive. That's just a detail though, console formatting is always a bit of a pain using only standard output.

Secondly, your "computer AI" for this game is... defective. The (provably) fastest way for the computer to guess the number is by binary search, which can be concisely implemented in about ten lines of code. I don't C++ so I don't know the exact syntax, but the pseudocode goes like this:

1. Let Lo = 0, Hi = maxNumber. (Lo and Hi are variables)
2. Repeat forever steps 3 to 6.
... 3. Let computerGuess = (Lo + Hi) / 2
... 4. If actualGuess = computerGuess, the computer wins, break out of the loop.
... 5. If actualGuess < computerGuess, then let Hi = computerGuess - 1 and go to step 3.
... 6. If actualGuess > computerGuess, then let Lo = computerGuess, and go to step 3.

This is called binary search and the computer will guess your number in about log2(n) steps on average, where n is the maximum number he can guess. So for n = 100, it'll take the computer about 6-7 steps. For n = 1 million, it'll take it roughly 20 guesses. No need for some strange series of conditions (which, by the way, appear to be a hardcoded form of binary search...)

Unless, of course, you were trying to model a "bad AI" which made bad guesses, but even then you could've just used a variation of the binary search which wouldn't use the midpoint of Lo and Hi at each guess, but a random guess within the search interval for instance, which can end up being faster or slower (but on average the same speed). This way the computer will appear to actually "guess" instead of making mechanical choices. If that makes sense.

----------

Now, this might seem harsh, but you need to learn to code elegantly before moving on to more complex stuff, because, well, it's pretty simple why: you won't be able to get away with your current method in more complex games. You will simply have too many conditions and variables to keep track of. So, no, you are not ready to move on, you need to step back and improve your coding skills. All three games you have attached to this topic are in dire need of rewriting, and you would benefit immensely from doing just that. Though don't hesitate to create new topics if you need specific coding advice while doing this, I'm sure many people would be happy to guide you.

Also, reflect on this quote, which I find to be extremely true to programming in general:
[quote]Perfection is achieved, not when there is nothing left to add, but when there is nothing left to take away.[/quote]
1

Share this post


Link to post
Share on other sites
[quote name='EngineProgrammer' timestamp='1346467107' post='4975303']
In your response I want 2 answers from you:
Could you explain me, in a neat/technical sentence, how a pointer works?
Could you explain me what the difference is between a local, global, member variable? Also in in neat sentence.
[/quote]

I'm not him but I couldn't resist this little challenge. Always fun to see if I've listened closely enough during my school lessons.
Actually created a user here on the awesome GD.net to post this [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img]

[b]Pointer[/b]: A pointer work in the way that it gives you direct access to the memorybank/memoryspace in which a variable is stored on your computer. Meaning the chunk of memory that is reserved for this variable. Meaning if you forget to *pointer=0 before reassigned it another value you will create memory leaks as the memorybank is still "locked".

Variables:
[b]Local [/b]- Local variables are variables accessible by all functions within the class where it is created.
Example:
int main{
int a;
}
//Destroyed when the block/function/class ends

[b]Member [/b]- Member variables are only accessible within the scope where they are created meaning inside a function for instance
Example:
int main{
void randomName(){
int a;
}
}
//Destroyed when the block/function ends

[b]Global [/b]- Global variables are accessible from everywhere in your program, hence the name global.
Example:

int a;
int main(){
}
//Destroyed when the program terminates


Wow that was more than a sentence, sorry.

Of course I would appriciate it a lot if you would confirm if I have indeed been listening or need to redo my last semester ;)

You are of course welcome to PM me the answer as to not spoil it completely.

And sorry for hijacking/butting in on the post [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] Edited by LarsDC
0

Share this post


Link to post
Share on other sites
Your response to pointers is wrong in concept.
Your response to members is wrong entirely.

As for pointers, you gave basically a textbook definition of how they are used, but not really what they are. They are nothing but integers whose values can be interpreted as an address. Their sizes change between platforms but to keep things simple we should assume Windows x86 (32-bit pointers).
0x00000100 can’t be a pointer but 0x00400000 is. It is simply a value that points to valid memory. Though some values that are meant to be pointers could point to invalid memory if your program has errors.


Members are “attributes” of classes. You posted an example in which a function was declared inside another function. This is entirely illegal.
For this, you need to redo some of your learning.


L. Spiro Edited by L. Spiro
0

Share this post


Link to post
Share on other sites
Thanks for the response [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

I had a feeling a month of c++ wouldn't get it in place so it's nice to get some feedback. At least I know I need to practice some more and read a bit more also.
I did know that if you cout a pointer you'll get the memory address and not the variable value itself hence them always being integers, if that is what you meant.

Still much appreciate the response.

Regarding the member variable.

I think I kinda switched around local and member didn't I?

Local being class visible and member being function specific.

Again much appreciated! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img] Edited by LarsDC
0

Share this post


Link to post
Share on other sites
[quote name='L. Spiro' timestamp='1346593454' post='4975724']
Your response to pointers is wrong in concept.
Your response to members is wrong entirely.

As for pointers, you gave basically a textbook definition of how they are used, but not really what they are. They are nothing but integers whose values can be interpreted as an address. Their sizes change between platforms but to keep things simple we should assume Windows x86 (32-bit pointers).
0x00000100 can’t be a pointer but 0x00400000 is. It is simply a value that points to valid memory. Though some values that are meant to be pointers could point to invalid memory if your program has errors.


Members are “attributes” of classes. You posted an example in which a function was declared inside another function. This is entirely illegal.
For this, you need to redo some of your learning.


L. Spiro
[/quote]

Looks like someone was before me [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] But I don't mind at all, you've explained it 10x better than I would've done!
I was going to say: "Pointers are addresses. Nothing more nothing less. They only "point to" an object which is allocated on the heap(or on the stack, depending where/how you have allocated your object. But most likely it will be on the heap).
But indeed you need to be careful using pointers.


Assume this code:
[CODE]
int main()
{
Object* pObject1 = new Object();
Object* pObject2 = pObject1;

delete pObject1;

pObject2->ShootBlast();
}
[/CODE]
If you don't know what this code will do, too bad I won't tell it! [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
Write it in C++ and use break points to look what each step will do.
if you like this kind of thinking-work of this code, send a PM because I have tons of these thinking-codes. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

LarcDC, you bad bad boy! [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] My question wasn't meant as a challenge. [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]


~EngineProgrammer
0

Share this post


Link to post
Share on other sites
Engine Programmer,

My goal is to learn how to program, with the ultimate goal of learning how to program games. As you can see these are the very, VERY first games I have ever created and you can probly tell this too, I am practically teaching myself with the help of a book or two. Do any of you guys know the TI-84 Plus Silver Edition Graphing Calculator? I first learned how to program on that when I was getting tired of doing the Quadratic Formula over and over again. I then got interested in writing code and then into coding games and then into trying to program on the computer. I then got to the point where the books were going to slow, so I went ahead and started to implement what I had learned so far into these "Games". Putting up the source code for these games was a very good decision by me because of all of these tips I have recieved. I just wanted to say thanks so much, and if you guys have anything else you want me to know or clean up, then please put it all out here:)
Thanks again!!!,
Saint Squireen
0

Share this post


Link to post
Share on other sites
Well, if you follow the pdf I've linked to you in my first comment I'm sure you will be a much better programmer soon!

I still remember my first piece of code. I only knew what data members, bitmaps and methods were.
I wrote 1000lines of code for a simple sprite of Warcraft2-Tidens of darkness that could move around the map and plays a random sound when you select it.
And 4 months later I looked again to that code and I really wanted to laugh at myself of being so bad. But when I compared with the progress I've made I was really glad.
The pdf shows you all basics of C++ and you can learn it in 1 month.(but go over it slowly, so take 2 months)

Also I remember I've followed some tutorials on websites to program in C++:
Console Applications: [url="http://xoax.net/cpp/crs/console/index.php"]http://xoax.net/cpp/...nsole/index.php[/url]
Win32: [url="http://xoax.net/cpp/crs/win32/index.php"]http://xoax.net/cpp/...win32/index.php[/url]

And yes I sure want to tell you something more so you won't make the mistake I did. Listen and follow the advice of good programmers.
I learned Winsock(networking stuff) and I've been told to learn Raknet(better networking stuff) but didn't listened. And on the finals I didn't have a networking system in my game(wasn't really needed but I was going for the extra points). All because I 'was' stubborn. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
I'm not saying you need to listen to me, I'm far away of being a good programmer. L. spiro is a great programmer, I've looked at some of his comments and I noticed allot of details he can tell on a single topic.


~EngineProgrammer
0

Share this post


Link to post
Share on other sites
Several tips and one criticism:
1) Don't be afraid to use whitespace. It makes the code easier to read. Easier to read is better than not easy to read.
2) Don't cram multiple things onto one line 'just because'.

For example, this:
[code]int topLeft=0,topCenter=0,topRight=0,middleLeft=0,middleCenter=0,middleRight=0,bottomLeft=0,bottomCenter=0,bottomRight=0,turn=0,restart=1,playerMove=0,compMove=0,playerMoveAccept=0,compMoveAccept=0,win=0,fourCorners=0,care=0,chance=0,difficulty=0,placement=0;[/code]

Should be:
[code]int topLeft = 0, topCenter = 0, topRight = 0;
int middleLeft = 0, middleCenter = 0, middleRight = 0;
int bottomLeft = 0, bottomCenter = 0, bottomRight = 0;
int turn = 0;
int restart = 1; //What is restart? It either isn't named very descriptively, or else should be a boolean.
int playerMove = 0, compMove = 0; //Maybe these should be bools also?
int playerMoveAccept = 0, compMoveAccept = 0;
int win = 0; //Bool?
int fourCorners=0;
int care = 0; //Needs more discriptive name, and also should be a bool.
int chance = 0, difficulty = 0, placement = 0;[/code]

Use constants or enums wherever applicable. Avoid as many [url="http://en.wikipedia.org/wiki/Magic_number_(programming)#Unnamed_numerical_constants"]magic numbers[/url] as you can.

Declare any variables [i]as close to the first use[/i] as reasonable. Definitely declare them in the proper scope. Don't make them all globals. Some globals are okay though.

Learn [b]if else[/b]() and [b]else [/b]and use them where appropriate.

[hr]

You're doing good, so keep at it! All of the above is just tips to improve and get better. There's still a ways to go, but you're just starting out so that's to be expected. [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Now for the one real criticism:

What in the world is this? [img]http://public.gamedev.net//public/style_emoticons/default/angry.png[/img]
[code]if(middleCenter==1 and topLeft==0 and topRight==0 and bottomLeft==0 and bottomRight==0)
{
//...
}[/code]

'[b]and[/b]' is not a C++ keyword. If you have a macro named 'and' that is defined as '&&', get rid of it! [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]

[size=2](*tongue-in-cheek anger*)[/size] Edited by Servant of the Lord
1

Share this post


Link to post
Share on other sites
[quote name='Servant of the Lord' timestamp='1346626332' post='4975866']
'[b]and[/b]' is not a C++ keyword. If you have a macro named 'and' that is defined as '&&', get rid of it! [img]http://public.gamedev.net//public/style_emoticons/default/dry.png[/img]
[/quote]

Actually it is and it is the same as &&. However, absolutely nobody uses it to the point where I didn't even know about it after almost 10 years of C++. Maybe it's because && is easier to type or simply because it sticks out a lot better than 'and'. Basically, use && and || instead of 'and' and 'or', unless you are extremely paranoid of accidentally using & and | instead.
1

Share this post


Link to post
Share on other sites
Oh wow, I never knew that. I've [i]never[/i] seen them used in C++, and most C++ operator lists don't even mention them (but it does [url="http://en.cppreference.com/w/cpp/keyword"]here[/url]).

Because of their very uncommon use (in C++), I would still recommend getting rid of them and use the more commonly recognized symbols. Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites
I've seen "and" sparingly used in some old PHP code, but I also have never seen it being used in any recent examples. Whoever or whatever sources you've used to learn the C++ language must have some interesting but outdated approaches.

[quote]2) Don't cram multiple things onto one line 'just because'.[/quote]

Following this advice is not only to make code easier to read, but also to make it far easier to debug.

If you get a syntax error in runtime, or logical error causing a crash and the debugger points to line XX being the problem line, it's gonna be harder to know exactly what in that line made it crash if you had multiple statements going on.
0

Share this post


Link to post
Share on other sites
“and” and “or” are very rare and I have never seem them in practice, but at least they are documented.
Here is a snippet of code that may look entirely alien to most of you.

[CODE]
int iBlah<:100:>;
if ( bBleegers and bBloopers )
for ( int i = sizeof( iBlah ) / sizeof( iBlah<:0:> ); i--; ) <% iBlah<:i:> = i; %>
[/CODE]

I wrote this on paper for my coworkers today and asked, “What language is this?”.
All of them are very experienced and none of them were able to answer correctly.

It’s plain C/C++. Actually “and” is not a C keyword, but the rest of it will compile in any C compiler (assuming you have declared bBleegers and bBloopers).
Try it for yourself.

C/C++:
<% = {
%> = }
<: = [
:> = ]

C++ Only:
and = &&
or = ||


These tokens were created because 20 years ago not all keyboards had &, |, {, }, [, and ] characters. So these are all exact drop-in replacements.


Again, I have never seen any of these in actual use and there seems not to be any documentation of it anywhere.
The only reason I know about them is because I wrote a C compiler a long time ago.
The lexer grammar for ANSI C can be found here:
[url="http://www.lysator.liu.se/c/ANSI-C-grammar-l.html"]http://www.lysator.l...-grammar-l.html[/url]


All that being said, I have to honestly question how the original poster knew about “and” and especially why he or she is actually using it.
It does not appear in tutorials or books. How could a beginner possibly not know about and use &&? Any learning resource you ever find will be using only &&, so I have to ask, where on earth did you learn C++? Even if you come from a scripting background you would have had to look at some tutorial or learning source on C++ [i]somewhere[/i], and there is no chance it would have been using &&…


L. Spiro Edited by L. Spiro
0

Share this post


Link to post
Share on other sites
I'm familiar with ternary (though I don't have them memorized).

As to where he learned it, I don't think it's that hard to accidentally learn if you're coming from a different language that uses AND and OR.

For example:
[quote name='CC Ricers' timestamp='1346781248' post='4976505']
I've seen "and" sparingly used in some old PHP code, but I also have never seen it being used in any recent examples.[/quote]

When I read that I smiled to myself half-embarrassed, because over the past 30 days I've had to learn PHP for getting my game's website up and running... and I was using 'and' and 'or' the entire time. Only once CC Ricers indicated it was outdated and unused, did I realize that PHP even [i]had[/i] && and ||.

'course now I''ve switched to && and || in PHP, since that's what I'm more familiar with from C++ anyway. Plus I like that && and || are so tall and distinguishable from other letters, that they act as visual separators between variable names. (run and gun) vs (run && gun)
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0