Doodad JavaScript API Features #65

Closed
opened 2022-01-14 20:36:19 +00:00 by kirsle · 1 comment

Ideas to add to the JS API to enable more features:

  • ActorsAt(Point): query a position in the level and return a list of actors that intersect that point.
    • Use case: the Bird can scan for the player character by sampling every 10 pixels diagonally to see if it intersects with a playable character.
  • CreateActor: dynamically create a new doodad in the level.
    • Use case: a turret could spawn bullets, a mob could spawn an Item Bag on death holding its dropped inventory items, etc.
    • The created actor would need some way to configure its properties: velocity of a bullet, contents of an item bag, etc. that would be distinct from the usual "static actor placed by the level creator with hard-set doodad tags on it"
    • CreateActor could return the Actor and the caller can SetVelocity() etc. on it. An API to "link" the created actor so PubSub events can be sent, or a method to directly call a PubSub handler on an Actor could be useful.
  • FindActor() or FindPlayer() or NearestPlayer(): locate actors by name or ID or find the player characters.
    • Use case: the Snake (#61) wants to face the player always, or mobs could path-find to players, or search the level for actors of interest that a doodad interacts with.
Ideas to add to the JS API to enable more features: * ActorsAt(Point): query a position in the level and return a list of actors that intersect that point. * Use case: the Bird can scan for the player character by sampling every 10 pixels diagonally to see if it intersects with a playable character. * CreateActor: dynamically create a new doodad in the level. * Use case: a turret could spawn bullets, a mob could spawn an Item Bag on death holding its dropped inventory items, etc. * The created actor would need some way to configure its properties: velocity of a bullet, contents of an item bag, etc. that would be distinct from the usual "static actor placed by the level creator with hard-set doodad tags on it" * CreateActor could return the Actor and the caller can SetVelocity() etc. on it. An API to "link" the created actor so PubSub events can be sent, or a method to directly call a PubSub handler on an Actor could be useful. * FindActor() or FindPlayer() or NearestPlayer(): locate actors by name or ID or find the player characters. * Use case: the Snake (#61) wants to face the player always, or mobs could path-find to players, or search the level for actors of interest that a doodad interacts with.
kirsle added the
enhancement
label 2022-01-14 20:36:19 +00:00
Poster
Owner

Added in 9201475060

Note: CreateActor not yet tested and will be fleshed out when a doodad starts needing it.

Added in 9201475060408ccdb7c234e8f7b57d1e0baf25ae Note: CreateActor not yet tested and will be fleshed out when a doodad starts needing it.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SketchyMaze/doodle#65
There is no content yet.