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
Obstacle
and give a class name - Create new enum for the Obstacle in LevelInfo.ObstacleType
- Create Info class, mention the tag string in the
tag
funciton, and assign the correct type in_init
class Info extends LevelInfo.ObstacleInfo:
func _init() -> void:
type = ObstacleType.MOON
static func tag():
return ""
func load(attributes_dict: Dictionary):
super(attributes_dict)
- To create more config attributes, create variables for it in
Info
class, and specify how to parse in theload
function - Map the info class in
LevelInfo.obstacle_info_classes
Scene + DI Mapping
- Create
New Inherited Scene
ofobstacle_base.tscn
- Update the name of the root node, attach the created script, and save the scene as new
- Create new
PackedScene
variable 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
>DepClass
node - in
main.gd
create 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.