Class Based Enemies
In my first game Nasty, all enemies have their own name and there is no good way to group them together. Some of them (for instance the blue ghosts and the green and red ghosts) share some logic, but they are really entirely different entities.
For my next game, I have decided to create different customizable classes of enemies with every enemy belonging to a class. This way I can create a class of enemies (for instance soldiers) that have a specific set of behaviors that can be used for multiple enemies. I can easily create multiple enemies that appear to the user as different enemies but really share the exact same logic. They'll even be able to share the exact same animation/drawing logic but pass in different textures to use.
Here is an example of how that might work (these are completely arbitrary numbers right now FYI):
Crazy Farmer (soldier class)
Speed = 100
Patrol Range = 300
Shot rate = 10
Detection Range = 400
Health = 50
Army Man (soldier class)
Speed = 150
Patrol Range = 600
Shot rate = 50
Detection Range = 1000
Health = 150
The Crazy Farmer and the Army Man will both walk back and forth on the level and use the same animations (with different textures), but the Army Man will patrol a larger area and shoot at the player from further out because of the different values assigned to him. He will also be harder to kill due to more health and a quicker speed.
Reusing code is a very good thing to do. This will significantly reduce the amount of debugging I have to do and increase the number of enemies that my next game can have. I have not settled on how customizable I'd like these enemies to be just yet, but I aim to make them customizable enough that to the end user (gamer), they seem like completely different beasts.
/tds/go.php?si
This article has been view 410 times.
|