Damage Calculating within game...

Looking to see how the damage calculation works within a game

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 3908 Views - Last Post: 29 December 2009 - 09:29 PM Rate Topic: -----

Poll: Opinion wanted. (15 member(s) have cast votes)

Can a total new born programer(just started) make a 2D fighter game by the end of 2010?

  1. Yes (5 votes [33.33%])

    Percentage of vote: 33.33%

  2. No (5 votes [33.33%])

    Percentage of vote: 33.33%

  3. If you find more people to help, then yes (1 votes [6.67%])

    Percentage of vote: 6.67%

  4. Don't know, but i wish u luck. (4 votes [26.67%])

    Percentage of vote: 26.67%

Vote Guests cannot vote

#1 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Damage Calculating within game...

Post icon  Posted 27 December 2009 - 10:08 PM

Ok my question is, how does damage calculation work within the C++ enviroment? cuz im trying to make a 2D fighter, while im here putting ideas down on functions i want, i was thinking about damage calculation, an the life bar. thought for my first beta im only using number as life(show a number for each players life depending on character, example, big character has 800 hit points available and small but fast character has 500 hit points), but anyways, how would the code be if lets say i want the low punch to take only 3% off the hit points?(im doing this by % since i feel more comfortable with it^^) but im also thinking of having each character a diferent value for each hit, for example, the big guy would do 7% low damage and 12% high damage, will this be a hell of a work for a one man team? ahhh, im still reading the books but taking breaks to put more ideas into my little book, so i wanna have clarify if i should think over the things an make it more simple for my first game or continue on this road an really have a huge challenge for me...^^ thanks b4 hand for any help

This post has been edited by TygerX7: 28 December 2009 - 12:43 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Damage Calculating within game...

#2 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,585
  • Joined: 27-December 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 02:00 PM

If you're new to C++, then you might want to cover the basics of Object-Oriented Programming before tackling this project. Make sure you understand class design and interaction first, then get the logic working in a text-based environment. Really, once you understand the basics of OOP, the logic will come fairly easily. After you get this part working, then consider pursuing the 2D graphics. It's a big task for a new programmer, and it's important you get the basics down before pursuing more advanced concepts. Good luck! :)
Was This Post Helpful? 0
  • +
  • -

#3 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Re: Damage Calculating within game...

Posted 28 December 2009 - 02:08 PM

thanks an i am reading the basics in a book called, LEarning C++, 600 pages T.T, but for now the book has just explained what short, unsigned short an the other 11 data types are, soon it will be objective types, but the main purpose of the book is to build a DOS running program to calculate the final grade of some university courses, dont know if that will help me in the end, but it sure teaching me the basic of everything, but i ask u this, after this book, what book would u recomend for me learing to create a game? cuz 2D fighter is my baby, but i know i have to start other small easier projects to get a good feel about how the game creation works, cuz first, i think a over top shooter like galaga might be a good start, simple, just a back ground, same enemy ship, an the animation of them exploding and my ship and its animation of exploding. then if i manage to do that, i will move to a platform type of game(mario), ofcourse all this will have just one lvl to test my skills, but i have a book my friend finished an sent it to me by mail, Game programing for teens, using visual basic 6 and Direct X, for what i read about it, its for making an RPG... so u think that book would be good read after i learn the basics with the book im on now? sorry for asking so much, but i like to be prepared and make blue prints of things i will need for anything i will do ^^ im not a boyscout, but im hell prepared for everything haahaha
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,585
  • Joined: 27-December 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 02:24 PM

2D games and animation are a ways off if you are only at the basic datatypes. The grade calculator is a good excercise, but it doesn't really lead into 2D graphics. Be patient and get the basics first (after getting a good handle on OOP & data structures), then move onto the 2D graphics.
Was This Post Helpful? 0
  • +
  • -

#5 WolfCoder  Icon User is offline

  • Isn't a volcano just an angry hill?
  • member icon


Reputation: 781
  • View blog
  • Posts: 7,604
  • Joined: 05-May 05

Re: Damage Calculating within game...

Posted 28 December 2009 - 02:30 PM

You can write games in just C fine. Especially 2D fighters. The more important things to learn is the graphics, sounds, etc. for a video game.
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5641
  • View blog
  • Posts: 12,359
  • Joined: 16-October 07

Re: Damage Calculating within game...

Posted 28 December 2009 - 03:58 PM

Not to be cruel, but I said no. There are a number of elements in such a project above and beyond simply knowing how to write a computer program. If you don't have that yet, you're not even close.

Goals are good. Plan to write your 2D fighter game. I'm sure you can, if you work on it. However, it's not something you'll get done in a few days.

You have a big ole book on computer programming? Good. Work your way through it. Don't worry about how this will further your long term goal, just learn what the book has to offer. Solve the little problems you feel you're up to. Read this site and try to solve other people's problems.

At some point you'll feel confident enough in the basics to start your game. You'll be wrong, but you'll know enough to figure out where you're wrong.

