ennacord / phaser3-experiments

A repository to collect phaser3 experiments / spikes in the development of `ennacord/anniversary-1y`
0 stars 0 forks source link

VnScene class and auxillaries #1

Open jhanschoo opened 2 years ago

jhanschoo commented 2 years ago

The task is to well-architect the part of the game as it relates to orchestrating scenes of a VN, by focusing on creating a VnScene class.

Class Design:

  1. The VnScene class may have a constructor into which providers are injected, but it's OK to leave this part of the VnScene API underspecified (i.e. consider hardcoding the game objects that the vnscene manages, rather than worry about injecting them) for the experiment.
  2. The VnSceneclass should implement an Updatable<T extends SpecificType> interface, so that it has an .update(message: T) method. It then acts based on the message received, as well as perhaps delegates messages (with potential transformation) to its member objects (e.g. dialog object, stage object (manipulating character sprites on the screen, etc.).
  3. The SpecificType above should be chosen to include (for now, and for this experiment), raw key and mouse state and input, as well as game tick information. In a more elaborate architecture we may revise this to receive more semantic messages.

Demo implementation:

In addition to the above, also implement some simple input-dependent behavior upon update (and possibly creation) in the vnscene's subobjects (don't have to actually represent dialog/stage/etc., just some basic feedback). Instantiate a vnscene object as a member of the Game singleton during game loading, and hook the vnscene's update to be called by the game's update method. Then verify that the game ticks and user input get propagated down to the vnscene's subobjects by observing their feedback.

Further details:

When completed, a working Phaser3 game instance should exist in a top-level folder vnscene that contains the VnScene class in vnscene.ts, an Updatable interface in types/updatable.ts (under appropriate folder hierarchies if desired or necessary), and various dummy classes that will be instantiated into dummy member objects of a vnscene object.

jhanschoo commented 2 years ago

Edited issue: Scene -> VnScene to avoid confusion with Phaser Scene classes.

jhanschoo commented 2 years ago

Also consider an approach by extending GameObject: https://blog.ourcade.co/posts/2020/organize-phaser-3-code-game-object-factory-methods/

jhanschoo commented 2 years ago

You can check out https://github.com/ennacord/phaser3-experiments/tree/main/text-animation 's DialogLine for reference, since I just integrated it to GameObject and GameObjectFactory. The type declaration stuff with TypeScript (for extending library types) is quite difficult to use, don't hesitate to ping me if you need help with that

dealoux commented 2 years ago

will do, thanks!