-
-
Notifications
You must be signed in to change notification settings - Fork 20
Popochiu
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 😊 .
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
- 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.
-
camera_offset( Vector2
offset = Vector2.ZERO
, boolis_in_queue = true
) voidChanges the main camera's
offset
(useful when zooming the camera). If you want to use it outside a run, sendis_in_queue
asfalse
. Can be yield. -
camera_shake( float
strength = 1.0
, floatduration = 1.0
, boolis_in_queue = true
) voidMakes the camera shake with
strength
forduration
seconds. If you want to use it outside a run, sendis_in_queue
asfalse
. Can be yield. -
camera_zoom( Vector2
target = Vector2.ONE
, floatduration = 1.0
, boolis_in_queue = true
) voidChanges the camera zoom. If
target
is larger thanVector2(1, 1)
the camera will zoom out, smaller values make it zoom in. The effect will lastduration
seconds. If you want to use it outside a run, sendis_in_queue
asfalse
. 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
, booluse_transition = true
) voidLoads 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
, floatduration, [bool](https://docs.godotengine.org/en/stable/classes/class_bool.html)
is_in_queue = true` ) voidPlays the transition
type
animation in TransitionLayer.tscn that lastduration
in seconds. Possibletype
values can be found inTransitionLayer
(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?', ])
-
room_exists( String
script_name
) bool:Checks if the room with
script_name
exists in the array of rooms of Popochiu. -
run( Array
instructions
, boolshow_gi = true
) voidExecutes 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
) voidExcecutes 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
, Stringmethod
, Arrayparams = []
, Stringyield_signal = ''
) voidMakes a
method
innode
to be able to be used in a run call. Method parameters can be passed withparams
, andyield_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 waitmethod
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
, boolis_in_queue = true
) voidCreates a delay timer that will last
time
seconds. If you want to use it outside a run, sendis_in_queue
asfalse
. 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.' ])