From 05ce12b4fadb5f8c81610d9f91fe0b69a822a572 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Tue, 16 Jan 2024 12:37:43 -0700 Subject: [PATCH] Add more docs (#547) * Add more docs --- docs/basics/actors.md | 38 ++++++++++++++++++++++++- docs/basics/actorsmenu.md | 33 ++++++++++++++++++++-- docs/basics/basicsmenu.md | 8 +++--- docs/basics/controlflow.md | 57 ++++++++++++++++++++++++++++++++++++++ docs/basics/objects.md | 2 ++ 5 files changed, 131 insertions(+), 7 deletions(-) create mode 100644 docs/basics/controlflow.md create mode 100644 docs/basics/objects.md diff --git a/docs/basics/actors.md b/docs/basics/actors.md index 47a246e17..560de747d 100644 --- a/docs/basics/actors.md +++ b/docs/basics/actors.md @@ -1,2 +1,38 @@ \page actors How Actors Work -# Actors \ No newline at end of file +# Actors +If you are familiar with oot or sm64 prepare to be very disappointed. Both games split actors into separate files. In an unorderly fashion, mk64 appears to place all actors in the same file save for the odd exception. + +Actor setup: +```c +// Loop through the actor list and run that particular actors behaviour. +for actorListSize { + actor = gActorList[i] + switch(actor->type) { + case ACTOR1: + actor_name(args, actor); + break; + case ACTOR2: + another_actor(args, actor); + break; + } +} + +// Camera/Mat4 are optional +void actor_name(Camera, Mat4, actor) { + actor->pos[x] += 10; // Increase the actors X position by ten every frame or game loop. + actor->rot[y] -= 1; // Decrease the actors Y rotation by one every frame or game loop. + + // Increase the actors velocity until it reaches fifteen. + if (actor->velocity[z] < 15) { + actor->velocity[z] += 5 // Increase the actors Z velocity by five every frame. + } +} +``` +Check actor_types.h for a full list of options. You can create a new actor struct for your actor and customize it or use a predefined one. All actor structs must retain the same size. Generally, the types in the struct may be modified so long as `type` and `flags` stay the same as those are used elsewhere. + +See `update_obj_railroad_crossing` for an example of how a timer may be setup and used. + +Audio may be activated in the following method: +`func_800C98B8(actor->pos, actor->velocity, s32_audio_flag);` + +For more complex uses such as distanceFrom and collision, you will need to analyze the other actors. diff --git a/docs/basics/actorsmenu.md b/docs/basics/actorsmenu.md index d438e3d94..42e911fbe 100644 --- a/docs/basics/actorsmenu.md +++ b/docs/basics/actorsmenu.md @@ -1,8 +1,23 @@ \page actorsmenu Actors \htmlonly +Actors are dynamic game objects usually subject to game physics such as gravity, force, and collision. They might move around the map, spin, or interactive in some manner. Alternatively, static game objects cannot move and cannot be interacted with. They can use collision but not physics. A course model and Mario Raceway's Pipe are examples of static objects. Any of the items or player karts are examples of dynamic game objects; actors. -How actors in mk64 works. There are two kinds of actors. +mk64 contains two systems for implementing actors. They have been deemed as actors and objects, albeit an explicit or categorical difference between the two has yet to be determined. The running theory is that the systems were designed by different developers that were perhaps not communicating resulting in game objects being randomly distributed between the two. + +The two main variables to concern yourself with are `gActorList` and `gObjectList`; the core containers of the two systems. + +`gActorList` contains: +``` +trees, bushes, falling rocks, kiwano-fruit, banana, shells, piranha-plant, train wheels, rail-road crossing, cows, yoshi-valley's egg, spinning signs, palm trees, paddle for the paddle-wheeled boat, wheels for cars/trucks, etc. +``` +The actor code has two main parts; the update code and the render code. The update code alters the position/rotation of the object whereas the render code displays the object on the screen. + +`gObjectList` contains: +``` +thwomps, bowser fire-breath, moles, hedgehogs, snowmen, crabs, etc (also, probably penguins and birds). +``` +The object system is much more complex than actors and is not well documented.