Dev C++ Fighting Game

 
Dev C++ Fighting Game 3,7/5 8153 reviews

Every function in Game, except for play, should be private. Game should contain a player as a data member and instantiated in Game 's constructor. If you end up implementing your map idea (or anything similar), that would be instantiated in the constructor as well. Learn typed code through a programming game. Learn Python, JavaScript, and HTML as you solve puzzles and learn to make your own coding games and websites.

Hey everyone,

I'm still tweaking the attributes but here is what I've got:

All races: dmg = rand, where 0 < r < str

Human
25% chance of blocking
5% chance of double attack (attack x2)
10% chance of dmg+60

Elf
5% chance of blocking
35% chance of double attack

Balrog
35% chance of attacking twice

Cyberdemon
35% chance of blocking


Balrog and Cyberdemon are inherited from Demon; all objects of class Demon have a 10% chance of inflicting dmg+50.

My code (very few comments so far, sorry):

Dev C++ Game Code

main() only tests a fight between Hume vs Elf and Hume vs Balrog for now (Hume is way overpowerful, oops).

My problem is this:
Every run of the program produces the same results. Same damage, same blocks, same double attacks, same winners, everything. I thought rand() was supposed to randomize the outcome in this situation? What am I doing wrong?

Thanks for any help!

  • 3 Contributors
  • forum 6 Replies
  • 111 Views
  • 9 Hours Discussion Span
  • commentLatest Postby MoucheLatest Post

WaltP2,905

My code (very few comments so far, sorry):

Why do people apologise for doing bad things rather than just doing what they know they should? :icon_confused:

My problem is this:
Every run of the program produces the same results. Same damage, same blocks, same double attacks, same winners, everything. I thought rand() was supposed to randomize the outcome in this situation? What am I doing wrong?

Not wanting to waste time looking through 400+ lines of code for that 1 wayward statement, all I can suggest without you being more specific is that srand() should only be called once at the beginning of the program.

Dev C++ Fighting Games

If this doesn't help, give us a clue as to what to look at.