Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 2 [3] 4 5 ... 29

Author Topic: My C++ Projects - Tower of Azari v0.31 - "I'm not dead yet."  (Read 50333 times)

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.1, updated Sep. 18)
« Reply #30 on: September 19, 2009, 01:43:30 pm »

to pass a multidimensional array to a function you need to remember that the name of the variable alone:

char chMap[XMAX][YMAX] = {0};  //map initialized to zero. 

chMap (without specific [] is a pointer to the first element of the array)

so to use it in a function you will pass it by reference doing the following:
Code: [Select]
/* The first dimension of a multidimensional array is obtained automatically by the compiler so you can use name[][YMAX] instead of name[XMAX][YMAX] to define it (wich you can also do if it's only one dimension, wich is really handy :)) . */
void WriteMap(char chInput[][YMAX])
{
  for(int iii = 0;iii<YMAX;iii++)
    for(int jjj = 0;jjj<XMAX;jjj++)
      cin>>chInput[jjj][iii]; /*This will ask you to input a char every time and place it in the correct spot of the matrix.  This is gonna modify the passed value*/
}

char chMap[XMAX][YMAX] = {0};

int main ()
{
  //You call it like this
  WriteMap(chMap);  /*remember, you're passing a pointer to the direction of the first element of the array.*/
}



Is that mode safe enough to prevent the array from turning into a pointer? If not, you shouldn't pass an array like this to function A and from function A again to function B. Funny things might happen, and that's the dwarven definition of fun (by passing it a second time it might lose it's array information and therefor it becomes nothing but a pointer). Just some information I ran into while looking for info about 2-d arrays
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, updated Sep. 19)
« Reply #31 on: September 19, 2009, 04:52:51 pm »

Version 1.3 Released

Release Notes:
  • FIX - Fixed spelling of "Operate Pump"
  • FIX - Fixed toughness description bug
  • FIX - Fixed starvation/dehydration bug

See first post for new link.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: My C++ Projects (Dwarf Caretaker v1.1, updated Sep. 18)
« Reply #32 on: September 19, 2009, 11:31:14 pm »

to pass a multidimensional array to a function you need to remember that the name of the variable alone:

char chMap[XMAX][YMAX] = {0};  //map initialized to zero. 

chMap (without specific [] is a pointer to the first element of the array)

so to use it in a function you will pass it by reference doing the following:
Code: [Select]
/* The first dimension of a multidimensional array is obtained automatically by the compiler so you can use name[][YMAX] instead of name[XMAX][YMAX] to define it (wich you can also do if it's only one dimension, wich is really handy :)) . */
void WriteMap(char chInput[][YMAX])
{
  for(int iii = 0;iii<YMAX;iii++)
    for(int jjj = 0;jjj<XMAX;jjj++)
      cin>>chInput[jjj][iii]; /*This will ask you to input a char every time and place it in the correct spot of the matrix.  This is gonna modify the passed value*/
}

char chMap[XMAX][YMAX] = {0};

int main ()
{
  //You call it like this
  WriteMap(chMap);  /*remember, you're passing a pointer to the direction of the first element of the array.*/
}



Is that mode safe enough to prevent the array from turning into a pointer? If not, you shouldn't pass an array like this to function A and from function A again to function B. Funny things might happen, and that's the dwarven definition of fun (by passing it a second time it might lose it's array information and therefor it becomes nothing but a pointer). Just some information I ran into while looking for info about 2-d arrays
Look... I'm not sure what you mean exactly but when you pass an array into a function the first dimension is automatically recognized (hence the [] without an amount) but if you want to pass a multidimensional array you need to specify each one.

I think I may be not be precise enough to explain this so I'll just link you to a good article of a nice c++ tutorial wich covers this topic:
http://www.mikeware.us/cpp/?p=44
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, updated Sep. 19)
« Reply #33 on: September 24, 2009, 07:19:15 pm »

New project!  Copied from the OP...

