Jump to content
  • Advertisement
  • entries
    743
  • comments
    1924
  • views
    582803

Doors and switches

Sign in to follow this  
Aardvajk

154 views

As part of the "Add a feature a night" drive, here are the latest additions:



The red switch in front of the ship is activated by the player landing on it, at which point it sinks to the ground. The translucent blue blocks are doors, and when their associated switch is pressed, they alpha fade out quite nicely.

Every game object already has an integer ID field, which can be set in the level editor along with all the other object properties, so a switch just has an AffectID field, and when a switch is pressed, the virtual CItem::Activate() member is called on any current items whose ID matches the switch's AffectID.

This has the implication that one switch can open many doors. In the screen above, the switch in front of the player opens all four of the door blocks to the right, but the door block near the bottom of the screen is activated by another switch, not currently in view.

For the CDoor class, the Activate member, which does nothing in the CBasicItem class, clears the door's solidity and starts the alpha fade.

This also means though that if I add new objects that are switch activated, all I need to is override the Activate member for the new object class, then assign its ID in the level editor to be the same as the AffectID field in the switch that activates it.

I'm actually quite happy so far with how extensible the framework is proving. It was one of those things - took weeks and weeks with very little end result, then all of a sudden passed that magic point where all of a sudden features start dropping in very easily.

The entire mods to the game code to add in the switches and doors was to add two classes with probably about eight to ten lines of code each. The level editor just required changes to scheme.txt.
Sign in to follow this  


0 Comments


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!