Jump to content
  • Advertisement
  • entries
  • comments
  • views


Sign in to follow this  


With the show-stopping bug crushed I've been beavering away on jsInvaders for the past few days. It's a nice little system and seems to be pretty flexible. I've probably mentioned before that it's event-driven, so whenever something happens in the game, like the entity being spawned or updated a scripted function will be called for that entity.

The function name is based on the entity name and the event itself; so if an entity with class 'Alien' and a name of 'myAlien' was to be spawned, the game would first look for 'myAlien_OnSpawned' and then the basic 'Alien_OnSpawned' if that isn't found. This allows for a form of inheritance and per-object overrides for event handling.

Last night I spent time working on a flexible event object system. At present, the event functions are just normal functions that don't take a parameter. For simple events this is fine, but what if you need to pass a collision event? You'd need to know about the entity that has just been collided with. To counteract this I've created a ScriptedEvent class that can be used as a base for the various event types. The idea is that when this event is thrown it'll automatically create an event object for the script to consume. Rather than an 'all-in-one' solution, each script event will only have properties that correspond to the relevant game event. So 'OnSpawned' won't have any details about collisions, but 'OnCollided' will.

The basic system is working, I just need to start adding new event classes.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!