Return to previous page Return to menu Go to next page

5. Action control

What is an action?

The 2D shooting game in the sample game uses a method called action to perform pseudo multitasking. An action is a function that performs a one-cycle process such as player, enemy, shot, and background scrolling.
∙ By registering these functions individually (makeaction) and rotating the registered functions in a loop at once (actionloop), pseudo multitasking is realized.
This sample is provided in smp_task.c and smp_task.h and is used in most of the sample programs.

Action control mechanism

Action control centrally manages actions using an action structure. The basic action structure (ACTWK) consists of the flag (id), level (level), mode (mode), status (status), function execution address (pcbuff), and area that can be set freely.
Of these, you can use anything other than id and pcbuff. In addition, if you want to save other necessary information, you can freely register members with the macro described below. (See Fig. 7)

In 2D shooting, a dedicated action structure called GAMEACT is declared.
∙ In order to manage multiple actions, an array with ACTWK type as an element is defined, and information for each action can be saved. The maximum number of this array is specified by ACTWKMAX. In other words, actions can be registered for the maximum number of ACTWKMAX.
∙ There are two types of registration: one that is unconditionally registered for an unused action and one that is registered at a specified location in the array. The registered action is called by actionloop. At this time, actionloop passes a pointer to the action structure as an argument, so you can manipulate the information of each action in the action.


Return to previous page Return to menu Go to next page