|
Page 5 of 10
Sprites
All sprite objects (the hero, guardians, doors, collection items) are based on the CSprite class. When creating the CGuardians or CHero object, you have to pass the CSprite object to CGuardian and CHero constructor. The Sprite object is created in this way:
new CSprite(gameEngineObject, // reference to the game engine
SurfaceNumber, // ID of surface (ID given to DDCreateSurface)
nSurfaceOffsetX, // upper left coordinate of the sprite bitmap within surface
nSurfaceOffsetY,
nSpriteWidth, nSpriteHeight,// dimensions of the single frame of the sprite
bIsSpriteBidirectional, // true if sprite has different frames for left and right direction
nNumberofSpriteFrames); // number of sprite frames
The guardian object is created in the following way:
guardian.Create( pSpriteObject,
nInitPosX, // initial coordinates
nInitPosY
nSpeed, // guardian speed - number of pixels per game frame
horizontalOrVertical ); // CGuardian::VERTICAL / CGuardian::HORIZONTAL
guardian.SetBorderLimits(
nLeft, // defines left and right (or top and bottom) limits
nRight ); // for the guardian movement
guardian.SetBidi( bIsSpriteBidirectional );
The Hero object is created in the following way:
hero.Create( pSpriteObject, nInitPosX, nInitPosY );
|