2D enemies in numerous rooms.

Blitz3D Forums/Blitz3D Beginners Area/2D enemies in numerous rooms.

Tobo(Posted 2012) [#1]
Dear all,

May I ask the enlightened how they would go about planning a game that has many rooms and individual enemies that each have their own room? (if you remember JetSetWilly then you know what I'm after).

I can't quite get my head around how to cater for 50+ enemies each with their own screen and path to follow, and the collision detection for different rooms/screens layouts.

Vague I know.

Any pointers?


Kryzon(Posted 2012) [#2]
But you're not going to cater for 50+ enemies and rooms at the same time. You only have to worry about the current room being played. You shouldn't update game elements that reside at other rooms.

Every time the player changes room, you...
• Clear the current room and all of its elements (enemies, props and platforms);
• Read somewhere (blitz Data statement, text file, pre-loaded data etc.) on what are the classes and locations of enemies, props and platforms (and other properties such as player spawn position, the type of screen transition to display etc.) that need to be at this new room;
• Create each of these elements according to the room's specification;
• Each of these elements has its own logic\behavior associated with it, so after the layout is complete, your game engine will take care of updating them appropriately until the game changes to a different room.
Events that cause the room to be changed can be: game start, in-game player teleport, player death, player success etc. All these events should call the same "ChangeToRoom()" function with an appropriate room number to change to. This function takes care of all these steps I mentioned.
Starting the game is an example of changing to a room - you'd be changing from 'Null room' to room '1'.

Everything is 'generic', it's just the layout that changes as you move to a new room.
Some kinds of enemies, props or platforms will only appear at specific rooms - like a boss character for instance. You have already coded his logic and tested him appropriately at a debug room to tweak things and make his behavior fun for the player.
Once the player reaches one of the rooms that need this boss character placed at a specific location, your game engine takes care of creating a copy (or more) of him for you, placing him at that location and updating him with the behavior you programmed.

Last edited 2012