Quote from: Original Post
    I recently started playing Disgaea: Afternoon of Darkness, and found myself taking every possible chance to solve the geo-panel puzzles presented in many of the levels. Unfortunately, I also find myself making mistakes regularly, and despite the simplicity of the puzzles, my memory (or lack thereof) makes it difficult for me to plan out the entire thing before actually doing it.

   To help with this, I've developed a program that will solve the puzzles, letting me worry about surviving the combat while finding the most efficient way to go about moving the pieces.

   As of version 0.1 (first public release) it only supports five colors (blue, green, purple, red and yellow), primarily because I haven't really progressed all that far into the game yet, and don't even know if there are any other colors...  anyways, I plan to upload the source code soon, but the current version was just tacked onto the original hello world project, that was slowly expanded so I could play with different things and eventually turned into this.  Unfortunately, this means that the source and stuff is the biggest mess I think I've ever seen.  There is code for things that don't exist any more, functions related to buttons that I forgot to delete and so are still in the "Hello World" dialog I created earlier in development and other similar stuff.

The download link and a list of known bugs can be found in the original post

[EDIT]: Man... I just realized how bugged the method I was using to solve the puzzles is... I'm gonna need to work on that... any help in that area would be great.

[EDIT2]:  Dang, I played a bit more and realized you can solve them by simply putting all the blocks except the void on on one color, putting the void on another color, then destroying a block of the same color as the tile you put the void one on... guess that idea's gone... maybe I'll try making a Sudoku solver or something...
« Last Edit: September 25, 2009, 10:24:38 am by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: My C++ Projects (Dwarf Caretaker v1.3, Updated Sept. 24)
« Reply #34 on: September 26, 2009, 04:03:47 pm »

the games are looking great... Ill check them out in depth soon...

I tried from work but I was missing dlls...  downloaded them but the snake program still didn't work.  The other one did. 
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, Updated Oct. 1) New Project!
« Reply #35 on: October 01, 2009, 04:59:32 pm »

@Alexhans - Sorry for the slow reply.  Did it specify which DLLs were missing and where they were expected to be?

NEW PROJECT
After the failure that was my "Disgaea Geosolver" project I decided to try a Sudoku solver.  I realize there are loads of them already available, probably with nicer interfaces and more efficient solving algorithms, that are available without a download, but I wanted to develop some sort of puzzle solver, and I learned a good bit about interface programming and computer logic in the process.

See the first post for more details.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.3, Updated Oct. 1) New Project!
« Reply #36 on: October 01, 2009, 05:34:10 pm »

I haven't read through the whole thread, so I'm not sure of your programming expertise, but here's a site I am finding has some nice tidbits in it: http://takinginitiative.wordpress.com/

Edit: More specificly, the programming articles under "catagories."
I personally find the neural network articles interesting.

Oh, and if you really want to learn a fun method of problem solving, look into genetic algorithms.

Based on your code, it looks like you are on a similar level with me as far as experience with programming goes; albiet going at it with a completely different approach (I code much more procedurally).
« Last Edit: October 01, 2009, 05:50:19 pm by alway »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, Updated Oct. 1) New Project!
« Reply #37 on: October 01, 2009, 06:32:58 pm »

@alway - I'll look into both of those, thanks!  I tried procedural programming, but I have a hard time keeping up with my own code when it starts getting longer... I'm sure there's a way to manage it better, I just don't know what it is...

My internet cut off on me for a minute or two while I was uploading the source code for the Sudoku Solver, so I'll have to try again.  It should be up shortly.
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.3, Updated Oct. 1) New Project!
« Reply #38 on: October 01, 2009, 06:45:02 pm »

It does get a bit difficult at times. The important thing is to break it up into plenty of functions, I use Dev Bloodshed C++ as my compiler, and it (like I suspect most if not all compilers) has an option to show classes, functions, and global variables. This feature I mostly use for functions, since with a single double click on the function name, it takes me where ever in the code I want to go. Also, liberal use of comments is always a plus, even if the code's function is completely obvious.

