Game Development Reference
In-Depth Information
function EnemyThinker:OnUpdate(deltaMs)
print(
);
for id, actor in pairs(self._enemies) do
actor.stateMachine:ChooseBestState();
end
end
This class only has the OnUpdate() function, which loops through all the actors and
calls ChooseBestState() on their state machine, just like you saw in Chapter 19.
Running AI update for enemies
Don
'
t Cross the Streams
One alternative to the design above would be to make every AI state into a
ScriptProcess object. This would certainly work, but it would cause a lot
more traffic across the C++/Lua boundary. It
s much better to have only a
few ScriptProcess objects that do more work than to have a bunch of
ScriptProcess objects that do very little work.
'
An Exercise Left to the Reader
It may not look like it, but Teapot Wars is an excellent example of how to make a
game. I ' ve worked on a lot of projects in my career, and they all looked very much
like Teapot Wars in the early days. The excellence isn
s in the
potential. If you took this game and spent six months to a year on it, you could easily
have something to compete in the Independent Games Festival.
I get emails from budding game developers all the time asking me what they can do
to make a game. The answer to this question is simple: Make a game. You can read
every book in the world on game development, go to a school specializing in game
programming, play every game under the sun, post on every message board, and talk
to everyone about game development. None of it takes the place of actually sitting
down and making something. Conversely, don
'
t in the game itself, it
'
t bite off more than you can chew.
Games take a long time to make, even simple ones. Start really simply (like Teapot
Wars) and build from that.
To use a video game analogy, making games is a lot like leveling up in Ultima VII.In
Ultima VII, you would gain experience by killing monsters, which would cause you
to level up. Leveling up didn ' t do anything except give you training points; you ' d
have to find a trainer to spend those training points and make your character better.
Visiting a trainer is useless without the experience to back it up, and gaining experi-
ence isn
'
'
t productive without the benefits of a trainer.
 
 
Search WWH ::




Custom Search