Beruflich Dokumente
Kultur Dokumente
graphics. The more general termcomputer generated imagery encompasses both static scenes and
dynamic images, while computer animation only refers to moving images.Modern computer
animation usually uses3D computer graphics, although 2D computer graphics are still used for
stylistic, low bandwidth, and faster real-time renderings. Sometimes the target of the animation is
the computer itself, but sometimes the target is another medium, such as film.
Each character is implemented as an object of a class CGraphin that has the following members
(in addition to the standard constructor and destructor).
protected:
CWinThread * m_pThread;
static UINT ThreadFunc(LPVOID pParam);
GParam m_param;
public:
void SetGraphin(GParam *p);
void GetGraphin(GParam *p);
void StartWork(BOOL resume);
void StopWork(BOOL terminal);
void Draw(CDC *pDC, HICON IconList[]);
A graphin is essentially a thread with an associated function and a parameter structureGParam.
This structure contains not only input parameters but also placeholders of the state variables of
the object used by the calling thread. Bellow is a partial listing of the structure with the essential
members. Additional members affect the "lifespan" of the object, details of its motion, etc.
typedef struct _GParam {
int id;
// index of the object. If -1, the thread is not running
int x0, y0; // initial position
int dx, dy; // speed
int type;
// determines how it is drawn
int x, y, ix; // state of the object
// ...
} GParam;
This structure begins life in the calling program and it is copied in the graphin object during
initialization. The SetGraphin(GParam *p) function contains only the statement
m_param = *p;
}
The program works equally well when the thread function is taken out of the class because all
the class instance variables are passed as argument. It has been included in the class for
"bookeeping purposes".