Oh, and a fun little tidbit in case you didn't know: in addition to system("pause"); you can use the other system commands available to the command prompt. system("color 0c"); is one I find particularly useful for warning the player if something bad is happening/about to happen (system("color"); will reset it to default). For other color combinations, type "help color" into your command prompt.

Here's my WIP sci-fi game... although at the moment its more of a generic text RPG game engine. I am fairly sure most of my includes are un-needed, but oh well... The apmatrix.h is hooked up to 3 other files I DLed, apmatrix.cpp apvector.cpp apvector.h, all 4 of which have been slightly modified (so I could add in a couple extra functions to apmatrix, namely an eraseRow and eraseCol function. The itemvector header file contains my itemvector class, which is essentially a class based version of the parallel vectors (and matricies) used for the area system. Both the itemvector and the area data stuff do more or less the same things, just different methodologies due to items needing to be rearanged, added, and deleted frequently.
Code: [Select]
//includes
#include <iostream>
#include <vector>
#include <string>
#include "apmatrix.h"
#include <fstream>
#include <iomanip>
#include "itemclass.h"


//namespace
using namespace std;



void redAlert();                            //function declarations
void loggin();
int playerInput();
void loadProfile();
void loadDef();
void move();
void directionInput(char dInput);
void statusInfo();
void areaData();
void saveProfile();
void displayInventory();





int p_new_location;                           //player variables
vector<int> p_a_contents;
vector<int> p_a_connections;
vector<char> p_a_directions;
int p_a_location;
string p_a_description;
int p_health;
string p_name;

vector<int> a_locations;                      //world variables
vector<string> a_descriptions;
apmatrix<int> a_contents(5,5,0);
apmatrix<int> a_connections(5,5,0);
apmatrix<char> a_directions(5,5,0);
itemvector p_inventory;
itemvector WorldItemList;







//main function
int main()
{
    areaData();                          //load in world area data
   
    WorldItemList.loadFromFile();
   
    loggin();                            //load/create character
   
   
   
    //game loop
    while(true)
    {
           statusInfo();                //displays vital info after every loop
           playerInput();               //input
           
           
           
    }
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
    return 0;
}






















//Red Alert function
void redAlert()
{
     cout<<"ENTERING RED ALERT STATUS, ALL PERSONNEL REPORT TO STATIONS"<<endl;
     system("color 0c");
}


//login function, retrieves data from previous games
void loggin()
{
     bool tf=true;
       while (tf)
       {
       cout<<"Please enter username, type 'new' if you do not have a character: "<<endl;
       cin>>p_name;
       if(p_name!="new")
       {
       ifstream fin(("profiles\\"+p_name+".txt").c_str());
       if (fin.good())
       {
                      fin.close();
                      loadProfile();                    //load from txt file
                      tf=false;
       }
       else
       {
           cout<<"Username not found."<<endl;
       }
       }
       if (p_name=="new")
       {
           loadDef();                                 //use default values
           tf=false;
       }
       }
}


//input handling function
int playerInput()
{
    string input;
    cin>>input;
    if (input=="w"||input=="e"||input=="n"||input=="s"||input=="east"||input=="west"||input=="north"||input=="south")
    {
           char dInput;
           if (input=="w"||input=="west")
           {
           dInput='w';
           }
           if (input=="e"||input=="east")
           {
           dInput='e';
           }
           if (input=="n"||input=="north")
           {
           dInput='n';
           }
           if (input=="s"||input=="south")
           {
           dInput='s';
           }
           directionInput(dInput);
    }
    if (input=="inventory")
    {
        displayInventory();
    }
}




//load profile from default (starting) values
void loadDef()
{
     cout<<"Welcome, new player, please enter a name. Note: entering the same name as a pre-existing profile will erase that profile!"<<endl;
     cin>>p_name;
     cout<<"Welcome, "<<p_name<<endl;
     p_health=100;
     p_new_location=1;
     move();
     saveProfile();
}