You will not get to your goal as quickly as you want to ( omg, now, now, now! ). You will learn what you need to get there. When you write your next game, your time table will almost certainly be much shorter.

Good luck.
Was This Post Helpful? 0
  • +
  • -

#7 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Re: Damage Calculating within game...

Posted 28 December 2009 - 04:51 PM

baavgai, dont worry about the no hahahaha, i was expecting more no's than anythign else, an i know i wont get it now hahaha, my goal is for a year from now, atleast a beta, but that can change, i might change to a platform, but that depends on my feeling of testing myself, an wolfcoder, love the sig, the right corner is puyo puyo right? but anyways, i know about the sound an all that, but for now, im just thinking about the mechanics, i know sound an graphic are very important, but most people just do huge awesome graphic an forget the mechanic, an i want to make a game that focus on the mechanic but leaving enough room for the graphic to look decent enough, i know it wont be easy, i know it wont be fast, i know i might not even have a beta in a year an just start to code it in a year, but aslong as i see my goal, i wont give up on it... n i will probably try to gather a few other people to help me with full credit on the project, but about a team i wont worry, since first i need to learn to defend my self an not be a total weight on them, cuz my vision is more of director type, but i hate sitting around ordering people... so i like to help an put everything i can into the things.




oh b4 i forget, i still havent gotten an answer about how does it work, i know i will learn it in the future, but i would like to know how it would work in C++... why C++ cuz i have read that it gives u full an total control over everything in the program, an i dont like having premade stuff, if i cant break it, an rebuild it my way, i wont be happy with it, same thing goes for my desk, laptop and other stuff around me, i need to costomize it for myself or i wont be happy hahahhahaha.... so i love video games an i always found something to improve in a game, i know my game will have its flaws an even with the best team in the world, the game will have a few flaws an missing some stuff, because to create a perfect game, it would need everything to be perfect. speed, features, mechanics, combos, story, sound, graphic, loading... an bunch more... but i will try my best to have a decent balance for the final project, be it in a year or 3... but really, i wanna know how the damage calculation works, how would the code be, an can i use percentage in a c++ code or should i take out the percentage on my own an put that direct number in the c++? but i think it be hard because like i said, the chracters varie from big an strong to small light an fast, so if i little guy hits the big one, he only does 2% damage normal hit, but if he hits a average player, he does 4% damage, an fighting his own size would be 5%... yea...

This post has been edited by TygerX7: 28 December 2009 - 04:59 PM

Was This Post Helpful? 0
  • +
  • -

#8 DoubleFission  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 223
  • Joined: 20-September 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 05:13 PM

Damage Calculation works however YOU want it to work because you'll be the one doing the code...

However I personally suggest not using percentages for damage, mainly because it can lead to bugs where you can't actually get the opponent's HP to zero.

Eg.

I have a punch that does 50% damage, I have an opponent that has 200 HP.

I punch them, they loose 50% of 200... 100 HP left
I punch them again, they loose 50% of 100... 50 HP left
I punch them a third time, they loose 50% of 50... 25 HP left
...

Each punch does 50% less damage than the one before it, you'd have to have the code so that each attack does some percentage of the opponent's maximum health, which means your attacks will me MORE effective against stronger opponents.

Eg.

Your punch does 3% damage:
Against an opponent with 500 HP, the punch does 15 damage
Against an opponent with 800 HP, the punch does 24 damage
...

And that just doesn't make sense.

I suggest using solid values with modifiers based on the character.

Say a base damage of 5, but bigger and stronger characters get up to another 5 added on allowing them do to up to 10 damage.

But however you code it into your game is how it works, there is no right and wrong...

Just smart, and not so smart ways of doing things...
Was This Post Helpful? 1
  • +
  • -

#9 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Re: Damage Calculating within game...

Posted 28 December 2009 - 05:37 PM

ok, i didnt think about the percentage the way u did, i was thinking it will always take 3% of the main HP so it will always be 3% of 800, so it be 24 each hit, so a combo a 3 weak punch would be 72. but i do see the problem with the 500 and 800, but i think i mentioned,(checking)...nope, i guess i didnt explain it like i wanted, for player1 ..

player1
HP - 400
Low punch (against normal opponent) is 4%
(against big opponent) is 2%

but i still dont know maybe ur write, an i should put the percentage in my notebook an in the program i will put the solid number. but one question, it would be a "cont" number since its a value that wont change? ask cuz i was just reviewing that chapter about variables that dont change...
Was This Post Helpful? 0
  • +
  • -

#10 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 942
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 06:42 PM

