Game Development Reference
In-Depth Information
Now it becomes easy to see how valuable a simple canvas abstraction can be when
using more advanced rendering techniques. In most cases, even if we're just render-
ing on a single canvas, being able to encapsulate all the loose variables associated
with a canvas often makes things more efficient, especially when you need to pass
the canvas and the canvas context around to other functions and classes.
EnemyManager.js
Since the player of our game will only control a single entity throughout the entire
game, creating an instance of the entity class and letting the player control that entity
is trivial. The challenge is finding a way to create enemy entities, move them around,
and manage them as the game progresses. To solve this problem, we create an
EnemyManager class, whose job is to create enemy entities when needed and man-
age their existence.
While this may seem like a complex task, it becomes more manageable if we break
down the task into smaller pieces. The responsibilities that the EnemyManager class
Search WWH ::




Custom Search