//deals with player movement
void move()
{
     int x = 0;
     while (a_locations[x]!= p_new_location)          //find x position of new location in world structure
           {
           x++;
           }
     p_a_contents.clear();                              //clear old player area variables
     p_a_connections.clear();
     p_a_directions.clear();             
     p_a_location=p_new_location;                       //assign new location variable
     p_a_description = a_descriptions[x];             //assign new area description
     int y = 0;
     while (a_contents[x][y])                     //assign new contents
     {
           p_a_contents.push_back(a_contents[x][y]);
           y++;
     }
     y=0;
     while(a_connections[x][y] != 0)                          //assign new connections
     {
     p_a_connections.push_back(a_connections[x][y]);
     y++;
     }
     y=0;
     while(a_directions[x][y] != '0')                            //asign new directions
     {
                                   p_a_directions.push_back(a_directions[x][y]);
                                   y++;
     }
     cout<<p_a_description<<endl;                              //show area description
     return;
}
     
     

//process direction input to ensure valid movement
void directionInput(char dInput)
{
     int size= p_a_directions.size();
     int i = 0;
     while (i<size && dInput != p_a_directions[i])
     {
           i++;
           if (i==size)
           {
                      cout<<"Invalid movement"<<endl;        //failsafe to prevent invalid movement entry from causing vector problems
                      return;
           }
     }
     p_new_location=p_a_connections[i];
     move();
     return;
}


//displays information about player and area after every game loop
void statusInfo()
{
     
     string exits="";          //display possible movements
     int i=0;
     cout<<"exits: ";
     while (i < p_a_directions.size())
     {
           
           exits=p_a_directions[i];
           i++;
           cout<<exits;
           if (i < p_a_directions.size())
           {
           cout<<", ";
           }
     }
     
     cout<<". health:"<<p_health<<". Input: ";    //display health and prompt for input
     return;
}


//saves player profiles
//will need updating as more variables come into play, specifically inventories and ship data
void saveProfile()
{
     ofstream fout(("profiles\\"+p_name+".txt").c_str());
     fout<<p_name<<endl;
     fout<<p_a_location<<endl;
     fout<<p_health<<endl;
     fout.close();
}


//loads preexisting profiles from text files in profile fold in directory
void loadProfile()
{
     ifstream fin(("profiles\\"+p_name+".txt").c_str());
     fin>>p_name;
     fin>>p_new_location;
     fin>>p_health;
     move();
}



//display items in player's inventory
void displayInventory()
{
     int iter=0;
     while(p_inventory.vectorSize()>iter)
     {
         cout<<p_inventory.itemName(iter)<<endl;
         iter++;
     }
}



//transfer item from world list to other itemvector
void itemvector::createItem(string itemName)
{
     int iter=0;
     bool solution=false;
     while (WorldItemList.name.size()>iter+1)
     {
           if(WorldItemList.name[iter]==itemName)
           {
              solution=true;
              break;
           }
           iter++;
     }
     if(solution==false)
     {
         cout<<"Error: Item not found!"<<endl;
     }
     
     else
     {
         name.push_back(itemName);
         id.push_back(WorldItemList.id[iter]);
         type.push_back(WorldItemList.type[iter]);
         description.push_back(WorldItemList.description[iter]);
         int rows=use.numrows();
         int cols=use.numcols();
         use.resize(rows+1,cols);
         if(WorldItemList.use.numcols()>use.numcols())
         {
            use.resize(rows+1,WorldItemList.use.numcols());
         }
         int y=0;
         
         while(y<WorldItemList.use.numcols())
         {
            use[name.size()-1][y]=WorldItemList.use[iter][y];
            y++;
         }
     }
}





































//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//----------------------Area data--------------------------------------------
//---------------------------------------------------------------------------
//-------------Feeds data into world variables-------------------------------
//---------------------------------------------------------------------------
//-a_locations--a_descriptions--a_contents--a_connections--a_directions------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------

