View Full Version: Game design thread

Sugababes UK > General Chat > Game design thread


Title: Game design thread
Description: Questions or comments welcome


AmelleLover26m - August 23, 2009 06:19 PM (GMT)
As I am a proffesional in the industry, if any of you have ever wanted to know anything about how a game is designed, what goes into it, what any of the program means, you can ask away here - I will be happy to answer any questions you may have about it.

If any of you would like to get into it yourself, you can do it from home by learning C or C++.

This is a program I wrote in the C language to play a game of "Guess the Number" agaisnt the computer on a console application.

CODE
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
  int tries = 0,
      guess = 0,
      theNumber = ( 1 + rand() % 1000 );

  srand(( unsigned ) time( NULL ));

  printf("\tGUESS THE NUMBER\n\n"
  "I have guessed a number between 1 and 1000\n"
  "and you have to try to guess it!\n\n");

  /*game loop*/
  do {
     printf("Enter your guess: ");
     scanf("%d", &guess);
     tries++;

     if ( guess < theNumber ) {
        printf("\nTOO LOW!\n");
     }

     if ( guess > theNumber ) {
        printf("\nTOO HIGH!\n");
     }
  } while ( guess != theNumber );

  /*user has guessed it*/
  printf("\n\nYou got it! It took %d tries!\n", tries);

  return 0;
}


Just to show you what a game program looks like, well any program in a console looks like that, but obvously C++ is a bit different to C. :D

krajol - August 23, 2009 07:28 PM (GMT)
Im starting to learn C++ right now as Im going to university this year. Im gonna study computer science :D And it's the best university teaching computer sciance in my country, hihi. So I just gotta learn a lot, heh

Robert - August 23, 2009 07:37 PM (GMT)
I'm learing programming at the moment too, so it's nice to know I have Pete to turn to when I need help! :P

Wow! - August 23, 2009 07:38 PM (GMT)
Oooh! good luck Krajol. I went to one of the best art colleges in England. So my advice is to use the tutors and the factilites to the max. :)

AmelleLover26m - August 23, 2009 07:39 PM (GMT)
Aw wow thats great Krajol.

Yeah its a great language it can do many many things and its very very large too - but do not let that scare you, as you only use what you need.

It's an object orintated lanaguage - so it creates objects from a blue print from a class.

For example:

CODE
class Sugababes {
public:
  Sugababes( std::string, int );
  ~Sugababes();

private:
  std::string name;
  int age;
};

Sugababes Keisha( "", 0 );
Sugababes Heidi( "", 0 );
Amelle( "",0 );


Class Sugababes is a blue print - and objects Keisha, Heidi and Amelle
are made from them ;)

AmelleLover26m - August 25, 2009 03:48 PM (GMT)
Here is another sample.

This is what basic Enemy Artificial Intellegence looks like in games.

CODE
/***
* Example of ENEMY AI
* By Peter Watts (c) 2009
****/

void trackPlayerMovement ( Client *client, Enemy *enemy, int &rx, int &ry ) {
  /*is the player moving*/
  if ( client->station( reutrn true )) {
     status = TRUE;
  }
 
  else {
   referToPlayerEngine( client );
  }
 
  /*player is moving - so keep count of player
    button presses*/
   int playerPress = getPadTypeAndCount( ++variable );
   
   /*is the player stood behind or infront or to the side*/
   returnMaximumMoveTotal( client->ClientState );
   
   enum BESTMOVES {
    NORTH,
    SOUTH,
    EAST,
    WEST
   };

 /*enemy cannot reach player*/
 if ( enemy->isNear() == FALSE ) { return 2; }
 if ( enemy->isNearLeftRight() == FALSE ) { return 3; }
 typedef struct {
 int hit, miss;
 }
 
 nextAction( client, enemy );
}

AmelleLover26m - September 18, 2009 10:51 PM (GMT)
Example of what a ( very basic ) player class looks like:

CODE
// Example of a player class
// (c) 2009 Peter Watts


// a class is a 'blue print' for an object
// it defines its scope, abilites and features
Class Player {
public:
Player();
~Player();

private:
 usigned long health;
 string name;
 bool *deadoralive;
 signed long score;
};

// this is a constructor
// it initilizes all data members to a
// default state
Player::Player() {
  health = 100;
  name = "Millie";
  *deadoralive = false; // void pointer
  score = 0;
}

// this is a destructor
// the compiler calls this when the program terminates
// it destroys the created object
Player::~Player() {
   for (;; ) {
      if ( gameEnd == true ) {
         std::cout << "\nDestructor called...\n"
     << "Destryoing all player objects\n";
      }
}

// main
int main ( void ) {
 // now I create a player 'object'
 Player play;
 
 engine->startGame( &play );

  return EXIT_SUCCESS;
}




Hosted for free by InvisionFree