Link Bar

Home | Games | Programming | Tutorials | Donate | Legal (These are mostly empty right now. Placeholders!)

warning code

This website contains adult content.

Thursday, March 8, 2012

Day 19: A quest! And a world!

So I recoded everything from scratch in a new project called "Noob Game," rather than keep everything in "Hello World."

You start in Noob Camp and can talk to the Noob Trainer, who gives you a quest to take some Noob Shit to Noob Town.  If you keep trying to talk to the Noob Trainer, he tells you to get going.  You can then turn the Noob Shit in to the Noob Civilian, who gives you a gold piece.  Now you're on a first-name basis with the Noob Trainer!  That's some status right there!

The source code is beneath the jump, for anyone who is curious and/or wants to compile and play this pile of a game before I "officially" release it.  There are still a few bugs, like levels don't work right (also, attacking is a lie and does not work), but I have ideas of how to fix them and just wanted to put something up on the blog before midnight.

EDIT:  Uhh... finished the game?  Compiled and released before midnight.  Lots more quest, figured a couple neat new things out, posting a tutorial tomorrow.  Who knows of a nice free place to make .exe files available for download?

DOUBLE-EDIT:  Aaaaand... BAM!



CODE:
//hooray for inclusion!
#include "stdafx.h"
#include "NoobGame.h"
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


using namespace std;


//CHARACTER SHEET!


//playerActionsTaken are fundamental
int playerActionsTaken = 0;


//declare playerExperience as a function of playerActionsTaken
int playerExperience = playerActionsTaken;


//declare level as a function of playerExperience
int playerLevel = playerExperience / 10;
//doesn't work on its own, brute-forced in game.


//declare HP
int playerHealth = 12 + ((playerExperience / 10) * 4);


//we'll make playerLocation an integer variable, too.
int playerLocation=0;


//END CHARACTER SHEET!



//GAME WORLD:


//Place Names
string placeName[] = {"Noob Camp", "Noob Town", "Noob Forest", "Pro Mountain", "Wild Blue Yonder"};
//NPC Names
string npcName[] = {"Noob Trainer", "Noob Civilian", "Noob Enemy", "Pro Troll"};
//Inventory items
string itemName[] = {"Noob Shit", "Noob Loot", "Noob Sword", "Noob Armor"};
//Start with no money or items
int playerGold = 0;
bool haveNoobShit = false;
bool haveNoobLoot = false;
bool haveNoobSword = false;
bool haveNoobArmor = false;
bool noobQuestOne = false;
bool noobQuestTwo = false;
bool noobQuestThree = false;


//
//MAIN GAME FUNCTION!
//