void areaData()
{
     int locationId=0;           //variable declarations
     string description;
     int count=0;
     int contentId;
     int endone=0;
     int xSize=10;
     int ySize=5;
     int zSize=5;
     int xPosition=0;
     int iter=0;
     
     a_connections.resize(xSize, ySize);         //initial sizing of matrices
     a_directions.resize(xSize, ySize);
     a_contents.resize(xSize, zSize);
     
     
     ifstream fin("area.txt");           //initialize file input
     if(fin.good() != 1)
     {
                    cout<<"Error opening world data."<<endl;
                    return;
     }
     
     while (fin.eof()==false)
     {
           fin>>locationId;
           fin.ignore();
           getline(fin, description);
           fin>>count;
           if((ySize-2) < count)
           {
                        ySize += 5;            //ensure matrices are large enough, essentially the same as push_back
                        a_connections.resize(xSize,ySize);
                        a_directions.resize(xSize,ySize);
           }
           iter = 0;
           while(iter<count)
           {
                  fin>>a_connections[xPosition][iter];      //store connectionIDs
                  iter++;
           }
           iter = 0;
           while(iter<count)
           {
                  fin>>a_directions[xPosition][iter];    //store movements possible
                  iter++;
           }
           a_directions[xPosition][iter]='0';
           fin>>count;
           if (zSize-2<count)
           {
                   zSize += 4;
                   a_contents.resize(xSize, zSize);        //ensure matrix is large enough
           }
           iter=0;
           while(iter<count)
           {
                  fin>>a_contents[xPosition][iter];           //store things in area
                  iter++;
           }
           a_contents[xPosition][iter]=0;
           if(xSize-2 < xPosition)
           {
                   xSize = 5 + xSize;
                   a_connections.resize(xSize,ySize);
                   a_directions.resize(xSize,ySize);
           }
           a_locations.push_back(locationId);
           a_descriptions.push_back(description);
           xPosition++;
           fin.ignore();
     }
a_locations.push_back(0);
return;
}
« Last Edit: October 01, 2009, 06:57:42 pm by alway »
Logged

Flaming Dorf

  • Bay Watcher
  • Oh No Indian!
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.3, Sudoku Solver v1.0, Updated Oct. 1)
« Reply #39 on: October 02, 2009, 09:30:46 pm »

Hey, thanks for the games. I've been working on my own C++ game for over a year now and its going kinda slow, but seeing someone else's work is really inspiring. I might actually get some work done tonight! :0
Logged
[PERMITTED_JOINT:100] (It's a maximum number per day. This is the elven setting)

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, Sudoku Solver v1.0, Updated Oct. 1)
« Reply #40 on: October 03, 2009, 12:10:21 am »

@Alway - I haven't had the time to look through all of the code, but I'm definitely working on it!  I personally feel that understanding every possible angle to approach a problem is absolutely necessary to solving it efficiently, so learning how to program procedurally is something I need to get a better grasp of... :D  I'll google the apmatrix and apvector files and see if I can find them so I can try this out later!

@Flaming Dorf - Not a problem, I've really enjoyed working on them!  I'd love to see what you've done as well, there is a lot of inspiration to be gained by watching other people work :)

The source code for my Sudoku Solver is up on the Google Code page.  One of the files in the folder is about 50MB, and google code wouldn't let me upload it, so I may have to find another way to make it available, if it is a necessary file...

Thanks for the feedback!
Tim

Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, Sudoku Solver v1.0, Updated Oct. 1)
« Reply #41 on: October 07, 2009, 05:09:12 pm »

I finally broke down and started a Rogue-Like with PDCurses.  I've gotten a lot done in the last couple days, and right up until I tried to add enemies it worked great... unfortunately, now that I have, it dies on me at seemingly random points, usually when the x position of the player is a particular value (such as 46).  I've been staring at the code for about an hour now trying to figure out what's wrong, but I can't find anything... 

