Hi !
Featured games (87)
games approved by the League of Dukes
Games in Showcase (670)
Games in Android Showcase (194)
games submitted by our members
Games in WIP (727)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: Simple melee attacks, looking for advice on: 2012-10-19 07:28:51
You can save a list of damaged entities in your attack instance. If enemy is already in list, do not damage it again.
You can save a list of damaged entities in your attack instance. If enemy is already in list, do not damage it again.
This. A HashSet can be used for it.

That's great! Thank you guys so much. I didn't think to create an instance of the attack. Rather, my attack consisted of a box that followed the player around and a player state that determined whether to check for objects within the box. Now I feel silly.
2  Game Development / Game Mechanics / Re: Simple melee attacks, looking for advice on: 2012-10-18 15:44:23
I'll elaborate with an example scenario.

My designer decides to give the player a slashing sword attack that can definitely hit multiple enemies. He sets the hit box of this attack so that it will hit anything in front of the player, where the sword will swing. It takes one full second for the sword to go from the initial position to the end of the swing.

The player is testing this, and two enemies are in front of him. One of the enemies is already within the hit box, and the other is fast approaching. So the player hits the attack button, and the sword swings. The second enemy steps into the hit box while the sword is swinging, exactly .5 sec after the attack is initiated. The pixels of the sword make clear contact with both enemies.

Currently, here is what happens: The game logic is updated at 60 frames per second. The first enemy, who was within the hit box for the entire length of the attack, is damaged 60 times. The second enemy, who is only present for half of the attack, is damaged 30 times. These numbers might be off, but that is essentially what happens.

Ideally, I would like to damage each enemy only once.

But I'd just clear the player attack hit frame once every intersecting object has been damaged

This is attractive to me, but in my example scenario the second enemy would not be damaged. Perhaps that is correct, and an enemy should not be damaged if they were not in range at the exact moment the attack begins. But visually, the player still sees the sword make contact.
3  Game Development / Game Mechanics / Simple melee attacks, looking for advice on: 2012-10-18 15:11:13
I have run into a problem calculating attacks.
If the player is attacking and an object intersects his attack hit box, I call the damage() function of the object.
Problem is, this happens every loop, and the object is damaged several times during a single attack animation.

I searched the forums for a solution, but I didn't find anything. My ideas:
  • I thought I might end the attack after causing damage once, but that makes cleaving attacks impossible.
  • I thought of "tagging" the enemy as damaged, and testing for this before applying more damage, but I would have to reset each object between attack animations.
  • My best idea is to use a timer, allowing damage() to be called only so often, so there is a recovery period after being attacked, during which the object cannot take damage. Problem is, the recovery period cannot be shorter than the animation. If it is too short, the attack will still hit multiple times. If it is too long, the next attack might not cause damage. I don't want to use a set animation length. Maybe I can pass the animation length to the object when it is damaged...

Any thoughts? How do you handle this kind of attack?
Pages: [1]
IanParcs (35 views)
2016-04-18 14:18:53

KaiHH (35 views)
2016-04-18 08:35:41

KaiHH (66 views)
2016-04-15 12:43:58

theagentd (64 views)
2016-04-14 02:16:17

theagentd (72 views)
2016-04-14 02:15:43

IanParcs (66 views)
2016-04-12 03:51:16

IanParcs (36 views)
2016-04-12 03:50:03

IanParcs (32 views)
2016-04-12 03:49:54

IanParcs (28 views)
2016-04-12 03:49:52

IanParcs (36 views)
2016-04-12 03:49:52
Website offering 3D Models specifically for games for free
by vusman
2016-04-29 12:56:17

List of Learning Resources
by SilverTiger
2016-02-05 09:39:47

List of Learning Resources
by SilverTiger
2016-02-05 09:38:38

List of Learning Resources
by SilverTiger
2016-02-05 09:35:50

Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!