User Tools

Site Tools


wamDisplay: Implementation Strategy for Mole Info Records

Moles are represented using a struct that is shown below. Carefully read the comments associated with the struct to understand how the struct is used. The ticksUntilAwake/ticksUntilDormant will be decremented at a regular rate by the controlling state machine.

typedef struct {
        wamDisplay_point_t origin;  // This is the origin of the hole for this mole.
        // A mole is active if either of the tick counts are non-zero. The mole is dormant otherwise.
        // During operation, non-zero tick counts are decremented at a regular rate by the control state machine.
        // The mole remains in his hole until ticksUntilAwake decrements to zero and then he pops out.
        // The mole remains popped out of his hole until ticksUntilDormant decrements to zero.
        // Once ticksUntilDormant goes to zero, the mole hides in his hole and remains dormant until activated again.
        wamDisplay_moleTickCount_t ticksUntilAwake;  // Moles wake up (pop out of hole) when this goes from 1 -> 0.
        wamDisplay_moleTickCount_t ticksUntilDormant; // Moles go dormant (back in hole) this goes 1 -> 0.
} wamDisplay_moleInfo_t;

Each mole is represented by a single mole-info record that provides the mole's screen coordinates and awake/dormant status (ticksUntilAwake, ticksUntilDormant). You will use a one-dimensional array of pointers to keep track of, and to access your mole-info records. You will need to resize this array whenever the user selects a different number of moles for game play. You will allocate/deallocate memory using malloc()/free() whenever you resize the array.

representing_moles_with_a_data_structure.txt · Last modified: 2019/04/10 12:45 by hutch