I'm going to take a break and see if it comes to me after I walk away for a bit, but in the mean time, feel free to see if you can figure it out...

Download - 408KB - Full project folder.

[EDIT]:  I'm fairly sure the problem is in here somewhere...
Code: [Select]
int Move(int xmod, int ymod, _game &Game, map &game_map, tileType tiles[])
{
    int move_cost = 50/Game.plyr_dex;
    int move_tile = game_map.tile[Game.plyr_x+xmod][Game.plyr_y+ymod];

    Game.plyr_ap-=move_cost;

    if(tiles[ move_tile ].passible==true && game_map.occupied[Game.plyr_x+xmod][Game.plyr_y+ymod]==false)
    {
        Game.plyr_x+=xmod;
        Game.plyr_y+=ymod;
        addlog(" You moved","   ???.", "You took one step.", Game);
        return 1;
    }
    else if(move_tile==5)
    {
        game_map.tile[Game.plyr_x+xmod][Game.plyr_y+ymod]=6;
        addlog(" You open","   the door.", "You opened a door.", Game);
        return 2;
    }
    else if(game_map.occupied[Game.plyr_x+xmod][Game.plyr_y+ymod])
    {
        enemy target;
        bool got_target=false;

        int targets = int(Game.enemies.size());

        for(int i=0; i<targets; i++)
        {
            enemy current_enemy=Game.enemies.at(i);

            if(current_enemy.x==Game.plyr_x+xmod && current_enemy.y==Game.plyr_y+ymod)
            {
                target = current_enemy;
                got_target=true;
                break;
            }
        }

        char dmg[3];
        sprintf(dmg, "%d", ( rand()%Game.plyr_str) - (rand()%target.endu) );
        int hit = (Game.plyr_dex + rand()%20)-(target.dext + rand()%20);

        if(hit>=0 and dmg[0]!='-')
        {
            addlog(" You attack","   "+target.name+".","You attacked "+target.name+"\n   for "+dmg+" damage!", Game);
        }
        else
        {
            addlog(" You missed", "   "+target.name+".", "You attacked "+target.name+"\n   but you missed!", Game);
        }
        return 3;
    }

    else {return 0;}
}

It's called in four places, each corresponding to a case in a switch statement, like so...
Code: [Select]
Move(0,-1, Game, game_map, tiles);Except the 0,-1 is changed depending on the direction they want to move.

Also, it would seem that it's just certain positions on the map that the player isn't allowed, as there seem to be arbitrary y "walls" as well...

[EDIT2]:  I feel like an idiot... I wasn't initializing the occupied flag when I loaded the map...  it works now, I should have an upload of a semi-playable version some time tonight or tomorrow...

[NEW GAME!]
Just finished uploading a primitive release of my rogue-like: Tower of Azari.  The name was pretty much just because I needed a 5-letter name (for the last word), and figured I'd go with a corny fantasy sounding name. 

From the first post:
Quote
Well, I've finally broken down and started a rogue-like.  I've decided to start simple though, so the concept is very, very basic.  Early iterations will only have melee combat, although I will later add ranged, and after that, magic.  Your character starts at the bottom of a tower, and has to work his way up to kill... something, haven't really decided what yet.  Each floor is relatively small, and won't scroll, so it will likely be a much shorter rogue-like than some others.  In addition, I may or may not allow the player to go down stairs, to force them to make sure they've finished on the current floor before moving onto the next.  I also have what I believe to be a slightly more interesting idea for the way magic is introduced, but it's long, and can wait until I can get my notes organised into a primitive design document and upload it.

See the original post for a download link.  The source code isn't up yet, and probably won't be until I get the next version done... if you want to help with that, I've got a question here that needs answering... especially if you've got a more efficient way to do it than one piece at a time...

