I don't want to use my previous engine. it was this:
I want to be able to pick up and item when crossed, then use it or drop it later on.Code:int sword = 0;
if (sword == o)
this
else if (sword == 1)
that
How would i do that?
Printable View
I don't want to use my previous engine. it was this:
I want to be able to pick up and item when crossed, then use it or drop it later on.Code:int sword = 0;
if (sword == o)
this
else if (sword == 1)
that
How would i do that?
thats kind of vague, please elaborate.
you mean if u "step" on it?
well if thats what u meant, when i first started programming i had a text game, heres how i did it for picking up the amulet:
If you want to see all of the code just ask i'll post it as an attachment.Code:/***************************************************************
****************************************************************
Code for Amulet
****************************************************************
***************************************************************/
if (User_Location_X == 0 && User_Location_Y == 5)
{
if (Amulet == 1)
{
cout <<"You have returned to where you found Soris's Amulet.\n\n";
}
else if (Amulet == 0)
{
cout <<"You found Soris's Amulet!\n\n";
cout <<"You feel protected and are awarded ten points.\n\n";
Amulet = 1;
}
}
Here are some of the data structures I've used for text games
PHP Code:
enum eItemFunction { eOnce, eInfinite, eFinite, eTimeLimited }; // how many times can you use item?
enum eRoomType { ePath, eWall, eRoom }; // types of rooms
struct sItem {
char* itemName;
int itemStrBonus;
int itemLifeBonus;
eItemFunction itemUse;
}
struct sMapRoom {
eRoomType roomType;
sItem roomItems[4]; // max of 4 items
char* roomDescription;
bool bNeedKey;
char* keyName;
}
struct sMap {
sMapRoom mapRooms[100][100];
char* mapDescription;
// map details like geography etc.
}
struct sPlayer {
sItem Inventory[32];
int Life;
int x; // map co-ordinates
int y;
// etc.
}
That helps out a little... but how would i ADD the items to the inventory? My first game was using RoDs engine. i created about 1800 lines of that crap.... and the game was really bad. after 6 games of that i got into using structures... my latest source is this
attached. Its a game to rival my dads Beave hunter (beave is my nickname). So It's called Dad Hunter. LOL. But when i start the game, im already on that wierd floor with the trap on it.. no matter what, then when i add to the skill, max_y etc, it performs an illegal operation. That really irritates me.
Hm, wha? where? huh? RoD made an engine? Tell me about it!Quote:
Originally posted by Blizzarddog
My first game was using RoDs engine.
Dad Hunter makes me think of my time in BASIC :p
You should do something about it, put some things in functions.
it was in my first week of C++, i had a junky-at-best txt game that ran on if's, a switch or two, and user input...i mean it was ok but i wouldn't consider it an engine...
I love Cut & PasteQuote:
My first game was using RoDs engine and the game was really bad.
:D
I call anything that the game runs on an engine, what makes things happen. In my experiance in ZZT, my company made a game call mech trainer with the player at the bottom of the screen controlling the mech above him. That is an engine. If (sword == 2) do this, i consider that an engine because else if (sword == 1) do that
if its an engine its a ford....prone to problems....
And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
And i dont care much for sarcaasm.. bad week.
I hear ya.Quote:
Originally posted by RoD
if its an engine its a ford....prone to problems....
Hmmmmm, it was a joke for RoD, anyhow sorryZ.Quote:
Originally posted by Blizzarddog
And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
And i dont care much for sarcaasm.. bad week.
i got the joke, guess he missed it...