Declaration of the Flyweight_Exercise() function as used in the Flyweight Pattern. More...
Go to the source code of this file.
Macros | |
#define | __FLYWEIGHT_EXERCISE_H__ |
Functions | |
void | Flyweight_Exercise (void) |
Example of using the Flyweight design pattern. | |
Declaration of the Flyweight_Exercise() function as used in the Flyweight Pattern.
Definition in file c/Flyweight_Exercise.h.
#define __FLYWEIGHT_EXERCISE_H__ |
Definition at line 9 of file c/Flyweight_Exercise.h.
void Flyweight_Exercise | ( | void | ) |
Example of using the Flyweight design pattern.
The Flyweight pattern is used when a large object needs to be represented by a much lighter weight class, possibly multiple instances of said light-weight class.
In this example, a large object is represented by a so-called "big resource" (a two-dimensional array of text characters) containing multiple images, one associated with each flyweight class. Flyweight classes that represent offset into the big resource, along with position and velocity, are attached to the big resource image so they all share the same image but have different positions and velocities. The image is rendered to a display area through the Flyweight class. The Flyweight class instances then have their positions updated, bouncing off the edges of the display area 60 times a second. This continues for 1000 iterations or until a key is pressed.
Definition at line 346 of file Flyweight_Exercise.c.
References _Flyweight_ClearDisplay(), _Flyweight_GenerateBigResource(), _Flyweight_GenerateDisplay(), _Flyweight_GenerateFlyweightClasses(), _Flyweight_MoveFlyweights(), _Flyweight_RenderFlyweights(), _Flyweight_ShowDisplay(), BigResourceManager_Clear(), checkforkey(), disableinputecho(), Display_Destroy(), enableinputecho(), Flyweight_ImageList_Clear(), getcursorposition(), readkey(), setcursorposition(), and sleep().