⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsprite32x24.h

📁 symbian 的一个 二维飞行游戏 源码 及相关技术文章
💻 H
字号:
// Copyright 2002 Kenneth Guy,
// 
// TSprite32x24.h



#ifndef _TSPRITE32X24_H_
#define _TSPRITE32X24_H_

/** \file TSprite32x24.h 
    defines class TSprite32x24 */


#include <e32std.h>

class CMap;

/** Class used for the moving sprites. This class plots a 32x24 pixel
    sprite onto the off screen map (class CMap). The Plot() function
    stores away the background behind the sprite so that the
    Remove() function can erase the sprite. The Plot() function checks
    the top four bits of each pixel of the background for collision
    information which can be queried with the Hit() member. */

class TSprite32x24 {
public:
  /** Enum describing what is under the sprite */
  enum THit {
    EHitNone, ///< Nothing
    EHitShip, ///< Players ship
    EHitShipExtension, ///< Extension parts of the players ship, unused
    EHitLandScape, ///< Background landscape
    EHitBullet1,  ///< Players bullets
    EHitBullet2,  ///< Players bullets
    EHitBullet3,  ///< Players bullets
    EHitBullet4,  ///< Players bullets
    EHitBullet5,  ///< Players bullets
    EHitBullet6,  ///< Players bullets
    EHitBullet7,  ///< Players bullets
    EHitBullet8,  ///< Players bullets
  };

public:
  TSprite32x24();
  void Plot(CMap &aMap,const TUint16 *aSprites);
  void Remove();
  THit Hit();
  void SetSpriteNo(TInt16 aSpriteNo);
  void ClearSprite();
  TBool Used();

private:
  void RemoveAsm();
  TUint32 PlotAsm(const TUint16* aSpriteData);

  // if these are reordered, assembler functions need changing see:
  // sprite.s, remove_sprite.s
private:
  TUint16* iSpritePos; /**< Memory location to plot the sprite.
                           Set up from iX and iY by Plot() and NULL'd by Remove(), Must be the first member of class or assembler routines sprites.s and remove_sprite.s muxt changed. */
  TUint16* iDrawEnd; /**< End of offscreen map.
                         Read from CMap by Plot() and NULL'd by Remove(), Must be the second member of class or assembler routines sprites.s and remove_sprite.s muxt changed. */
  TUint16  iBehindSprite[32*24];  /**< Area behind the sprite. 
                                     Stored to by PlotAsm() and used by RemoveAsm() to erase the sprite, Must be the third member of class or assembler routines sprites.s and remove_sprite.s muxt changed. */

protected:
  TUint32  iCollision; /**< Collision information.
                           Orr'd collection of the backgrounds overwritten during the last Plot, used by Hit() to calculate what the sprite was plotted over. */
  TInt16   iSpriteNo; /**< Number of the sprite to plot. */

public:
  TInt16       iX; /**< X coordinate of the sprite.
                       Runs from 0->351 with 16->303 being the visible section of the screen. Each increment in iX is equal to 2 pixels ie one 32bit word*/
  TInt16       iY; /**< Y coordinate of the sprite.
                       Runs from -24->223 with 0->199 being the visible */
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -