Skip to main content

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

  1. Create a new script for the obstacle, extend it with Obstacle and give a class name
  2. Create new const for the Obstacle in ObstacleType
  3. Create Info class, mention the tag string in the tag funciton, and assign the correct type in _init
class Info extends LevelInfo.ObstacleInfo:<ur_base_obstacle_class>.Info:
    func _init() -> void:
        type = ObstacleType.MOON<ur_type>

    static func tag():
        return ""

    func load(attributes_dict: Dictionary):
        super(attributes_dict)

  1. To create more config attributes, create variables for it in Info class, and specify how to parse in the load function
  2. Map the info class in ObstacleType.info_class_mapping

Scene + DI Mapping

  1. Create New Inherited Scene of obstacle_base.tscn
  2. Update the name of the root node, attach the created script, and save the scene as new
  3. Create new PackedScene variable in dep_class_mapping.gd
  4. create a mapping for you new class with this variable in dep_class_to_scene_mapping
  5. attach the new scene you created in mappings.tscn > DepClass node
  6. 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.