2 Replies - 337 Views - Last Post: 23 January 2012 - 04:10 PM Rate Topic: -----

Topic Sponsor:

#1 tox_von  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 04-January 12

Collision Events

Posted 23 January 2012 - 02:48 PM

How are collision events done in c++? Eg if sword hits enemy enemy dies. If player hits spikes he bounces back and takes damage.I think it has something to do with the two x,y cords being the same when specific events happen. Are there any examples anywhere.
Is This A Good Question/Topic? 0
  • +

Replies To: Collision Events

#2 The Adrian  Icon User is offline

  • New D.I.C Head

Reputation: 10
  • View blog
  • Posts: 31
  • Joined: 09-January 12

Re: Collision Events

Posted 23 January 2012 - 03:19 PM

Well a way that you could handle it is you have two collidable objects to start with (of course). I know one way it's done is when something attacks, a collidable rod is created at the attackers center pointing in the direction of the attack. Then, if that rod is colliding with anything other than the attacker, deal damage if that is an enemy and kill if the health is low

In order to do something like this, you should have a good physics engine and it needs to give lots of information about what happened like what two objects were involved in the collision etc.
Was This Post Helpful? 0
  • +
  • -

#3 ButchDean  Icon User is offline

  • Pro Games Programmer
  • member icon


Reputation: 689
  • View blog
  • Posts: 2,504
  • Joined: 26-November 10

Re: Collision Events

Posted 23 January 2012 - 04:10 PM

First you need to establish what a collision is, and common methods are bounding box/sphere collisions - this will tell you if you hit an object. To these bounding shapes you apply attributes to determine what they are.

When a collision occurs between shapes with certain attributes you trigger a new action and/or state.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1