Attacking

Attacking

In games where collision detection is used, attacking generally falls into two general types, projectile attacks and melee attacks.

Projectile (Missile) Attacks

(Main article: projectile)

A projectile attack (sometimes called a missile attack) is where one object attacks by shooting or throwing projectiles such as bullets at the intended victim. Projectile attacks are the easiest to program because all it requires you to do, at minimum, is to create a projectile, get it moving, and detect the collision once it hits.

Melee Attacks

Melee attacks involve the character using something held or attached to it to attack with. Swords, clubs, etc, all count as melee weapons. Any physical attack using a character's body part also is considered a melee attack. Kicks, punches and head-butts are all considered melee attacks.

Ways to implement melee weapons are many, including using a mask or a collision detection function.

Death from Above

Some rather silly platform games use a "death from above" system (also known as an "ass attack") where the player object can damage an enemy object by stomping or forcefully sitting on it. The Super Mario Bros. series (except for SMB2) uses death from above.