Creating new Obstacles
Obstacles are objects in the game which can be shot at by the ship by typing a word mentioned on them. You can create new obstacles by following steps
This Document shows steps to create the boilerplate for a new obstacle.
Config
- Create a new script for the obstacle, extend it with
Obstacleand give a class name - Create new const for the Obstacle in
ObstacleType - Create Info class, mention the tag string in the
tagfunciton, and assign the correct type in_init
class Info extends <ur_base_obstacle_class>.Info:
func _init() -> void:
type = ObstacleType.<ur_type>
static func tag():
return ""
func load(attributes_dict: Dictionary):
super(attributes_dict)
- To create more config attributes, create variables for it in
Infoclass, and specify how to parse in theloadfunction - Map the info class in
ObstacleType.info_class_mapping
Scene + DI Mapping
- Create
New Inherited Sceneofobstacle_base.tscn - Update the name of the root node, attach the created script, and save the scene as new
- Create new
PackedScenevariable indep_class_mapping.gd - create a mapping for you new class with this variable in
dep_class_to_scene_mapping - attach the new scene you created in
mappings.tscn>DepClassnode - in
main.gdcreate a new mapping
DI.bind(<OBSTACLE_NAME>, <YOUR_CLASS_NAME>, DI.As.SCENE_INSTANCE).to(Obstacle, LevelInfo.ObstacleType.<YOUR_OBSTACLE_TYPE>)
Thats it, now you can make any changes you want in the scene and script you create, for your obstacle. To spawn it, edit level config to spawn your own obstacle using the tag name you provided.
No Comments