• 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.
  • entries
    46
  • comments
    91
  • views
    64123

A Complete Graphics-less Game #3

Sign in to follow this  
Followers 0
Squared'D

727 views

More Design and the First Basic Prototype


In this journal entry, I'll talk about the prototype that I have written. Prototyping is a way to test concepts without committing to anything. Many like to use prototypes to test potential features. I think this is a good idea and I also do it. I also like to prototype code. Sometimes I do this in conjunction with UML to establish relationships and make sure the code structure makes sense. I think it's pointless to just start making the "final" production code right away unless you're working with an established framework or you're a crazy genius. Otherwise you'll end up

re-factoring

a lot.

Re-factoring

isn't always bad, but if I have to

re-factor

I rather find problems and do it earlier.



In my opinion, every prototype should have a clear and well defined purpose. The code doesn't have to be pretty and the same goes for the output, but after the prototype, I should learn something. I'm always careful about using code from a prototype. Usually the code sucks and at best should only be used as a guideline.



In this prototype, I want to quickly make a sample text-based game just so I can get a feel for what I'm about to make. I want to show 4 main things: the main menu, the world map, the battle system, and dialog. To prototype this, I'll make a simple function for each one. I'll code the real game in C++, but for this prototype at least, I'll use more of a C-style code. Why? For me, it's just easier to prototype simple console apps in C.



I'll explain some of the things I did in the code.



[color=#ff0000]

WARNING: The code you're about to read is bad. Proceed with caution

[/color]


I'll start with some forward function declarations.#include /* declare our forward definitions. */void DoMainMenu();void DoWorldMap();void DoBattleSystem();void DoDialog();bool DoTownOne(); /* true - goto next town */bool DoTownTwo(); /* false - quit world map */int main(){ DoMainMenu();}


As you can see, I'm using separate functions to handle the game states and places. In a real game some sort of a state system should be used, but remember, I'm not making a "real" game yet.

Here's the main menu code. It's very simple. Just a few loops for checking input.void DoMainMenu(){ bool finished = false; while(finished != true) { /* display the menu */ printf("\n============================================================================\n"); printf("You Got Punk'd\n\n"); printf("1) Play\n"); printf("2) Quit\n"); printf("\n"); printf("\n============================================================================\n"); /* get the user's input */ char input = _getch(); /* check for valid input */ bool valid; do { /* initialize valid for this loop */ valid = true; /* the user wants to play */ if(input == '1') { DoWorldMap(); } /* the user wants to quit */ else if(input == '2') { finished = true; } /* invalid input */ else { printf("Invalid Input\n"); } } while(valid == false); }}

The world map is also just a loop and it goes back and forth between the towns.void DoWorldMap(){ // the current town int cur_town = 0; // the return value from the town function bool town_return; printf("\nYou enter a strange new world.\n"); do { /* go to the town */ if(cur_town == 0) town_return = DoTownOne(); else town_return = DoTownTwo(); /* set to the next town */ cur_town = 1 - cur_town; } while (town_return == true);}
Here's the code for the two towns.bool DoTownOne(){ while(true) { /* display the menu */ printf("\n============================================================================\n"); printf("Welcome to Bean Town\n\n"); printf("1) Talk to a stranger. \n"); printf("2) Go to Gotham City\n"); printf("3) Quit\n"); printf("\n"); /* get the user's input */ char input = _getch(); /* check for valid input */ bool valid; do { /* initialize valid for this loop */ valid = true; /* the user wants to talk */ if(input == '1') { DoDialog(); } /* the user wants to go to the other city */ else if(input == '2') { return true; } /* the user wants to quit */ else if(input == '3') { return false; } /* invalid input */ else { printf("Invalid Input\n"); } } while(valid == false); }}bool DoTownTwo(){ while(true) { /* display the menu */ printf("\n============================================================================\n"); printf("Welcome to Gotham City\n\n"); printf("1) Fight for your life\n"); printf("2) Run to Bean Town\n"); printf("3) Quit\n"); printf("\n"); /* get the user's input */ char input = _getch(); /* check for valid input */ bool valid; do { /* initialize valid for this loop */ valid = true; /* the user wants to talk */ if(input == '1') { DoBattleSystem(); } /* the user wants to go to the other city */ else if(input == '2') { return true; } /* the user wants to quit */ else if(input == '3') { return false; } /* invalid input */ else { printf("Invalid Input\n"); } } while(valid == false); }}

I think it's very easy to see a lot of redundancy in the code. Noticing this will help me decide on a future code architecture.

And for lazy ones like me that never feel like downloading zips to look at code:void DoBattleSystem(){ int my_hp = 200; int enemy_hp = 400; char input = 0; printf("\n\nWelcome to the fight of your life.\n"); while ((my_hp > 0) && (enemy_hp > 0)) { printf("Your HP: %i\n", my_hp); printf("Enemy HP: %i\n\n", enemy_hp); printf("What will you do?\n"); printf("1) Use a gun. \n"); printf("2) Use a knife. \n"); printf("3) punch him. \n"); printf("4) Scream\n"); printf("\n============================================================================\n"); input = _getch(); if(input == '1') { printf("Stranger: You don\'t have a gun.\n"); printf("You idiot. Stop pointing at me.\n"); printf("Super Uppercut\n"); printf("You -75\n"); my_hp -= 75; } else if(input == '2') { printf("Crap. No knife.\n"); printf("Kill him with a spoon.\n"); printf("Stranger -199\n"); printf("\nYou are very powerful.\n"); enemy_hp -= 199; } else if(input == '3') { printf("Stranger: You hit like my sister.\n"); printf("You: I know your sister well.\n"); printf("Stranger: Mother #&@ Die.\n"); printf("You -150\n"); my_hp -= 150; } else if(input == '4') { printf("Stranger: What? You\'re so weak.\n"); printf("You stab the stranger with a spoon as he walks away.\n"); printf("Stranger -399\n"); printf("\nStranger: It hurts a lot.\n"); enemy_hp -= 399; } else { printf("Stranger: What are you trying to do?\n"); printf("You -15\n"); my_hp -= 15; } } if(my_hp > 0) { printf("Stranger: I'm so sorry. Take some money.\n"); } else { printf("Stranger: I'll let you live because the programmer was too lazy to program a way to end the game here.\n"); } _getch();}void DoDialog(){ bool finished = false; printf("\n============================================================================\n"); printf("Stranger: What's up?\n"); printf("1) Nothing much.\n"); printf("2) The Sky.\n"); printf("3) I don't know. I'm lost.\n"); char input = _getch(); if(input != '2') { printf("Stranger: I'll kill you!"); DoBattleSystem(); } else { printf("Stranger: Ha.Ha. Here's some money."); _getch(); }}

I'd explain the code more, but I think it's pretty self-explanatory. Even though this is a text based game, I hope readers have a working knowledge of C and C++. If you have any questions though, feel free to leave a comment. In my next entry, I'll analyze this prototype some more and I'll also introduce some things that are missing from it.

0
Sign in to follow this  
Followers 0


1 Comment


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