Fantasy API for NPCs
danfinlay opened this issue · comments
I'm going to be assembling various convenience methods that would be nice to have for NPCs here.
NPC vs Entity
Aaron just said this to me and it confused me. These are two things?
I'm coming from teaching kids with Scratch, and Scratch is learnable for kids because it has a compelling set of convenience methods (blocks) to get started with games fast.
For example, with just about 6 blocks, a simple chase game can be made. (Hero: always follow mouse. Enemy: Always point at hero, move forwards).
For one thing, I don't like exposing global functions in the NPC scope, I think it encourages bad practice for the kids. I'd encourage us to treat the NPC run-loop as a method
of the NPC, and tie all methods to a this
object.
The beauty of this approach is that to start we can simply run the NPC
run loop in the context of the entity object being called. I don't completely remember what these objects have on them offhand, but it should include direct access to the mesh
, along with any other voxel-related objects and methods related to it.
Voxel NPC Convenience Pack
To start, we can pass the current objects, but all we have to do to modularly expand the API is create the Voxel NPC Convenience Pack, a module that accepts a Voxel-character, and returns the same voxel-character but with a growing library of convenience functions!
Organization
These functions could be flat, but since I'm largely thinking about kids who are coming off Scratch and are ready for real code, I'd strongly recommend grouping the convenience functions into categorical objects the way Scratch
does. In this case, that would be:
- Motion
- Looks
- Sound
- Sensing
So in this case you could call this.motion.moveRelative([0,1,0]);
, or this.motion.moveAbsolute([1,0,0]);
.
List of convenience methods to come.