Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 3:04 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Knockback logic?
PostPosted: Thu Mar 01, 2012 3:19 am 
Offline

Joined: Thu Jan 26, 2012 5:40 pm
Posts: 79
I'm having some trouble trying to cause knockback when a player or enemy is hit (based on the direction the attacker is facing). I'm using MarteEngine for the entity framework. Think of a SNES Zelda-like action RPG.

I have a player entity, an attack entity, and an enemy entity. The only way I can tell would work is to make 4 different entities for my attack entities, one for each direction. I don't really want to do this because I am going to have many different attacks.

Here's what I have in my enemy class's update method, for example:
Code:
      if(collide("attack", x, y) != null) {
         addDamage(25);
      }


How should I accomplish this without making different directional attack entities?


Top
 Profile  
 
 Post subject: Re: Knockback logic?
PostPosted: Thu Mar 01, 2012 1:53 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
You could use/calculate the center coordinates of your entities to find out from which direction the attack happened.
This way you could have one attack entity and solve attacks from all directions.

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group