Oh, and this'll probably be on the blog some time tomorrow, but I'm tired now so it'll wait.
« Last Edit: October 07, 2009, 10:05:00 pm by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Flaming Dorf

  • Bay Watcher
  • Oh No Indian!
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.3, Sudoku Solver v1.0, Updated Oct. 1)
« Reply #42 on: October 08, 2009, 08:03:50 pm »

@Flaming Dorf - Not a problem, I've really enjoyed working on them!  I'd love to see what you've done as well, there is a lot of inspiration to be gained by watching other people work :)

Yeah, I'm thinking about posting a v0.1 of my latest project on the forum coming up. The code is a complete mess, so I probably won't be posting any source, at least not until I get around to rewriting a few thousand lines of code.

Also, I extracted and ran Tower of Azari, and managed to get through character creation. Shortly afterwards, it gives me something along the lines of a 'file not found' error and terminates itself. I used a campus Vista (ugh) to run it.
Logged
[PERMITTED_JOINT:100] (It's a maximum number per day. This is the elven setting)

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Dwarf Caretaker v1.3, Sudoku Solver v1.0, Tower of Azari v0.1 +more!
« Reply #43 on: October 08, 2009, 08:31:45 pm »

I like it so far, but I'd like to know the basic format of your code layout.
It seems sort of random, and a bit ambiguous.
For instance, game, map, and main all sort of seem like they are the same in my mind.
You seem to be a lot more proficient than me though.

Are you going to do anything new with this rogue-like?
I'd like to see what you can come up with.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.3, Sudoku Solver v1.0, Updated Oct. 1)
« Reply #44 on: October 08, 2009, 10:19:29 pm »

Yeah, I'm thinking about posting a v0.1 of my latest project on the forum coming up. The code is a complete mess, so I probably won't be posting any source, at least not until I get around to rewriting a few thousand lines of code.

Also, I extracted and ran Tower of Azari, and managed to get through character creation. Shortly afterwards, it gives me something along the lines of a 'file not found' error and terminates itself. I used a campus Vista (ugh) to run it.
I know what that's like... the source for most of my projects starts out like that...

Hmm... I really have no idea what might be causing that... what was the last thing you did/tried to do?

I like it so far, but I'd like to know the basic format of your code layout.
It seems sort of random, and a bit ambiguous.
For instance, game, map, and main all sort of seem like they are the same in my mind.
You seem to be a lot more proficient than me though.

Are you going to do anything new with this rogue-like?
I'd like to see what you can come up with.
Basically, the main.cpp file runs what needs to be run at startup.  The header files (.h) hold function and structure names and some basic information, while the matching source (.cpp) file holds the full function declarations. 

The 'ascii_art' files are for displaying large blocks of text that I'd rather not try to format by hand in a printw() function or something.  The 'game' files hold information used to manage the game, output, getting input, moving the player, eventually saving and loading will be in there too.  The 'map' files are for functions/structures related to maps (this is where it might get a little confusing, cause the function for loading a map into a game is in the 'game' files, not the 'map' files...).  The 'map.cpp' file doesn't actually have anything in it now, and is just there in case I need to add functions related to maps.  In the version I'm working on there are files for managing enemies, with things like the structure definition and a function to make adding enemies easier.  The 'misc_functions' file just holds anything that doesn't fit anywhere else.  For example, I wrote a simple function that returns a rounded down integer representing the distance between two points on the map.

I really need to comment it more, so that'll be a project for before the next release.  I don't particularly to go through the massive commenting project I had when I didn't bother to comment the Dwarf Caretaker code for so long...

Also, I've uploaded a pdf "design doc".  It's far from being a real, complete design document, but it gives a decent idea of where I picture this going.

"Design Document"

[EDIT]:  Also, the above is a starting point.  I have every intention to expand it later, but I want to get a base first, then I can try to make something more of it.  Maybe I'll try and make the spell creation mechanic I've been wanting to put in a game...
« Last Edit: October 08, 2009, 10:21:10 pm by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.
Pages: 1 2 [3] 4 5 ... 29