int _tmain(int argc, _TCHAR* argv[])
{
cout<<"One Man Show"<<endl;
cout<<""<<endl;
cout<<"Welcome to Noob Game. Enter 1 to play.  Unexpected inputs will end playtime."<<endl;
char choiceOne[10];
cin.getline(choiceOne,10);
if(choiceOne[0]=='1'){
//PRAY!
cout<<"Welcome to your new game of Noob Game!"<<endl;
cout<<"What is your name, Noob?"<<endl;
char playerName[100];
cin.getline(playerName,100);
cout<<"Hello, " <<playerName <<".  Did I pronounce that right?  Lord, what a noobish name."<<endl;
cout<<endl;


//GAME LOOP!
bool playerDeath = false;
while (playerDeath != true) {


//GAME WORLD DESCRIPTION:
cout<<"You are standing at " <<placeName[playerLocation] <<"."<<endl;
cout<<placeName[playerLocation + 1] <<" looms in the distance."<<endl;
cout<<"There is a " <<npcName[playerLocation] <<" here."<<endl;
cout<<endl;


//description of player stats:
cout<<"You have " <<playerHealth <<" HP at level " << playerActionsTaken / 10 <<"."<<endl;
cout<<endl;


//description of possible player actions:
cout<<"What do you do, " <<playerName <<"?" <<endl;
if (playerLocation==0) {
cout<<"Press W to win, G to anger the gods, S to speak with the " <<npcName[playerLocation] <<" (or A to attack), T to travel to " <<placeName[playerLocation + 1] <<"." <<endl;
}
else cout<<"Press W to win, G to anger the gods, S to speak with the" <<npcName[playerLocation] <<" (or A to attack), T to travel to " <<placeName[playerLocation + 1] <<", or R to retreat to " <<placeName[playerLocation - 1] <<"." <<endl;

char playerAction[10];
cin.getline(playerAction,10);
cout<<"~*~*~*~*~*~*~*~"<<endl;


//if (condition) { doSomething(); }
//else {doSomethingElse(); (if "condition" resolves as false)
if (playerAction[0]=='w') {
cout<<"Congratulations, " <<playerName <<"!  You have won the game!"<<endl;
}
else if (playerAction[0]=='g'){
cout<<"Foolish mortal!  In your hubris, you have angered the gods!  Behold their swift and terrible vengeance!"<<endl;
cout<<"You take " <<playerHealth <<" damage."<<endl;
playerHealth= playerHealth - playerHealth;
cout<<"You now have " <<playerHealth <<" HP."<<endl;
}
else if (playerAction[0]=='t') {
if (playerLocation==3) {
cout<<"You're already at " <<placeName[playerLocation] <<".  You can't venture out into " <<placeName[playerLocation + 1] <<" just yet."<<endl;
}
else playerLocation = playerLocation + 1;
cout<<"You travel to " <<placeName[playerLocation] <<" by taking an action."<<endl;
playerActionsTaken = playerActionsTaken + 1;
cout<<"You now have " <<playerActionsTaken <<" experience points."<<endl;
}
else if (playerAction[0]=='s') {
cout<<"You speak to " <<npcName[playerLocation] <<" by taking an action."<<endl;
playerActionsTaken = playerActionsTaken + 1;
if (playerLocation==0) {
if (noobQuestOne == true) {
cout<<npcName[playerLocation] <<":  Welcome back to " <<placeName[playerLocation] <<", " <<playerName <<"!"<<endl;
}
else if (haveNoobShit == true) {
cout<<npcName[playerLocation] <<":  Get going, you noob!  Once you deliver that " <<itemName[0] <<", we'll be on a first-name basis."<<endl;
}
else {cout<<npcName[playerLocation] <<":  Welcome to " <<placeName[playerLocation] <<"!  Now take this " <<itemName[0] <<" to " <<placeName[playerLocation + 1] <<", you fuckin' noob."<<endl;
cout<<"You pick up the " <<itemName[0] <<"."<<endl;
haveNoobShit = true;
}
}
else if (playerLocation==1) {
cout<<npcName[playerLocation] <<":  Welcome to " <<placeName[playerLocation] <<"!  Do you have any " <<itemName[0] <<" for me today?"<<endl;
if (haveNoobShit == true) {
cout<<"Deliver the " <<itemName[0] <<" by entering Q to perform the quest action."<<endl;
cin.getline(playerAction,10);
if (playerAction[0]=='q') {
cout<<npcName[playerLocation] <<":  Oh, thank you!  I was waiting for some " <<itemName[0] <<" today.  Here, have a coin for your trouble."<<endl;
haveNoobShit = false;
noobQuestOne = true;
playerGold = playerGold + 1;
cout<<"You deliver the " <<itemName[0] <<" and receive 1 gold coin.  Noob."<<endl;
}
}
}
cout<<"You now have " <<playerActionsTaken <<" experience points."<<endl;
}
else if (playerAction[0]=='r') {
if (playerLocation==0) {
cout<<"Seriously?  You can't retreat from " <<placeName[playerLocation] <<".  Where would you go?  Back home to your mommy?"<<endl;
}
else playerLocation = playerLocation - 1;
cout<<"You travel back to " <<placeName[playerLocation] <<" by taking an action."<<endl;
playerActionsTaken = playerActionsTaken + 1;
cout<<"You now have " <<playerActionsTaken <<" experience points."<<endl;
}

if (playerHealth==0) {
//you die
cout<<"You have died."<<endl;
playerDeath = true;
}
}




};


//replay module:
cout<<"Playtime's over.  Enter 1 to play again, or anything else to quit."<<endl;
char replay[10];
cin.getline(replay,10);
if(replay[0]=='1'){
//pray again!
cout<<"Just kidding!  You CAN'T play again, you mook."<<endl;
}
else {
cout<<"OK, quitter."<<endl;
}


cout<<"The game is now over.  Press Enter to close."<<endl;
cin.getline(choiceOne,10);
;
//game ends
return 0;
}

No comments:

Post a Comment