📄 ski.h
字号:
#ifndef __SKI_H_
#define __SKI_H_
// INCLUDES
// System includes
#include <e32std.h>
#include <e32base.h>
#include <fbs.h> //CFbsBitmap
#include <w32std.h>
// User includes
#include "keyhandler.h"
// CONSTANTS
const TInt KSkiArrayGranularity = 8;
// FORWARD DECLARATIONS
class CDoubleBufferedArea;
class CDirectScreenAccess;
// CLASS DECLARATION
/**
*
* @class TMapPrimitive Ski.h
* @brief Class to represent a particular object on the play area map
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class TMapPrimitive
{
public:
enum TMapObjectType
{
ETree = 0x01,
ELog = 0x02,
ELeftFlag = 0x04,
ERightFlag = 0x08,
EBump = 0x10,
EPassedFlag = 0x20,
EFailedFlag = 0x40
};
public:
TMapPrimitive(const TPoint& aPosn, TMapObjectType aType);
const TPoint& Posn() const;
TMapObjectType Type() const;
void SetType(TMapObjectType aType);
private:
TPoint iPosn;
TMapObjectType iType;
};
/**
*
* @class CMapPrimitiveArray Ski.h
* @brief An array of map primitives
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
#define CMapPrimitiveArray CArrayFixSeg<TMapPrimitive>
/**
*
* @class MMapPrimitiveToRectConverter Ski.h
* @brief Mixin class for classes to convert an object on the map to a rectangle.
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class MMapPrimitiveToRectConverter
{
public:
virtual TRect RectangleL(TMapPrimitive aPrimitive) const = 0;
protected:
TRect CreateRect(TPoint aPosn, TSize aSize) const;
};
/**
*
* @class CSkiMap Ski.h
* @brief Repository of primitive positions on the play area.
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CSkiMap : public CBase
{
public:
static CSkiMap* NewL();
static CSkiMap* NewLC();
static CSkiMap* NewLC(CMapPrimitiveArray* aArray);
~CSkiMap();
public:
CMapPrimitiveArray& PrimitiveArray();
const CMapPrimitiveArray& PrimitiveArray() const;
//
// Returns a map that contains all the primitives within aArea.
// aRectRep converts each map primitive into rectangles
//
class CSkiMap* IntersectsLC(const TRect& aArea, const MMapPrimitiveToRectConverter& aRectRep);
CMapPrimitiveArray* TypeLC(TInt aType);
TSize MapLimits() const;
void SetMapLimits(TSize aSize);
private:
CSkiMap();
CSkiMap(CMapPrimitiveArray* aArray);
void ConstructL();
private:
CMapPrimitiveArray* iArray;
TSize iLimits;
};
/**
*
* @class TSkiScreenAttribs Ski.h
* @brief A collection of the screen attributes, including the offset. The offset is
* the position of the top left hand corner of the screen on the play area
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class TSkiScreenAttribs
{
public:
TSkiScreenAttribs(const TRect& aRect);
TSkiScreenAttribs();
public:
const TRect& Rect() const;
TRect& Rect();
TPoint Offset() const;
void SetOffset(TPoint aOffset);
private:
TRect iRect;
};
/**
*
* @class CSkiSprite Ski.h
* @brief base class for screen sprite
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CSkiSprite : public CBase
{
public:
static CSkiSprite* NewL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aType);
static CSkiSprite* NewLC(CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aType);
~CSkiSprite();
public:
// bitmap accessors
const CFbsBitmap& Bitmap() const;
CFbsBitmap& Bitmap();
CFbsBitmap* Mask();
const CFbsBitmap* Mask() const;
TInt Type() const;
protected:
CSkiSprite(CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aType);
void ConstructL();
protected:
CFbsBitmap* iBitmap;
CFbsBitmap* iMask;
TInt iType;
};
/**
*
* @class CSkiSpriteArray Ski.h
* @brief an array of sprites!
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
#define CSkiSpriteArray CArrayPtrSeg<CSkiSprite>
/**
*
* @class CGameGallery Ski.h
* @brief base class for a collection of sprites
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CGameGallery : public CBase
{
public:
static CGameGallery* NewL();
static CGameGallery* NewLC();
~CGameGallery();
public:
// sprite accessors
const CSkiSprite& SpriteL(TInt aType) const;
CSkiSprite& SpriteL(TInt aType);
// bitmap setters
void AddBitmapL(CFbsBitmap* aBitmap, CFbsBitmap* aMask, TInt aType) const;
protected:
CGameGallery();
void ConstructL();
protected:
//attribs
CSkiSpriteArray* iArray;
};
/**
*
* @class CMapGallery Ski.h
* @brief collection of map sprites
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CMapGallery : public CGameGallery, public MMapPrimitiveToRectConverter
{
public:
static CMapGallery* NewL();
static CMapGallery* NewLC();
public:
// from MMapPrimitiveToRectConverter
virtual TRect RectangleL(TMapPrimitive aPrimitive) const;
};
/**
*
* @class TMapPrimitiveBoundingRect Ski.h
* @brief class to represent a bounding rectangle of a map element for collision
* detection
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class TMapPrimitiveBoundingRect
{
public:
TMapPrimitiveBoundingRect();
TMapPrimitiveBoundingRect(TSize aSize, TInt aHeight, TMapPrimitive::TMapObjectType aType);
public:
TSize Size() const;
void SetSize(TSize aSize);
TMapPrimitive::TMapObjectType Type() const;
void SetType(TMapPrimitive::TMapObjectType aType);
TInt Height() const;
void SetHeight(TInt aHeight);
private:
TSize iSize;
TInt iHeight;
TMapPrimitive::TMapObjectType iType;
};
/**
*
* @class CBoundingRectArray Ski.h
* @brief array of bounding rect + type information
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
#define CBoundingRectArray CArrayFixSeg<TMapPrimitiveBoundingRect>
/**
*
* @class CMapPrimitiveBoundingRects Ski.h
* @brief collection of bounding rectangles
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class CMapPrimitiveBoundingRects : public CBase, public MMapPrimitiveToRectConverter
{
public:
static CMapPrimitiveBoundingRects* NewL();
static CMapPrimitiveBoundingRects* NewLC();
~CMapPrimitiveBoundingRects();
public:
TSize SizeL(TMapPrimitive::TMapObjectType aType) const;
void AddSizeL(TSize aSize, TInt aHeight, TMapPrimitive::TMapObjectType aType) const;
public:
// from MMapPrimitiveToRectConverter
virtual TRect RectangleL(TMapPrimitive aPrimitive) const;
TInt Elevation() const;
void SetElevation(TInt aElevation);
private:
void ConstructL();
private:
TInt iElevation;
CBoundingRectArray* iRects;
};
/**
*
* @class TSkiVector Ski.h
* @brief 2D Vector class
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class TSkiVector
{
public:
TSkiVector();
TSkiVector(TReal aX, TReal aY);
TSkiVector operator+(const TSkiVector& aVector) const;
TSkiVector operator-(const TSkiVector& aVector) const;
TReal DotProduct(const TSkiVector& aVector) const;
TReal Magnitude() const;
TInt Normalize();
public:
TReal iX;
TReal iY;
};
/**
*
* @class TSkierAttribs Ski.h
* @brief skier physics properties + state enum
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*
*/
class TSkierAttribs
{
public:
enum TSkierState
{
ESkier0 = 0,
ESkier30 = 1,
ESkier60 = 2,
ESkier90 = 3,
ESkier120 = 4,
ESkier150 = 5,
ESkier180 = 6,
ESkierFall = 7
};
public:
TSkierAttribs();
public:
const TSkiVector& Posn() const;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -