Bay 12 Games Forum

Please login or register.

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

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

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v0.7)
« Reply #15 on: September 09, 2009, 02:29:49 pm »

Well, I just finished uploading the version I just finished, but I like the idea, so it should be in the next version.  I would have just tacked it onto this one, but there's a solid chance there would bugs, even if they were just things not getting aligned correctly.

Anyways, v0.8 update:
  • BUG FIX - Enemy blocks don't break the game.
  • BUG FIX - Random numbers are actually random (seeded with time) again.
  • CHANGE - Partial rewrite to use a class to represent the dwarf.
  • CHANGE - Slight rewording on some combat text.
  • NEW - New random event: Parties!  About as often as sieges a party will roll around for free food, drink and happiness!
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.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v0.8)
« Reply #16 on: September 09, 2009, 03:21:51 pm »

Just looked through your code, and I ran into one thing. In ActWork, you're using int fatal and int mfatal, since it gives an error if you'd use int fatal twice. This is true, because in that case you'd be trying to initialise fatal twice, and compilers don't like that. Instead you should define fatal before the switch statement and use it as a normal variable. Saves you a headache ;)

Also, currently if you're dealt enough damage to a non-vital part, the game still ends. It'd be a good idea for later versions to contunie the game instead and give some sort of penalty.
« Last Edit: September 09, 2009, 03:26:27 pm by Virex »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v0.8)
« Reply #17 on: September 09, 2009, 04:15:50 pm »

Just looked through your code, and I ran into one thing. In ActWork, you're using int fatal and int mfatal, since it gives an error if you'd use int fatal twice. This is true, because in that case you'd be trying to initialise fatal twice, and compilers don't like that. Instead you should define fatal before the switch statement and use it as a normal variable. Saves you a headache ;)

Also, currently if you're dealt enough damage to a non-vital part, the game still ends. It'd be a good idea for later versions to contunie the game instead and give some sort of penalty.
Thanks!  I'd been trying to figure that out... I may read up on variable scope later, see if I can't figure it all out.  Don't know why I keep having trouble with something that seems so simple...

I plan to add some sort of penalty for non-vital damage, the healthcare-death thing was just a sort of (bad) joke placeholder on my part. 
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.

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v0.8)
« Reply #18 on: September 10, 2009, 01:37:05 am »

Well, as far as I know, scopes are pretty simple: the scope starts with { and ends with }.
Note that switch statements don't use { and } and also that if you don't end a case with a break it'll continue with the next case, indicating that all cases are within the same scope.
You can also stack scopes like this :
{
int a = 1
FooA(a)
if (FooB(a))
{ char a = e
   FooB (a)
}
}
In this case FooA would use 1 and FooB would use 1 and then e, since the second definition of a overwrites the first one for it's own scope but not for the scope above it.
(note that you'de probably need to overload FooB for this to work. Also note that the if-statement allows implied typecasting from int to bool. So if FooB(a) would return 0, everything in the if statement will be skiped and if it returns another value it does continue. I don't think it'll work with non-int variables (chars, strings et cetera)).

Besides that, the namespace, if defined, is the top scope.
« Last Edit: September 10, 2009, 01:41:20 am by Virex »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v0.8)
« Reply #19 on: September 10, 2009, 06:36:07 am »

Okay, simple enough, thanks!

Oh, while I'm here, Tuesdays and Thursdays are likely to be slow days for me.  I'm home-schooled, but I attend several classes on Tuesdays and Thursdays, as both my father and my step-mother work full time and while I can self-teach math and science, I'm not that good with much of anything else... anyways, I don't have access to the computer until 2:30-3 on Tuesdays, and 4-5 on Thursdays.  There is a seniors meeting today, so I won't be back for a couple more hours, but I have study hall on Thursdays, and may be able to get something done then, depending on the work-load from my school classes.
« Last Edit: September 10, 2009, 06:40:04 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 v0.8)
« Reply #20 on: September 10, 2009, 07:15:31 am »

here's some more feedback on variable scopes and more...

http://www.learncpp.com/cpp-tutorial/41-blocks-compound-statements-and-local-variables/

In fact... This is one of the best c++ tutorials I've seen online:
http://www.learncpp.com/

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.0)
« Reply #21 on: September 10, 2009, 07:39:14 am »

here's some more feedback on variable scopes and more...

http://www.learncpp.com/cpp-tutorial/41-blocks-compound-statements-and-local-variables/

In fact... This is one of the best c++ tutorials I've seen online:
http://www.learncpp.com/

Read the section from the first link, very useful, I'll have to see if I can get access to the wireless network at the school building so I can read the second one later...

Thanks!

Any bug finds in the most recent version?  Working on the next one now, with most of the suggestions given, maybe some new stuff too.


[EDIT]:  New version released, v0.9

Release Notes:

  • NEW – Stats UI overhaul.  Stats are now displayed as (slightly vague) descriptions, instead of numbers.
  • NEW – Wound UI overhaul.  Wounds are now represented by health bars, and a full health bar is always ideal.
  • NEW – Non-fatal wound handling.  Non-fatal wounds no longer force a game-over, and instead hospitalize your dwarf for a few weeks.
  • CODE FIX – Fixed variable scope of fatal and mfatal in the actWork() function.
See original post for download link.

[EDIT2]:  New version released, v1.0

Release Notes:

  • NEW – New random events!  Tantrum spirals, mandates, adamantine, masterwork products and a crazy cat lady!
  • NEW – Full in-game help.  Press [H] at the main menu to bring up the help/documentation.
  • CHANGE – Starting age fixed.  Dwarfs now start the game at 12 years of age (dwarven adult), instead of 1 year old.
  • CHANGE – Save files now have a .sav extension.  Old saves will need to be renamed, but are otherwise identical.
See original post for download link.
« Last Edit: September 12, 2009, 03:44:53 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.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.1, updated Sep. 13)
« Reply #22 on: September 12, 2009, 10:19:45 pm »

Version 1.1 Update
Download

Release Notes:
  • CHANGE - All output related code re-written to use PDCurses.


[EDIT]:  Reformatted the first post to make it read-able again :P
« Last Edit: September 13, 2009, 11:18:45 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.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.1, updated Sep. 13)
« Reply #23 on: September 18, 2009, 08:10:54 pm »

     Just finished work on "Snake", my first attempt at a graphical game.  See the first post for details and a download link, should be near or at the bottom.  The source is a bit of a mess at the moment, I plan to fix it up, move some of the stuff into functions, etc.  But first I need to read up on passing multi-dimensional arrays to functions, so I can pass the "field" array to all the functions that need access to the map.  I haven't gotten a chance to look for tutorials yet, but hopefully it'll come pretty quickly.
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 #24 on: September 18, 2009, 09:23:08 pm »

I was going to ask you about this... I didn't make myself some time to check the last version of it thoroughtly... wich I'll do soon... Anyway... I recall that there was some kind of waiting function that made battles a bit annoying....

I'll check the Snake game too.
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.1, updated Sep. 18)
« Reply #25 on: September 18, 2009, 09:27:43 pm »

Yeah... I'm gonna see about reworking some of it to take out a few of the irritating and unnecessary pauses... I may also look into setting up a loop that disables the default reactions for keys it doesn't understand, so that it just doesn't update or change anything until it get's one it does...
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 #26 on: September 18, 2009, 09:33:23 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.*/
}

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.1, updated Sep. 18)
« Reply #27 on: September 19, 2009, 09:24:27 am »

Thanks!!!

I've got that working, and while the code is still a little messy, at least most of it is split into smaller, more manageable functions now...

Anyways, I've touched up the Dwarf Caretaker code, and will be updating the links in just a moment... I didn't really change much as far as game play is concerned (pretty much just the combat pause fix and some invalid input handling), but there is a lot of far better commenting now...
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.

Ironhand

  • Bay Watcher
  • the llama is laughing
    • View Profile
Re: My C++ Projects (Dwarf Caretaker v1.2, updated Sep. 19)
« Reply #28 on: September 19, 2009, 12:30:01 pm »

'Operate' should be spelled with one 'p'.

Also, I think your toughness-calculating algorithm might be bugged:
After I've worked out a dozen or so times, toughness changes to "Bug!!!", and I get hungry/thirsty more quickly.
I don't think this is supposed to happen...

Otherwise, though, very nice!
Looks like it was fun to make...
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: My C++ Projects (Dwarf Caretaker v1.2, updated Sep. 19)
« Reply #29 on: September 19, 2009, 01:24:51 pm »

'Operate' should be spelled with one 'p'.

Also, I think your toughness-calculating algorithm might be bugged:
After I've worked out a dozen or so times, toughness changes to "Bug!!!", and I get hungry/thirsty more quickly.
I don't think this is supposed to happen...

Otherwise, though, very nice!
Looks like it was fun to make...

I'm on it, thanks!
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 ... 29