• 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
Ryan Atkins

Statements in while loop not working

2 posts in this topic

I figured it out. I'll never be thorough enough.


[s]I know there are probably plenty of things in this code unfinished. My current problem is that when ever I defeat the goblin in (on of the) case 1, it unravels my entire, original while(ourHero.getStr()>0) loop and goes to the game over text. I don't get it. Then when ever I go to give myself a 50/50 chance of making my health actually go to 0, it refuses to go to the game over page. Here's a video of exactly what's going on and the code.

[media]http://www.youtube.com/watch?v=kSKW5UfCgUk[/media][/s]


[code]#include <iostream>
#include <string>
#include "Character.h"
#include "weapon.h"
#include <windows.h>
#include "functions.h"
#include <cstdlib>
#include <ctime>

using namespace std;

character chooseClass();
weapon chooseWeapon1();
void startScreen();
void theGame();



int main()
{
startScreen();
cout << "Greetings, adventurer! What be thy name? \n";
string name;
cin >> name;
system("cls");
character ourHero = chooseClass();
cout << "\n\nPlease press enter to continue...";
cin.ignore();
cin.get();
system("cls");
weapon ourWeapon = chooseWeapon1();
cout << "\n\nPlease press enter to continue...";
cin.ignore();
cin.get();
system("cls");

while(ourHero.getHealth()>0)
{
cout << "Please make a selection:\n\n[1]The Armory\n\n[2]The Pit\n\n[3]Item Shop\n\n[4]Stats\n\n[5]Quit Game\n";
int menuSelect;
srand(time(0));
cin >> menuSelect;
system("cls");
switch(menuSelect)
{
case 1:
{
system("cls");
cout << "Welcome to The Frorth City Armory\n\n";
Sleep(1500);
cout << "What would you like to do?\n\n[1]Upgrade Main-hand Weapon\n\n[2]Upgrade Off-hand Weapon\n\n[3]Exit\n";
int choice;
cin >> choice;
system("cls");
switch(choice)
{
case 1:
{
ourWeapon.sharpenWeapon1();
cout << "Main-hand sharpened!";
cin.ignore();
cin.get();
system("cls");
break;
}
case 2:
{
if(ourWeapon.getDamageMultiplier2()>0)
{
ourWeapon.sharpenWeapon2();
cout << "Off-hand sharpened!";
cin.ignore();
cin.get();
system("cls");
break;
}
else
{
cout << "No off-hand weapon to upgrade.";
cin.ignore();
cin.get();
system("cls");
break;
}
}
case 3:
{

break;
}
default:
{
cout << "Invalid selection.\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
}
}
break;
}
case 2:
{
cout << "YOU HAVE ENTERED THE PIT\n\nChoose your opponent:\n\n[1] Goblin\n\n[2] Kobold\n\n[3] Ork \n\n[4] Pit Fighter\n";
int thePitChoice;
int combatChoice;
int theHit;
int currentHealth;
character goblin("goblin", 20, 7, 11, 0, 0);
cin >> thePitChoice;
system("cls");
if(ourHero.getLevel() < 2)
switch(thePitChoice)
{
case 1:
{
cout << "A goblin enters The Pit.\n";

while(goblin.getHealth()>0)
{
cout << "Which action would you like to take?\n\n[1]Attack\n\n[2]Beg for mercy\n";
cin >> combatChoice;
system("cls");
switch(combatChoice)
{
case 1:
{
if((ourHero.getStr()+(rand()%11))>(goblin.getDex()+(rand()%11)))
{
theHit=ourHero.getStr()*(ourWeapon.getDamageMultiplier1()+ourWeapon.getDamageMultiplier2());
cout << "You have hit the goblin for " << theHit <<"!\n\n";
currentHealth=goblin.getHealth()-theHit;
goblin.setHealth(currentHealth);
if(0 < goblin.getHealth())
cout << "This message doesn't show up";
cout << "You have slain a goblin!\n\nPlease press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
ourHero.setHealth(0);
break;
}
else
{
cout << "The goblin has dodged your swing!";
}
if((goblin.getStr()+(rand()%11))>(ourHero.getDex()+(rand()%11)))
{
theHit=goblin.getStr()*1.5;
}
else
{
cout << "You have dodged the goblin's attack!";
}
Sleep(2500);
system("cls");
break;
}
case 2:
{
if((rand()%3) < 2)
{
cout << "For some odd reason, the goblin allows you to keep your life.";
}
else
{
cout << "Poor decision. The goblin executes you!";
Sleep(3000);
system("cls");
ourHero.setHealth(0);
}
break;
}
default:
{
cout << "Invalid selection.\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
}

}
}
break;
}
case 2:
{
cout << "A kobold enters The Pit.\n";
break;
}
case 3:
{
cout << "An ork enters The Pit.\n";
break;
}
case 4:
{
cout << "You hear a gate from beyond creak open, from within emerging a tall, slim \nfigure.\n\n";
Sleep(2450);
cout << "As the figure enters in the mild, torch light you hear a whisper...\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
cout << "\"PSSSssst! Over hear!\"\n\nYou lean forward and see two beady eyes staring back at you.\n\n";
Sleep(4000);
cout << "\"I can help you defeat your enemy... just do what I say.\"\n\nYou are unsure if you trust this " <<
"voice as you ready yourself for battle.\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
break;
}
default:
{
cout << "Invalid selection.\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
}
}
break;
}
case 3:
{
cout << "Out to lunch";
cin.ignore();
cin.get();
system("cls");
break;
}
case 4:
{
cout << "Here are the stats for our " << ourHero.getClass() << ", " <<
name << "." << endl <<endl;
cout << "Health: " << ourHero.getHealth() << endl << "Strength: " << ourHero.getStr() <<
endl << "Dexterity: " << ourHero.getDex() << endl << endl;
cout << "Weapon stats for " << ourWeapon.getWeaponName() << "." << endl << endl;
cout << "Main-hand Damage: " << ourWeapon.getDamageMultiplier1() << endl <<
"Off-hand Damage: " << ourWeapon.getDamageMultiplier2();
cin.ignore();
cin.get();
system("cls");
break;
}
case 5:
{
cout << "Are you sure you wish to exit Sabra?\n[Y]es?";
cin.ignore();
cin.get();
break;
}
default:
{
cout << "Invalid selection.\n\n";
cout << "Please press enter to continue...\n";
cin.ignore();
cin.get();
system("cls");
}
}
}
if (ourHero.getHealth()<1)
cout << "Game Over!\n";
cin.get();

return 0;
}
[/code]
0

Share this post


Link to post
Share on other sites
You should learn some debugging skills: http://www.gamedev.net/page/resources/_/technical/general-programming/introduction-to-debugging-r2322
0

Share this post


Link to post
Share on other sites
Thanks for the advice. I really needed to stop having my hand held. I went back, checked everything, and, minus balancing stuff, finished most of the game. Thanks for the help. Hopefully you'll see less post from me.

[url="http://youtu.be/kAinjXWL51g"]http://youtu.be/kAinjXWL51g[/url]
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