Intel sponsors gamedev.net search:   
Adventures in Text-modeBy Twisol      
In order of no progress to done: Red, Orange, Yellow, Blue, Light blue, Green, Light green.

Last updated 2/12/09 at 12:01 am PST

Cripes! 2.0 -- See the Class Layout

Arenamatic Code w/ cConsole


Tuesday, May 9, 2006
The flight to Italy was so, so, so tiring and boring. I'm lucky that I can even post this from here, since this hotel's internet access costs $15 for an hour, and my father had to get on and let me have the last 30 minutes.

When we got off the plane, ARGH, I felt like i was braindead. Then we had to endure a tour bus for 4 hours!

Comments: 0 - Leave a Comment

Link



Sunday, May 7, 2006
I'm headed to Italy in about 8 hours, so I likely won't be posting for the week I'm staying there. Adios!

Uh, no, wait, that's Spanish... hmm...

Comments: 1 - Leave a Comment

Link



Friday, May 5, 2006
Well, Deranged has pointed me to TinyXML, so I might just scrap the current file parser I'm working on. It depends on if I can use TinyXML to fill instances of class "item" with the information parsed from an XML file. Could anyone reading this comment and let me know if it's possible and a good idea to use TinyXML to parse an XML file like below (this is just a guess at what an XML file would look like, I don't have any experience with XML) into a C++ object like [also] below?

EDIT: Hah, the past three entries have started with "Well". Ironic, since I'm not feeling at all "well" right now!

<items>
  <item name="Mana Potion">
    <desc>A potion of Mana</desc>
    <effects>
      <mana>+10</mana>
    </effects>
    <store>10</store>
    <inventory>5</inventory>
    <equipment>1</equipment>
  </item>
</items>



class item {
    string name;
    int price;
    string desc;
    map<string,int> effects;
    int InvenQuant, EquipQuant, StoreQuant;
}




Comments: 0 - Leave a Comment

Link


Well, so far so good. I've managed to make it "see" the 's' in the first line of the file, and then act to take in the number just after it. The code I have so far is below; still has mainly debugging cout statements, but at least I'm gettimg somewhere.

        void LoadGame() // Still implementing
        {
            ifstream gameIn(file.c_str());
            string line, prev;
            do
            {
                gameIn >> line;
                prev = line;
                for (int i = 0; i < line.length(); i++)
                {
                    cout << line[i];
                    if (line[i] == 's')
                    {
                        i++;
                        cout << ": S will have ";
                        for (int it = i; line[it] != '!'; it++)
                        {
                            cout << line[it];
                            i++;
                        }
                        cout << " object." << endl;
                    }
                    break;
                }
                break;
                cout << line << endl;
            } while (!gameIn.eof() && line != prev);
            gameIn.close();
        }



Comments: 0 - Leave a Comment

Link



Thursday, May 4, 2006
Well.. I've hit a wall in my coding. I need some easy-to-use way of maintaining player item inventory, equipment, and store lists (rather, maps), but I don't want the user to have to create and maintain three separate files. I'm thinking of having one master file with all the information about an item in it, but then comes two other problems: it'll likely be somewhat unweildy to parse, and I'll have to put the data into each component's map, which might be difficult considering each component is withing its own class, and depending on the needs of the user, it might be there and it might not.

I'm thinking of making it so you HAVE to create an object of type cArena to have everything work, which would allow me to make every other component call a cArena object function, which would switch a bool value to "true", which would cause the cArena file parser to know which components can be loaded...

Well. I guess writing in this journal has helpful side-effects, huh? :P

EDIT: As a last remark, this means I'll need to think up a format the user will use for the "master item file". This is what I'm currently thinking of...

s
mp
Mana Potion
Mana,+10
Adds 10 to your current amount of mana.
~
ies
ex
Elixer
Life,+20!Mana,+20
Adds 20 to your current amount of life.



The first line is a flag that determines which component recieves the info (in this case, the store only). The second is the key used for maps. The third line is the name of the item (duh?), and the fourth shows which player attributes are affected when the item is used (in this case, Mana for 10 points). The fifth line is a description of the item. Between item descriptions is a ~ thing to tell the parser that it's moving on to a new item. The only major differences in the second description are that it has two effects: Life +20 and Mana +20, using the ! to let the parser know it's got another attribute on its hands; and there's three flags set for the item: i (inventory), e (equipped), and s (in the store).

How I'm going to accomplish this is beyond me. I'll sleep on it. *sigh*

Comments: 2 - Leave a Comment

Link



Tuesday, May 2, 2006
I've tossed out the name "AreBat". Sounds too freaky.

Today I managed to solve my runtime problems (one that sticks out in my mind is accidentally passing a map iterator->second instead of ->first), and the shop has been bumped up to green! (I save light green for polishing and otherwise improving) Next up will be my battle component, which will take a while because of all the factors I need to add in... player health and stats, experience and money, and saving/loading a player file.

Once I'm done with all that, I'll also have a fun (complete) arena battle program created that fully utilizes the headers I'm making. If anyone wants, I'd be glad to put the finished program and headers up for download.

And with that... off to the battle component!
~Link

Comments: 0 - Leave a Comment

Link


AreBat is pronounced ah-REE-bat, and stands for Arena Battle. :P

Well, today I chatted on IRC way too much. I did take out a useless string (and its functions) in the cArena class, though, as well as change the way I utilize my modes in the actual program. I'm making sure my store class works the way I want it to by using it to implement a store into the arena program. If I can't do it, or have an insanely difficult time doing it (stupidity doesn't count), I'll incorporate functionality for whatever was annoying into the class itself.

Hopefully tonight I can green out one of the to-do list items, and notch the title from orange to yellow.

EDIT: Ok, sadly I will not be able to say that my store is done. I'm having troubles... runtime troubles... with my tests. Le sigh. Gotta prove that it works and can be done before I can green it.

Comments: 2 - Leave a Comment

Link



Monday, May 1, 2006
Currently I'm working on a set of header functions to be used for creating an "arena battle" game (text-based). My curent focus is on the store (where you spend money you get from winning arena battles), and it's been a bit tough. I managed to get the LoadStore and SaveStore functions working, though. When the user of these headers (specifically, cStore.h - don't ask about the c, please) creates an object of type store (the name I gave to my store class), the user passes a string argument with the name of the file they want to use to load shop data from. The constructor then calls LoadStore(), which parses every line of the file given and separates the lines at certain points. Hmm, maybe I should give an example.

// ...
#include "cStore.h"

store shop("shop.txt"); //Calls the constructor (you're probably thinking, "DUH!")

// ... skipping to cStore.h (EDIT: Everything from here down is in "class store")

    private:
        map<string, string> shopMap;
        string file;
        ifstream shopIn;
        ofstream shopOut;

/*
 *Please pretend there's a public: here... I don't want to have
 *to re-indent my code 8 spaces. >_<
 */
store(string userfile)
{
    shopIn.open(userfile.c_str()); //This opens an ifstream with the user-specified file
    cout << "Loading Store\n"; //Just for testing purposes; I want to make sure I don't break my code somehow.
    LoadStore(); //Uh... loads the store?
}

~store()
{
    if (shopIn.is_open()) shopIn.close();
    if (shopOut.is_open()) shopOut.close();
    SaveStore(); //Saves the store to a file
}

void LoadStore()
{
    string line, key;
    string item[2];
    do
    {
        shopIn >> line; //Gets a line from shopIn every iteration of the do-while
        if ((line != (item[0] + '%' + item[1])) && (line != "")) //If the line is not the same as the line before...
        {
            item[0] = PairSplit(line); //...then parse the line and save the first half here...
            item[1] = PairSplit(line, 1); //..and save the second half here.
            shopMap.insert(pair<string, string>(item[0], item[1])); //Insert the key-value pair into the shopMap.
            cout << shopMap[item[0]] << endl; //Debugging cout statement.
        }
    } while (!shopIn.eof());
}

void SaveStore()
{
    shopOut.open(file.c_str()); //opens an ofstream to the user-specified file
    if (!shopMap.empty()) //if the shopMap is not empty
    {
        map<string,string>::iterator forIter = shopMap.begin(); //iterator starting at the beginning of the map
        map<string,string>::iterator endIter = shopMap.end(); //iterator that stays at the end of the map
        string line;
        do
        {
            if (forIter->first != "" && forIter->second != "") //If forIter does not contain null values...
            {
                line = forIter->first + '%' + forIter->second; //...concatenate them using the %...
                cout << line << endl;
                shopOut << line << endl; //...and print them to the file.
                forIter++; //Increment forIter.
            }
        } while (forIter != endIter);
        shopOut.close();
    }
}




Uh... that wasn't as explanatory as I wanted it to be. Well... basically, when LoadStore is called, it parses the file and splits it into two variables at the '%' character. If the line "lp%Life_Potion$30" was in the file, we'd now have "lp" and "Life_Potion$30", paired and placed into the map. When the shop is saved, the process is reversed (concatenating the key and value with the '%').

Call me a newb, I think I posted this too early in the day. My mind needs to load up on gas. >_> I'm just too excited about getting a journal. :P As a question for anyone reading this, is it acceptable to post twice a day?

EDIT: Forgot to end the source tag. >_<

Comments: 3 - Leave a Comment

Link


All times are ET (US)

 
S
M
T
W
T
F
S
3
6
8
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

OPTIONS
Track this Journal

 RSS 

ARCHIVES
August, 2009
July, 2009
March, 2009
February, 2009
December, 2008
November, 2008
October, 2008
August, 2008
July, 2008
June, 2008
May, 2008
April, 2008
November, 2007
July, 2007
June, 2007
May, 2007
April, 2007
March, 2007
February, 2007
December, 2006
October, 2006
September, 2006
July, 2006
May, 2006
April, 2006