Coding update components
As you might expect by now, we will code an UpdateComponent
class that will inherit from the Component
class. It will have all the functionality that every UpdateComponent
will need and then we will code classes derived from UpdateComponent
. These will contain functionality specific to individual objects in the game. For this game, we will have BulletUpdateComponent
, InvaderUpdateComponent
, and PlayerUpdateComponent
. When you work on your own project and you want an object in the game that behaves in a specific unique manner, just code a new update-based component for it and you'll be good-to-go. Update-based components define behavior.
Coding the UpdateComponent class
Create a new header file in the Header Files/GameObjects
filter called UpdateComponent.h
and add the following code:
#pragma once #include "Component.h" class UpdateComponent : public Component { private: string m_Type = "update"; ...