Flash Game Example

Target Closest Enemy MovieClip

Wednesday, January 21st, 2009 | Game Engine, Game Examples AS2 | 5 Comments

I’ve been thinking about how targeting the closest enemy would work and started experimenting with the algorithm. Basically AS has an array method called sortOn, that sorts objects properties in any order you want. Well, that’s the catch. It only sorts objects, not movieClips.

The work around is simple enough; when creating a new enemy object, just save a reference to the movieClip on stage inside the object’s property.

Preview

Download Fla Sample

Download Fla Sample

Tags: , , , , , , , , , , ,

Simple Enemy Random Movement

Sunday, December 14th, 2008 | Enemy AI, Game Examples AS2 | No Comments

Here is a simple AS2 enemy creation/ai script that allows you to create enemies that move about randomly inside a container movieclip. You can set custom movement boundaries/borders. When an enemy hits the border, it will “bounce off” and move in the opposite direction.

Random Movement Example

Download Fla Sample

Download Fla Sample

Tags: , , , , , , , , , , , , , , , , ,

Weapons - Shooting Projectile Bullets v1.1

Thursday, October 30th, 2008 | Game Examples AS2, Game Weapons | 2 Comments

This script shows you how to shoot projectile bullets from the player movieclip towards the mouse x & y position.

Easy to use game weapon engine. Flash ActionScript 2.0.

Shooting Projectile Bullets Game Example

Download Fla Sample

Download Fla Sample

Customizable Game Weapon Settings

  • Bullet Offset - This set the accuracy of the bullet
  • Bullet Life Timer -  This sets the life span of the bullet based on frame rate
  • Bullet Speed - This sets the speed of the bullet
  • Reload Speed - This sets the reload speed of the weapon

Big Fix - 12.15.08
Fixed a bug where bullet offset was effecting the bullet starting position.

Update - 6.16.09
A new and improved version of this script is available here.
› Continue reading

Tags: , , , , , , , , , , , , ,