Skip to content

Popochiu

Carenalga edited this page Feb 7, 2023 · 4 revisions

IMPORTANT: This are not all the properties and methods for this class. I'm showing the most important ones while I manage to work on something that makes the documentation process easier 🍑 . That, and maybe some things will change in the coming weeks 😊 .

Description

This is the system main class, and is in charge of making the game to work. Is the shortcut for Popochiu.gd, and can be used (from any script) with E (E.g. E.goto_room('Cave')).

Some things you can do with it:

  • Change to another room.
  • Access the main camera and some game settings.
  • Run commands sequentialy (even in a form that makes the skippable).
  • Use some utility methods (such as making a function of yours able to be in a run queue).

Examples

E.current_room # The PopochiuRoom that is currently open.
E.run(['Player: Hi', '...']) # Makes the PC say "Hi" and then waits for one second.
E.shake_camera({strength = 8, duration = 12})
E.text_speed_idx # The current dialog text speed

Properties

Public

  • clicked PopochiuClickable. The last clicked node of type PopochiuClickable (e.g. a PopochiuCharacter, a PopochiuProp, etc.).
  • current_room PopochiuRoom. The room that is currently opened (on screen).
  • cutscene_skipped bool. If true, the current cutscene was skipped (done with popochiu-skip (Escape in the InputMap)).
  • half_height float. The half height of the game's viewport.
  • half_width float. The half width of the game's viewport.
  • height float. The height (in pixels) of the game's viewport.
  • history Array. Array of Dictionary that stores information about the actions done by players.
    # An example of how the history may look. Last actions go first.
    [
      {"character": "Manny", "text": "That's where I keep my suit and my scythe."},
      {"action": "Looked at: FileCabinet"},
      {"character": "Manny", "text": "Hi. My name is Calavera, Manny Calavera"}
    ]
  • in_run bool. If true, Popochiu is busy excecuting queue commands.
  • rooms_states Dictionary. Stores the state of all rooms. Each room is stored by its script_name as the unique key.
    # The PC started in Office, then moved to Garage, and then went back to Office.
    {
      "Office": {
        "visited": true,
        "visited_first_time": false,
        "visited_times": 2
      },
      "Garage": {
        "visited": true,
        "visited_first_time": true,
        "visited_times": 1
      },
    }
  • width float. The width (in pixels) of the game's viewport.

Methods

Public

  • camera_offset( Vector2 offset = Vector2.ZERO, bool is_in_queue = true ) void

    Changes the main camera's offset (useful when zooming the camera). If you want to use it outside a run, send is_in_queue as false. Can be yield.

  • camera_shake( float strength = 1.0, float duration = 1.0, bool is_in_queue = true ) void

    Makes the camera shake with strength for duration seconds. If you want to use it outside a run, send is_in_queue as false. Can be yield.

  • camera_zoom( Vector2 target = Vector2.ONE, float duration = 1.0, bool is_in_queue = true ) void

    Changes the camera zoom. If target is larger than Vector2(1, 1) the camera will zoom out, smaller values make it zoom in. The effect will last duration seconds. If you want to use it outside a run, send is_in_queue as false. Can be yield.

    E.run([
      # Offset the camera before it zooms in so dialogs are shown inside the viewport
      E.camera_offset(Vector2(0.0, -16.0)),
      E.camera_zoom(Vector2.ONE * 0.5, 0.5),
      'Player: Oh, oh.',
      # Restore the camera's offset to its default value before zooming out
      E.camera_offset(),
      E.camera_zoom(Vector2.ONE, 0.5)
    ])
  • goto_room( String script_name, bool use_transition = true ) void

    Loads the room with script_name. use_transition can be used to trigger a fade out animation before loading the room, and a fade in animation once it is ready.

  • play_transition( int type, float duration, [bool](https://docs.godotengine.org/en/stable/classes/class_bool.html) is_in_queue = true` ) void

    Plays the transition type animation in TransitionLayer.tscn that last duration in seconds. Possible type values can be found in TransitionLayer (TransitionLayer.gd).

    E.run([
      E.play_transition(TransitionLayer.PASS_DOWN_IN, 0.5),
      '...',
      E.play_transition(TransitionLayer.PASS_DOWN_OUT, 0.5),
      'Player: What was that?',
    ])

    E play_transition

  • room_exists( String script_name ) bool:

    Checks if the room with script_name exists in the array of rooms of Popochiu.

  • run( Array instructions, bool show_gi = true ) void

    Executes a series of instructions one by one. show_gi determines if the Graphic Interface will appear once all instructions have ran. Can be yield.

    When characters talk, it will continue to the next instruction after players click the screen anywhere (unless automatic text continue is enabled).

    yield(E.run([
      'Player: Hi',
      '...',
      C.player.face_right(),
    ]), 'completed')
    prints('This will appear once all the instructions have run')
  • run_cutscene( Array instructions ) void

    Excecutes a series of instructions one by one than can be skipped. When skipped, it triggers a transition animation to give players feedback.

    Popochiu uses the popochiu-skip (Escape by default) in the InputMap to skip cutscenes.

  • runnable( Node node, String method, Array params = [], String yield_signal = '' ) void

    Makes a method in node to be able to be used in a run call. Method parameters can be passed with params, and yield_signal is the signal that will notify the function has been completed (so run can continue with the next command in the queue).

    If 'func_comp' is passed as yield_signal, then it will wait method to complete.

    # run pauses until the $AnimationPlayer 'animation_finished' signal is emitted
    E.run([
      'Player: Ok. This is a runnable example',
      E.runnable($AnimationPlayer, 'play', ['glottis_appears'], 'animation_finished'),
      'Glottis: Hi Manny!',
      "Player: You're finally hear..."
    ])
    # run pauses until _make_glottis_appear 'completed' signal is emitted
    func _ready() -> void:
      E.run([
        'Player: Ok. This is another runnable example',
        E.runnable(self, '_make_glottis_appear', [], 'func_comp'),
        'Glottis: Hi Manny!',
        "Player: So... you're finally hear...",
      ])
    
    func _make_glottis_appear() -> void:
      $AnimationPlayer.play('make_glottis_appear')
      yield($AnimationPlayer, 'animation_finished')
      Globals.glottis_appeared = true
      yield(get_tree().create_timer(3.0), 'timeout')
    # run pauses until $GI 'clicked' signal is emitted
    # ---- In some prop ----
    func on_interact() -> void:
      E.run([
        C.walk_to_clicked(),
        'Player: Ok. This is the last runnable example.',
        'Player: Promise!',
        E.runnable($GI, '_show_button', [], 'clicked'),
        'Player: What was that!?',
      ])
    
    # ---- In the $GI node ----
    func _show_button() -> void:
      $BtnPlay.show()
    
    func _on_BtnPlay_pressed() -> void:
      A.play_music('mx_mysterious_place', false)
      emit_signal('clicked')
  • wait( float time = 1.0, bool is_in_queue = true ) void

    Creates a delay timer that will last time seconds. If you want to use it outside a run, send is_in_queue as false. Can be yield.

    E.run([
      E.wait(3),
      'Player: It is ready!',
      '...', # Same as E.wait(1)
      'Player: Wait, this is not what I wanted.'
    ])
Clone this wiki locally