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

📄 mopoidsettings.cpp

📁 mopoid game symbian os application development
💻 CPP
字号:
/*
========================================================================
 Name        : MopoidSettings.cpp
 Author      : 
 Copyright   : 
 Description : Stores settings related to the game and the current level.
 License     : 
 
========================================================================
*/
#include "MopoidSettings.h"

CMopoidSettings* CMopoidSettings::NewL()
	{
	CMopoidSettings* self = new (ELeave) CMopoidSettings();
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}


CMopoidSettings::CMopoidSettings()
:
    iHighScore(0),
    iScore(0),
    iLives(0),
    iScoreLiveLost(-100),
    iLevel(1),
    iAvailableLevels(1),
    iScoreLevelCleared(50),
    iScoreGameFinished(150),
    iBlockNormalDestroyScore(25),
    iScoreDecreaseTime(5000000),
    iScoreDecrement(5),
    iGamePaused(EFalse),
    iGameStatus(EStarted),
    iSoundLevel(2),
    iPanelSpeed(30.0),
    iPanelReflection(0.05),
    iGridCols(8),
    iGridRows(7),
    iBallStartSpeed(30.0),
    iBallSpeedMaxX(60.0),
    iBallSpeedAccX(0.08),
    iBallSpeedMaxY(48.0),
    iBallSpeedAccY(0.08)
{
	SetDrawRect(TRect(0, 0, 0, 0));
	SetGameRect(TRect(0, 0, 480, 540));
    iBallDefaultSize.SetSize(18, 18);
    SetBallSize(iBallDefaultSize.iWidth);
    iGridTopLeft.SetXY(0, 0);
    iPanelDefaultSize.SetSize(96, 24);
    SetPanelSize(iPanelDefaultSize.iWidth);
    TTime curTime;
    curTime.UniversalTime();
	iRandSeed = curTime.Int64();
}

void CMopoidSettings::ConstructL()
	{
	iFontUsed = (CFont*) AknLayoutUtils::LayoutFontFromId(EAknLogicalFontPrimarySmallFont);

    iFontHeight = iFontUsed->AscentInPixels();
    
    // The standard font line gap isn't enough for really text
    // that should be very readable (compare this to a linespacing
    // in an office application of 1 and 1.3 - the latter one
    // will be a lot better than the default.
    iTextBaselineOffset = iFontHeight / 4;
    iTextYOffset = iFontHeight + iTextBaselineOffset;
	}

CMopoidSettings::~CMopoidSettings()
	{
	
	}

void CMopoidSettings::SetBallSize(const TInt aNewWidth)
	{
	iBallSize.SetSize(aNewWidth, aNewWidth);
    iBallSizeHalf.SetSize(iBallSize.iWidth / 2, iBallSize.iHeight / 2);
	}


void CMopoidSettings::SetPanelSize(const TInt aNewWidth)
	{
	// Make sure to keep the aspect ratio
	iPanelSize.SetSize(aNewWidth, (TInt)((TReal)aNewWidth / ((TReal)iPanelDefaultSize.iWidth / (TReal)iPanelDefaultSize.iHeight)));
    iPanelSizeHalf.SetSize(iPanelSize.iWidth / 2, iPanelSize.iHeight / 2);
	}

void CMopoidSettings::SetGridSize(const TInt aCols, const TInt aRows)
	{
	iGridCols = aCols;
	iGridRows = aRows;
    const TInt brickWidth = iGameRect.Width() / iGridCols;
    iBrickSize.SetSize(brickWidth, brickWidth / 3);
	}

void CMopoidSettings::SetScreenSize(const TSize& aNewSize)
	{
	iScreenSize = aNewSize;
	iScreenRect.SetRect(TPoint(0, 0), aNewSize);
	}

void CMopoidSettings::SetDrawRect(const TRect& aNewRect)
	{
	iDrawRect = aNewRect;

    iDrawRectX = (TReal)iDrawRect.iTl.iX;
    iDrawRectY = (TReal)iDrawRect.iTl.iY;
    iDrawRectWidth = (TReal)iDrawRect.Width();
    iDrawRectHeight = (TReal)iDrawRect.Height();
	}

void CMopoidSettings::SetGameRect(const TRect& aNewRect)
	{
	iGameRect = aNewRect;

    iGameRectX = (TReal)iGameRect.iTl.iX;
    iGameRectY = (TReal)iGameRect.iTl.iY;
    iGameRectWidth = (TReal)iGameRect.Width();
    iGameRectHeight = (TReal)iGameRect.Height();
	}

⌨️ 快捷键说明

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