News:

11 March 2016 - Forum Rules

Main Menu

Battle System created by me.

Started by InfamousKnight, July 28, 2012, 06:12:34 PM

Previous topic - Next topic

InfamousKnight

I made this without any help. You have 3 allies and 2 enemies. The enemies are fairly easy since the battle I provided doesn't take much strategy.

http://pastebin.com/Dcs8dARC

Make sure you have negative strenght values for damage then positive values for healing. Yeah, I plan on combining this with my other projects. It'll be a huge source file!

I updated the code:

http://pastebin.com/eU3mK2Pj

Klarth

May I suggest creating an array of structs that contains all ability names, function pointers to a damage calculation function, so you can clean up your battle loop?  Also, you don't need to seed your random number generator before every time you use it, just once at the start.  Looks like you have a good start, but if you want to make the game more complex, you really need to refactor your code to be more organized.

Rhys

Seeding all depends on how random you want your numbers, if the random function is good then it usually ends up using crypto routines to take care of ensuring your numbers are random, a lot of the simpler functions however just base it off of some math done with the current timestamp, and in those cases you'll definitely want to generate a new seed after each use, .NET's Random class is one example of this.

LostTemplar

Quote from: Klarth on July 28, 2012, 07:42:16 PM
May I suggest creating an array of structs that contains all ability names, function pointers to a damage calculation function, so you can clean up your battle loop?

Or just polymorphic classes, as he is using C++ anyway.

Rhys

C++ Polymorphism gives me nightmares :(

Ryusui

#5
It's simple enough, really.

In game development, you might have a "Game Object" class with a function called "Update" which handles everything a given object needs to do on a given frame. The game's main loop calls "Update" on every single Game Object (or, if we're clever, just the ones on screen), but the twist is that we don't actually use the base Game Object class - we use derived classes, like "Player" or "Bullet" or "Powerup" or "Enemy," which override "Update" in their own specific ways. When you tell a Player to Update, it might read the controller/keyboard input and move accordingly; when you tell an Enemy to Update, it might follow its AI instead. The point, however, is that each of these objects can be treated as a "Game Object" by the rest of the program; they feature the same functions, even if what those functions actually do is different.
In the event of a firestorm, the salad bar will remain open.

Rhys

The problem with C++ Polymorphism is STL containers become completely useless, if you want to store derived types you're in for a world of hurt

Trax

Polymorphism is a lot easier (and intuitive) with Objective-C...

InfamousKnight

Quote from: Ryusui on July 29, 2012, 03:38:19 PM
It's simple enough, really.

In game development, you might have a "Game Object" class with a function called "Update" which handles everything a given object needs to do on a given frame. The game's main loop calls "Update" on every single Game Object (or, if we're clever, just the ones on screen), but the twist is that we don't actually use the base Game Object class - we use derived classes, like "Player" or "Bullet" or "Powerup" or "Enemy," which override "Update" in their own specific ways. When you tell a Player to Update, it might read the controller/keyboard input and move accordingly; when you tell an Enemy to Update, it might follow its AI instead. The point, however, is that each of these objects can be treated as a "Game Object" by the rest of the program; they feature the same functions, even if what those functions actually do is different.

With controller/keyboard input, it would be hard to wait for input when its the allies turn. I tried it in VB and no luck. I don't have much experience with SDL but I should learn it. In-fact, I can't do anything interesting with SDL with my little knowledge on it. I could use windows.h but I'm running lubuntu at the moment and I don't feel like going back to windows. I would like some graphics in this game.

Would anyone like to add graphics to this game? Its your choice. I would highly appreciate it though. You don't have to draw the sprites either. use videogamesprites.net for that.

InfamousKnight

Sorry about the double post: OP updated.