Name this game...

This is a discussion on Name this game... within the Game Programming forums, part of the General Programming Boards category; Okay, a very simple curses program here, the idea is loosely based on a faint memory I have of a ...

  1. #1
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179

    Name this game...

    Okay, a very simple curses program here, the idea is loosely based on a faint memory I have of a type-in in basic that I typed in and played some years back.

    Synopsis- your thing ('O') runs around the outside edge. When you press space it shoots one of it's bullets into the internal space. The object is to hit the 15 Xs on the inside. Eliminate the targets and get 15 more targets, 15 more bullets, and you go a little faster. If you can hit 2 with one bullet you've just saved yourself a bullet. If you beat level 10 you win the game.

    So what's would you give for setting, story, and name of this game?
    Code:
    #include <curses.h>
    #include <time.h>
    #include <stdlib.h>
    #include <ctype.h>
    
    int dirs[6] = {0, 1, 0, -1, 0, 1};
    
    void init () {
      srand (time(NULL));
      initscr ();
      raw (); nodelay(stdscr,1); noecho(); curs_set(0); nonl(); keypad(stdscr,1);
    }
    
    void play () {
      int x, y, bx, by, c, d, in, bul, lvl, buf[LINES][COLS];
    
      y = x = d = lvl = 0; bul = 10;
      do {
        bx = x; by = y;
        clear ();
        lvl++; bul += 15;
        mvprintw (LINES - 1, 37, "Round %d", lvl);
        for (y = 0; y < LINES; y++) for (x = 0; x < COLS; x++) buf[y][x] = 0;
        for (c = 0; c < 15; c++) {  /* Set up enemies. */
          do {
            y = 1 + rand () % (LINES - 3); x = 1 + rand () % (COLS - 2);
          } while (buf[y][x]);
          buf[y][x] = 1;
          mvaddch (y, x, 'X');
        }
        x = bx; y = by;
        mvaddch (y, x, 'O');
        mvprintw (LINES - 1, 0, "Bullets : %d", bul);
        mvprintw (LINES - 1, 60, "Press SPACE to fire.");
        refresh ();
        while ((bul > 0) && (c > 0)) {
          in = getch ();
          if (tolower(in) == 'q') return;
          if (in == ' ') { /* shoot a bullet */
            bul--;
            mvprintw (LINES - 1, 0, "Bullets : %d ", bul);
            bx = x; by = y;
            do {
              x += dirs[d + 1]; y += dirs[d + 2];
              if (buf[y][x]) {
                beep ();
                buf[y][x] = 0;
                c--;
              }
              else mvaddch (y, x, '.');
              refresh ();
              napms (15);
              mvaddch (y, x, ' ');
            } while  (!((x == 0) + (y == 0) + (x == COLS - 1) + (y == LINES - 2)));
            x = bx; y = by;
          }
          mvaddch (y, x, ' ');
          x += dirs[d]; y += dirs[d + 1];
          if (((x == 0) + (y == 0) + (x == COLS - 1) + (y == LINES - 2)) == 2) {
            d ++; d %= 4;
          }
          mvaddch (y, x, 'O');
          refresh ();
          napms (275 - 25 * lvl);
        } /* end of level loop. Either out of bullets or out of enemies. */
      } while ((c == 0) && (lvl < 10));
      if (c) mvprintw (10, 27, "Out of bullets. Game over.");
      else mvprintw (10, 15, "Congratulations! You have defeated every enemy!");
      refresh ();
    }
    
    int main () {
      init ();
      play ();
      nodelay(stdscr,0); getch ();
      endwin ();
      return 0;
    }
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Ow, my eyes. It burns, it burns...
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    yea, very very very very very very messy code... not only that but there are no comments. RTFM !
    -- Will you show me how to c++?

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Sounds fun. Try adding obstacles that you can't shoot through on later levels. And make the X's move. Powerups could give you a special bullet that ricochets back and forth to help with those moving targets.

    Anyway, there's not much story, so just name it something catchy, like "Blork!". :-)

  5. #5
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Quote Originally Posted by mramazing View Post
    yea, very very very very very very messy code... not only that but there are no comments. RTFM !
    How is that messy code? Uncommented, yes, but the code practically reads like a book. (Exaggerating in defense of a program that took me all of 2 hours to write.)

    Quote Originally Posted by medievalelks View Post
    Sounds fun. Try adding obstacles that you can't shoot through on later levels. And make the X's move. Powerups could give you a special bullet that ricochets back and forth to help with those moving targets.

    Anyway, there's not much story, so just name it something catchy, like "Blork!". :-)
    Ooh, good suggestions. However, as for not being a story, just means I'm leaving it open for you to write. Blork it good. Had someone say to combine Shoot with O and X to get ShOX.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  6. #6
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    If I remember correctly, the game was called Gyruss, and it had a very cool symphonic soundtrack.

  7. #7
    verbose cat
    Join Date
    Jun 2003
    Posts
    209
    Quote Originally Posted by guesst
    So what's would you give for setting, story, and name of this game?
    So you are the first on scene at a genetic lab where the creatures have escaped their cages and are making their way out of the building. Not knowing you would be facing such a task you have only limited ammunition, but you only have to hold the tide of creatures back until reinforcements arrive (which is in approximately 10 levels). You set up a perimiter and, thanks to your great physical shape, are able to run around the building and shoot at the creatures for a long time where normal people would drop dead of exhaustion...

    You could change things up a bit and include some S's or whatever to be the scientists fleeing for their lives, and so you don't want to shoot them, but the X's (monsters) will move toward the scientists since they want some revenge for all the experiments done to them, so not only are you trying to prevent the creatures from escaping the perimiter you set up, but you are also trying to rescue the fleeing scientists and you get bonus points for every scientist that makes it past your perimiter without being eaten by a monster...
    abachler: "A great programmer never stops optimizing a piece of code until it consists of nothing but preprocessor directives and comments "

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by jEssYcAt View Post
    So you are the first on scene at a genetic lab where the creatures have escaped their cages and are making their way out of the building. Not knowing you would be facing such a task you have only limited ammunition, but you only have to hold the tide of creatures back until reinforcements arrive (which is in approximately 10 levels). You set up a perimiter and, thanks to your great physical shape, are able to run around the building and shoot at the creatures for a long time where normal people would drop dead of exhaustion...

    You could change things up a bit and include some S's or whatever to be the scientists fleeing for their lives, and so you don't want to shoot them, but the X's (monsters) will move toward the scientists since they want some revenge for all the experiments done to them, so not only are you trying to prevent the creatures from escaping the perimiter you set up, but you are also trying to rescue the fleeing scientists and you get bonus points for every scientist that makes it past your perimiter without being eaten by a monster...
    Awesome. This reminds me of some of my old Odyssey II titles.

    As I grow older, I don't have time to learn the complex games of today. I like simpler games like this.
    Last edited by medievalelks; 04-30-2008 at 07:05 PM.

  9. #9
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Try it out, it's more of a one-switch Gyruss with stationary enemies. I've put it up online. You can download it here.

    Quote Originally Posted by jEssYcAt View Post
    So you are the first on scene at a genetic lab where the creatures have escaped their cages and are making their way out of the building. Not knowing you would be facing such a task you have only limited ammunition, but you only have to hold the tide of creatures back until reinforcements arrive (which is in approximately 10 levels). You set up a perimiter and, thanks to your great physical shape, are able to run around the building and shoot at the creatures for a long time where normal people would drop dead of exhaustion...

    You could change things up a bit and include some S's or whatever to be the scientists fleeing for their lives, and so you don't want to shoot them, but the X's (monsters) will move toward the scientists since they want some revenge for all the experiments done to them, so not only are you trying to prevent the creatures from escaping the perimiter you set up, but you are also trying to rescue the fleeing scientists and you get bonus points for every scientist that makes it past your perimiter without being eaten by a monster...
    Heh, I like it. Only, maybe you've programmed a wall hugging robot that you mount a gun on. (You work in an engineering/genetics lab?) As for adding enemy types or obsticles, hey, I've given you the code. That's kinda the idea behind my site.

    Okay, I've made some changes and commented the code somewhat. Does how's this strike you professionals?
    Code:
    #include <curses.h>
    #include <time.h>
    #include <stdlib.h>
    #include <ctype.h>
    
    int dirs[6] = {0, 1, 0, -1, 0, 1};
    
    void init () {
      srand (time(NULL));
      initscr ();
      raw (); nodelay(stdscr,1); noecho(); curs_set(0); nonl(); keypad(stdscr,1);
    }
    
    void play () {
      int x, y, bx, by, c, d, in, bul, lvl, buf[LINES][COLS];
    
      y = x = d = lvl = 0; bul = 10;  /* Set up variables for new game. */
      do {  /* Set up varaibles for new level */
        clear ();
        lvl++; bul += 15;
        mvprintw (LINES - 1, 37, "Round &#37;d", lvl);
        for (by = 0; by < LINES; by++) for (bx = 0; bx < COLS; bx++)
          buf[by][bx] = 0; /* clear buffer */
        for (c = 0; c < 15; c++) {  /* Set up enemies. */
          do {
            by = 1 + rand () % (LINES - 3); bx = 1 + rand () % (COLS - 2);
          } while (buf[by][bx]);
          buf[by][bx] = 1;
          mvaddch (by, bx, 'X');
        } /* c will count targets */
        /* Draw last few more things on the screen. */
        mvaddch (y, x, 'O');
        mvprintw (LINES - 1, 0, "Bullets : %d ", bul); /* space after the d */
        mvprintw (LINES - 1, 60, "Press SPACE to fire.");
        refresh ();
        while ((bul > 0) && (c > 0)) { /* The main game loop */
          in = getch ();
          if (tolower(in) == 'q') return;
          if (in == ' ') { /* shoot a bullet */
            bul--;
            mvprintw (LINES - 1, 0, "Bullets : %d ", bul); /* space after again. */
            bx = x; by = y;
            do {
              bx += dirs[d + 1]; by += dirs[d + 2]; /* move the bullet */
              if (buf[by][bx]) { /* a hit */
                beep ();
                buf[by][bx] = 0;
                c--;
              }
              mvaddch (by, bx, '.');
              refresh ();
              napms (15);
              mvaddch (by, bx, ' ');
            } while  (!((bx==0) + (by==0) + (bx==COLS - 1) + (by==LINES - 2)));
            /* above line is for edge detection. */
          }
          mvaddch (y, x, ' ');
          x += dirs[d]; y += dirs[d + 1];
          if (((x == 0) + (y == 0) + (x == COLS - 1) + (y == LINES - 2)) == 2) {
            /* if we're at a corner change direction. */
            d++; d %= 4;
          }
          mvaddch (y, x, 'O');
          refresh ();
          napms (275 - 25 * lvl);
        } /* end of level loop if out of bullets or out of enemies. */
      } while ((c == 0) && (lvl < 10));
      if (c) mvprintw (10, 27, "Out of bullets. Game over.");
      else mvprintw (10, 15, "Congratulations! You have defeated every enemy!");
      refresh ();
    }
    
    int main () {
      init ();
      play ();
      mvprintw (15, 32, "Press any key...");
      nodelay(stdscr,0); getch ();
      endwin ();
      return 0;
    }
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  10. #10
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Make the initial speed faster...it takes too long to get around.

    Also, before you get too far, consider porting it to OpenGL and going full screen. You can add graphic sprites pretty easily.

  11. #11
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,807
    The code could use some spaces in there. Also your variable names leave something to be desired.

    Such as:
    Code:
    void play()
    {
        //
        //Will be used to hold the player position
        //
        int playerX = 0;
        int playerY = 0;
    
        //
        //Will be used to hold the bullet position
        //
        int bulletX = 0;
        int bulletY = 0;
    
        //Will be used to hold the status of the game
        bool quit = false;
    
        //Will be used to hold the key entered by the user
        int userInput = '';
    
        //The main game loop, will handle all play logic
        do{
             //Grab the user entered character, in lower case to ease input handling
            userInput = toLower(getch());
            
            //Special Case: q means the user wants to quit, set quit flag to true
            if(userInput == 'q'){
                quit = true;
            }//if
    
            //Special Case: f means the user wants to fire a bullet, fire a bullet based on
            //the ships current position
            if(userInput == 'f'){
                //Fire bullet here
            }//if
        }while(!quit);
    }
    Note: This is assuming // is allowed as a comment, it would be just as simple to use /**/
    Woop?

  12. #12
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Gaah, look at all that wasted space! I see code like that coming off the printer and in a whole page I'll find a dozen functional lines of code. I have to make like a flipbook to read the darn thing.

    Can't we find a middle ground?
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

  13. #13
    Registered User
    Join Date
    Apr 2008
    Posts
    890
    Quote Originally Posted by prog-bman View Post
    The code could use some spaces in there. Also your variable names leave something to be desired.

    Such as:
    Code:
    void play()
    {
        //
        //Will be used to hold the player position
        //
        int playerX = 0;
        int playerY = 0;
    
        //
        //Will be used to hold the bullet position
        //
        int bulletX = 0;
        int bulletY = 0;
    
        //Will be used to hold the status of the game
        bool quit = false;
    
        //Will be used to hold the key entered by the user
        int userInput = '';
    
        //The main game loop, will handle all play logic
        do{
             //Grab the user entered character, in lower case to ease input handling
            userInput = toLower(getch());
            
            //Special Case: q means the user wants to quit, set quit flag to true
            if(userInput == 'q'){
                quit = true;
            }//if
    
            //Special Case: f means the user wants to fire a bullet, fire a bullet based on
            //the ships current position
            if(userInput == 'f'){
                //Fire bullet here
            }//if
        }while(!quit);
    }
    Note: This is assuming // is allowed as a comment, it would be just as simple to use /**/
    White space is good, but those comments are redundant and grating on the eyes. Tell me what the comment above "if (userInput == 'q') { quit = true; }" adds to that perfectly understandable code?

    All of those comments are unnecessary.
    Last edited by medievalelks; 05-01-2008 at 05:53 AM.

  14. #14
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    As many people have said before, comments should explain why you're doing something not what it's doing -- the code explains that.

  15. #15
    Registered User guesst's Avatar
    Join Date
    Feb 2008
    Location
    Lehi, UT
    Posts
    179
    Okay, so what about my revised comments. Spacing aside, what's yawls take on them. I have a few redundant ones, but some of them have got to be useful.
    Type-ins are back! Visit Cymon's Games at http://www.cymonsgames.com for a new game every week!

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-07-2010, 11:08 PM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21