I voted Yes, if you have help. Writing games usually reqires more than just one person. Not every programmer has all of the skills required to make a complete game. For example, I have to the technical skills to write many complex programs, games included, but there are things when it comes to games that I struggle with. For example, I have no real artistic skill or music skill. When it comes to those two areas I`m pretty much clueless. That doesn`t mean that if I had the game assets I couldn`t make a complete game, those are just two areas that I have problems with.

There are many other things that you will need to work on when it comes to game programming. The big one is game design. There is a big difference between programming a game and designing a game. I`ve seen many games fail because the design of the game was terrible. There are a lot of things that you need to work on with game design. Two important areas keeping the game balanced and keeping the game fun. If your game is too easy the player will get bored and will not want to continue playing the game. Also, if the game is too hard the player will get frustrated and move to a different game. You also have to keep the fun for the player. If a game isn`t fun the player will stop playing it and move onto something else as well.

Those are just a few things that you need to think about when it comes to writing games. There are many others.
Was This Post Helpful? 0
  • +
  • -

#11 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,585
  • Joined: 27-December 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 06:43 PM

@DoubleFission: You bring up a very good point that I want to expand on. @OP: If you've ever played the Pokemon gameboy games (RBY, GSC, etc.), then this may sound familiar; but even if you don't, it should provide a good example to help you with your logic. So each Pokemon has some stats including HP, Attack (Physical), Defense (Physical), Special Attack, Special Defense, Speed, and Level. The Attack (Physical or Special) determines how much damage a particular attack does coming from that Pokemon, and each attack is either physical (tackle for instance) or special (water gun, etc.). In addition, each attack has a base value for the damage that is constant among all Pokemon. Now the damage done to the other Pokemon is dependent on these numbers as well as the Defense (physical or special depending on the type of attack) as well as type alignments. For example, if the attacked Pokemon is resistant to the element of the attack (for example, a grass type may be resistant to water), the attack may do less damage. On the flipside, if the Pokemon is of the same element as the attack or if the attack is super-effective against the attacked Pokemon (water attack vs. fire Pokemon), it may do more damage. And of course, the games have a formula to determine all this.

So these are just some things to consider when calculating damage. Really though, once you have the formula, it is as simple as keeping track of a counter variable for a given player and subtracting the damage from the HP.
Was This Post Helpful? 0
  • +
  • -

#12 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Re: Damage Calculating within game...

Posted 28 December 2009 - 06:59 PM

macos, u bring up a good game for damage calculation, i was thinking about pokemon when i was thinking about the damage, but ii never notice the use of special defense an all does SPEC attacks, so i just push there formula away, but u brought back the calculation im interested in, depending the oponent is the damage. i wont have elemental in my first game, but the size of the player an there stats should do fine, i think... ok, i was reading that a program will have tons of pages, so i can make one page for each character an in there page i can define the hitting points each moves does, but what i want to know where would i put the exchange values? like where do i define that this character does less damage to this other character, an the blocking mechanic, since that will take minimal damage, where do i define that blocking will decrese the damage... oh my, this keeps getting more exciting^^
Was This Post Helpful? 0
  • +
  • -

#13 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10180
  • View blog
  • Posts: 37,585
  • Joined: 27-December 08

Re: Damage Calculating within game...

Posted 28 December 2009 - 07:12 PM

You can define various objects like players, shields, attack enhancers, etc. with classes, which is why I strongly encourage(d) you to start with OOP before moving on to the graphics.
Was This Post Helpful? 1
  • +
  • -

#14 TygerX7  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 24-December 09

Re: Damage Calculating within game...

Posted 28 December 2009 - 07:55 PM

ok classes, nice, thats the next chapter in my book^^
this is the book im reading^^
http://www.amazon.com/Learn-Program-C-John-Smiley/dp/0072225351/ref=sr_1_1?ie=UTF8&s=books&qid=1262037022&sr=1-1


also while watching WWE RAW, i started to doodle in photoshop an in between commercial i made these two models, same guy but one is a stance an the other is high damage animation

Posted Image

This post has been edited by TygerX7: 28 December 2009 - 08:04 PM

Was This Post Helpful? 0
  • +
  • -

#15 Fib  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 161
  • View blog
  • Posts: 554
  • Joined: 12-March 09

Re: Damage Calculating within game...

Posted 29 December 2009 - 10:32 AM

Hi TygerX7,

Once you get to classes in your next chapter, Object Oriented Programming will start to make more sense.

For example, you can create a class for each character that could look something like this:

class FighterA
{
private:
	 int health, // variable to keep track of fighter's health
	 int damage; // variable to keep track of fighter's damage

public:
	 void SetHealth(int hth) {health = hth} // method that can be called to set the fighter's health
	 void DamageReceived(int dmg) {health = health - dmg}  // method that can be called to remove the figher's health when damaged
};


So as you can see, creating an object like this makes your code MUCH MUCH more understandable, easier to read, and easier to implement. There are also more advanced features of OOP such as inheritance, and polymorphism. Once you get those concepts down, you will then see the true power of OOP.

Then once you get into the mind set of creating objects, then you can create objects for virtually everything in your game.

Also, once you finish the book your currently learning from, try picking up this book:
http://www.amazon.co...n...7744&sr=8-1

This book goes through all the basics of getting a game together including programming 2D graphics, sprites, sound, collision detection, and it even has a few chapters on 3D programming plus much more. I have personally read through that book and it has helped me tremendously.

This post has been edited by Fib: 29 December 2009 - 10:36 AM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2