Difference between revisions of "UNX511 - 20121 - Project - TeamA"

From CDOT Wiki
Jump to: navigation, search
(Useful Code Snippets)
(Blank)
 
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=Project Outline=
+
-
* Zork-like adventure game
 
* '''Type:''' text-based game
 
* '''Possible platform:''' Web/XHTML/HTML5, Terminal
 
* MMORPG-ish (killing, leveling, etc. involved) , but text-based game and it's all about statistics
 
** No maps!
 
 
 
=Team Members=
 
 
 
 
 
{| class="wikitable sortable" border="1" cellpadding="5"
 
|-
 
! First Name !! Last Name  !! Seneca Id !! wiki id !!  IRC nick
 
|-
 
|[[User:Nmayuranathan | Natesh]]||Mayuranathan||[mailto:nmayuranathan@learn.senecac.on.ca?subject=unx511 nmayuranathan]||[[Special:Contributions/Nmayuranathan |Nmayuranathan]]||Tesh_
 
|-
 
|[[User:Rainulf | Rainulf]]||Pineda||[mailto:???@learn.senecac.on.ca?subject=unx511 Rainulf]||[[Special:Contributions/Rainulf |Rainulf]]||_Rainulf
 
|-
 
|[[User:??? |Lucas]]|| Alba Bresso|| [mailto:ljalbabresso@learn.senecac.on.ca?subject=unx511 Lucas] ||[[Special:Contributions/Lucas |Lucas]]||N/A
 
|-
 
|[[User:aali83 |Ahmad]]||Ali|| [mailto:aali83@learn.senecac.on.ca?subject=unx511 Ahmad] || [[Special:Contributions/aali83 |Ahmad]] || N/A
 
|}
 
 
 
=Development Plan (Rough)=
 
* Project planning (Jan 11)
 
* Game interface/interaction planning (Jan 18)
 
* Game design/technical programming design (Jan 25)
 
** C++/OO design
 
** Socket OO design - accepting connections
 
** Main game design
 
** Putting the socket and the main game design together
 
 
 
=Useful Code Snippets=
 
<pre>
 
/**
 
* Runs a linux command, reallocates memory for whatever the command outputs
 
* @author Rainulf
 
* @return character pointer to the allocated memory
 
* @note needs to be free()'d after use
 
*/
 
char* runCmd(char* cmd){
 
  FILE* fp;
 
  char* out = NULL;
 
  char* more_out;
 
  char ch;
 
  int count = 0;
 
 
 
  /* Open the command for reading. */
 
  fp = popen(cmd, "r");
 
  if (fp == NULL) {
 
      printf("Failed to run command\n" );
 
      return 0;
 
  }
 
 
 
  /* Read the output a line at a time - output it. */
 
  ch = fgetc(fp);
 
  while(ch != '\n' && ch != EOF){
 
      more_out = (char*) realloc(out, ++count); // no need to free more_out
 
 
 
      if(more_out != NULL){
 
        out = more_out;
 
        out[count-1] = ch;
 
      }
 
      ch = fgetc(fp);
 
  }
 
 
 
  pclose(fp);
 
  return out;
 
}
 
 
 
/**
 
* Concatenates two strings by allocating memory for the two
 
* @author Rainulf
 
* @return concatenated string - dynamically allocated
 
* @note needs to be free()'d after use
 
*/
 
char* concat(char* a, char* b){
 
  char* tmp = malloc(snprintf(NULL, 0, "%s %s", a, b) + 1);
 
  sprintf(tmp, "%s %s", a, b);
 
  return tmp;
 
}
 
 
 
/**
 
* Gets input from STDIN character by character until '\n' or MAXLEN is reached, puts into the character pointer str
 
* @author Rainulf
 
* @return n/a
 
* @note MAXLEN have to be defined
 
*/
 
void getInput(char* str){
 
  int charCount = 0;
 
  char ch;
 
 
 
  // get input from user
 
  ch = getchar();
 
  while( (ch != '\n') && (charCount < MAXLEN) ) {
 
      str[charCount++] = ch;
 
      ch = getchar();
 
  }
 
  str[charCount] = 0;
 
}
 
</pre>
 

Latest revision as of 15:33, 25 April 2018

-