亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? retroengine.cpp

?? symbian系統上的2D圖形游戲
?? CPP
字號:
////////////////////////////////////////////////////////////////////////
//
// RetroEngine.cpp
//
// Copyright (c) 2003 Nokia Mobile Phones Ltd.  All rights reserved.
//
////////////////////////////////////////////////////////////////////////

#include "RetroEngine.h"

//System includes
#include <e32math.h>

//User includes
#include "KeyHandler.h"
#include "ImageFactory.h"
#include "DoublebufferedArea.h"
#include "RenderableFactory.h"
#include "BaseAnim.h"         
#include "BitmapAnimFrame.h"  
#include "BitmapTile.h"       
#include "FireAnim.h"         
#include "ParticleSystem.h"   
#include "RetroLeafTileset.h" 
#include "RetroNodeTileset.h" 
#include "ShipAnim.h"         
#include "Tilemap.h"          
#include "Tileset.h"          
#include "GameTimer.h"

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

CRetroEngine* CRetroEngine::NewLC(RWsSession& aClient, CWsScreenDevice& aScreenDevice, RWindow& aWindow,TKeyHandler& aKeyHandler, CImageFactory& aImageFactory, const TSize& aSize)
	{
	CRetroEngine* self = new (ELeave) CRetroEngine(aClient, aScreenDevice, aWindow, aKeyHandler, aImageFactory, aSize);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

////////////////////////////////////////////////////////////////////////

CRetroEngine* CRetroEngine::NewL(RWsSession& aClient, CWsScreenDevice& aScreenDevice, RWindow& aWindow,TKeyHandler& aKeyHandler, CImageFactory& aImageFactory, const TSize& aSize)
	{
	CRetroEngine* self = CRetroEngine::NewLC(aClient, aScreenDevice, aWindow, aKeyHandler, aImageFactory, aSize);
	CleanupStack::Pop();
	return self;
	}

////////////////////////////////////////////////////////////////////////

CRetroEngine::CRetroEngine(RWsSession& aClient, CWsScreenDevice& aScreenDevice, RWindow& aWindow,TKeyHandler& aKeyHandler, CImageFactory& aImageFactory, const TSize& aSize) :
	iClient(aClient),
	iScreenDevice(aScreenDevice),
	iWindow(aWindow),
	iKeyHandler(aKeyHandler),
	iImageFactory(aImageFactory),
	iSize(aSize),
	iDropRenderFrames(ETrue), // Set to "EFalse" to demonstrate ViewSrv 11 problem
	iFrameCounter(0)
	{
	}

////////////////////////////////////////////////////////////////////////
	
void CRetroEngine::ConstructL()
	{
	iPlaying = EFalse;

	iGameTimer = CGameTimer::NewL(*this);
	// Direct screen access
	iDirectScreenAccess = CDirectScreenAccess::NewL(iClient, iScreenDevice, iWindow, *this);

//	ConstructSimpleMapL();
	ConstructCompoundMapL();
	ConstructShipL();

	iDoubleBufferedArea = CDoubleBufferedArea::NewL(iSize, EColor4K);
	iOffscreenContext = &(iDoubleBufferedArea->GetDoubleBufferedAreaContext());
	}

////////////////////////////////////////////////////////////////////////

CRetroEngine::~CRetroEngine()
	{
	delete iGameTimer;
	iGameTimer = NULL;
	
	delete iDirectScreenAccess;
	iDirectScreenAccess = NULL;
	
	delete iDoubleBufferedArea;
	iDoubleBufferedArea = NULL;

	delete iMap;
	iMap = NULL;

	delete iNodeFactory;
	iNodeFactory = NULL;
	
	delete iLeafFactory;
	iLeafFactory = NULL;
	
	delete iEngineExhaust;
	iEngineExhaust = NULL;

	delete[] iShipVectors;
	iShipVectors = NULL;

	delete iShipAnim;
	iShipAnim = NULL;
	
	delete iFireAnim;
	iFireAnim = NULL;
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::ConstructSimpleMapL()
    {
	TInt mapData[] = 
		{
		0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,
		4,0,4,0,4,0,5,2,4,0,4,0,4,0,4,0,
		0,4,0,4,0,5,3,6,0,4,0,4,0,4,0,4,
		4,0,4,0,4,1,7,2,4,0,4,0,4,0,4,0,
		0,4,0,4,0,4,1,6,0,4,0,4,0,4,0,4,
		4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,
		0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,
		4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,
		0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,
		4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,
		0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,
		4,0,5,2,4,0,4,0,4,0,4,0,5,2,4,0,
		0,4,1,6,0,4,0,4,0,4,0,4,1,6,0,4,
		4,0,5,2,4,0,4,0,4,0,4,0,4,0,4,0,
		0,4,1,6,0,4,0,4,0,4,0,4,0,4,0,4,
		4,0,4,0,4,0,4,0,4,0,4,0,4,0,4,0,
		};

	iShipBounds		= TRect(TPoint(0x00000800,0x00000800),TPoint(0x00001800,0x00001800));
	iShipWorldPos	= iShipBounds.Center();
	iShipVelocity	= TPoint(0x000e,0x0013);

	iLeafFactory = CRetroLeafTileset::NewL(iImageFactory.TileImage());
	iMap = CTilemap::NewL(16,16,&mapData[0],*iLeafFactory);
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::ConstructCompoundMapL()
    {
	TInt mapData[] = 
		{
		15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
		15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
		15,15, 7, 3,11,15, 7, 3, 3, 3, 3, 3, 3,11,15,15,
		15,15, 5, 0, 2, 3, 1, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 8, 4, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 8, 4, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 2, 9, 4, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,10,15,15,
		15,15,13,12,12,12,12,12,12,12,12,12,12,14,15,15,
		15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
		15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
		};

	iShipBounds		= TRect(TPoint(0x00000800,0x00000800),TPoint(0x00007800,0x00007800));
	iShipWorldPos	= iShipBounds.Center();

	iLeafFactory = CRetroLeafTileset::NewL(iImageFactory.TileImage());
	iNodeFactory = CRetroNodeTileset::NewL(*iLeafFactory);
	iMap = CTilemap::NewL(16,16,&mapData[0],*iNodeFactory);
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::ConstructShipL()
	{
	iShipVelocity	= -TPoint(0x000e,0x0013);

	iShipFrame = 8;
	iShipScreenPos = TPoint(88,104);
	iShipScreenPosUp4 = TPoint(iShipScreenPos.iX << 4, iShipScreenPos.iY << 4);

	iShipAnim = CShipAnim::NewL(iImageFactory.ShipAnim());
	iFireAnim = CFireAnim::NewL(iImageFactory.FireAnim());

	iEngineExhaust = CParticleSystem::NewL(16,*iFireAnim);

	// Physics parameters for ship motion:
	iDragDownshift = 8;
	iDragRatio = 0xff;
	iThrust = 6;
	iGravity = 1;


	// Allocate and initialise ship vectors
	// (each one a vector lying along the central axis of the ship
	// in the corresponding animation frame):
	iShipVectors = new TVectorFP[64];
	User::LeaveIfNull(iShipVectors);

	TReal degreesToRadians = 3.141592 / 180.0;

	// Animation frame #0 is at 45 degrees, so:
	TReal angle = 45.0 * degreesToRadians;
	TReal angleStep = ( 360.0 / 64.0 ) * degreesToRadians;

	for ( TInt frame = 0 ; frame < 64 ; frame++ )
		{
		TReal cos;
		TReal sin;

		Math::Cos(cos,angle);
		Math::Sin(sin,angle);

		TInt16 cosFP;
		TInt16 sinFP;

		Math::Int(cosFP,cos * 256.0);
		Math::Int(sinFP,sin * 256.0);

		iShipVectors[frame] = TVectorFP(TPoint(cosFP,sinFP));

		angle += angleStep;
		}
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::Simulate()
	{
	UpdatePosition();
	iEngineExhaust->Simulate();

	if( iKeyHandler.Direction() == TKeyHandler::ELeft )
		{
		iShipFrame--;
		}
	else if ( iKeyHandler.Direction() == TKeyHandler::ERight )
		{
		iShipFrame++;
		}

	if (iKeyHandler.FirePressed())
		{
		iEngineExhaust->Generate(iShipWorldPos,iShipVectors[iShipFrame],iShipVelocity,13 << 4,128);
		}

	iShipFrame &= 0x3f;
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::UpdatePosition()
	{

	if (iKeyHandler.FirePressed())
		{
			TPoint deltaV = iShipVectors[iShipFrame].ScaleToPoint(-iThrust);
			iShipVelocity += deltaV;
		}

	TInt vSquared = ( iShipVelocity.iX * iShipVelocity.iX ) + ( iShipVelocity.iY * iShipVelocity.iY );

	TInt dragRatio = iDragRatio;

	if ( vSquared < 1024 )
		{
		// Very slow - no drag needed:
		dragRatio = 0x0100;
		}
	else if ( vSquared > 4096 )
		{
		// Fast - apply strong drag:
		dragRatio = 0x00fc;
		}
	else if ( vSquared > 8192 )
		{
		// Very fast - apply stronger drag:
		dragRatio = 0x00f0;
		}

	if ( vSquared > 1024 )
	{
		iShipVelocity.iX = ( iShipVelocity.iX * dragRatio ) >> iDragDownshift;
		iShipVelocity.iY = ( iShipVelocity.iY * dragRatio ) >> iDragDownshift;
	}

	iShipVelocity.iY += iGravity;

	TPoint newWorldPos = iShipWorldPos + iShipVelocity;

	if ( iShipBounds.Contains(newWorldPos) )
		{
		iShipWorldPos = newWorldPos;	
		}
	else
		{
		if ( ( newWorldPos.iX < iShipBounds.iTl.iX ) || ( newWorldPos.iX >= iShipBounds.iBr.iX ) )
			{
			iShipVelocity.iX = -iShipVelocity.iX;
			}

		if ( ( newWorldPos.iY < iShipBounds.iTl.iY ) || ( newWorldPos.iY >= iShipBounds.iBr.iY ) )
			{
			iShipVelocity.iY = -iShipVelocity.iY;
			}
		}

	iMapWindowTopLeft = iShipWorldPos - iShipScreenPosUp4;
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::Render(const TRect& aRect,CFbsBitGc* aCallerGc) const
	{
	TPoint pixelTopLeft(iMapWindowTopLeft.iX >> 4,iMapWindowTopLeft.iY >> 4);
	iMap->Render(pixelTopLeft,aRect,aCallerGc);


	iEngineExhaust->Render(pixelTopLeft,aRect,aCallerGc);
	iShipAnim->RenderFrameCentered(iShipFrame,iShipScreenPos,aRect,aCallerGc);
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::SetupDirectScreenAccessL()
	{
	// Initialise DSA
	iDirectScreenAccess->StartL();

	// Get graphics context for it
	iGc = iDirectScreenAccess->Gc();

	// Get region that DSA can draw in
	iRegion = iDirectScreenAccess->DrawingRegion();

	// Set the display to clip to this region
	iGc->SetClippingRegion(iRegion);
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::StartFirstGameL()
	{
	StartGameL();
	// We only want to play the game if we have the whole screen available so 
	// on first start we record the region available for comparision later (in restart)
	iGameDawingArea = iRegion->BoundingRect();
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::StartGameL()
	{
	iPaused = EFalse;
	if(!iPlaying)
		{
		SetupDirectScreenAccessL();
		iGameTimer->Restart();
		}
	iPlaying = ETrue;
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::StopGame()
	{
	iPlaying = EFalse;
	iPaused = ETrue;
	iGameTimer->CancelTimer();
	iDirectScreenAccess->Cancel();
	}

////////////////////////////////////////////////////////////////////////

TInt CRetroEngine::DoGameFrame()
	{
	// Force screen update:
	iDirectScreenAccess->ScreenDevice()->Update();

	Simulate();

	// Drop 1 render frame in every 128, to avoid ViewSrv 11 problems:
	if (iDropRenderFrames & ((iFrameCounter & 0x007f) != 0x007f))
		{
		Render(iGameDawingArea, iOffscreenContext);
		}

	iFrameCounter++;

	// Draw from offscreen bitmap
	iGc->BitBlt(TPoint(0,0), &(iDoubleBufferedArea->GetDoubleBufferedAreaBitmap()));

	iClient.Flush();	

	if(iPaused)
		{
		return CGameTimer::StopTicking;
		}
	else
		{
		return CGameTimer::TickAgain;
		}
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::Restart(RDirectScreenAccess::TTerminationReasons /*aReason*/)
	{
	// Restart display
	// Note that this will result in the clipping region being updated
	// so that menus, overlaying dialogs, etc. will not be drawn over
	SetupDirectScreenAccessL();
	if(iPaused)
		{
		if(iGameDawingArea == iRegion->BoundingRect())
			{
			iPaused = EFalse;	
			if(!iGameTimer->IsActive())
				{
				iGameTimer->Restart();
				}
			}
		else
			{
			PauseFrame();
			}
		}
	else
		{
		if(!iGameTimer->IsActive())
			{
			iGameTimer->Restart();
			}
		}
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::AbortNow(RDirectScreenAccess::TTerminationReasons /*aReason*/)
	{
	// Cancel timer and display
	iDirectScreenAccess->Cancel();
	iPaused = ETrue;
	}

////////////////////////////////////////////////////////////////////////

void CRetroEngine::PauseFrame()
	{
	// Force screen update: this is required for WINS, but may
	// not be for all hardware:
	iDirectScreenAccess->ScreenDevice()->Update();

	// and draw from unchanged offscreen bitmap
	iGc->BitBlt(TPoint(0,0), &(iDoubleBufferedArea->GetDoubleBufferedAreaBitmap()));

	iClient.Flush();		
	}

////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区久久久| 在线观看91精品国产入口| 欧美日韩国产中文| 中文字幕中文乱码欧美一区二区| 成人国产免费视频| 亚洲国产精品黑人久久久| 国产综合色精品一区二区三区| 欧美酷刑日本凌虐凌虐| 美女高潮久久久| 欧美成人精品福利| 国产一区二区三区四区五区入口| 精品人在线二区三区| 极品尤物av久久免费看| 日韩精品影音先锋| 成人精品免费视频| 国产精品对白交换视频| 91视频在线看| 亚洲一区二区五区| 欧美一区二区在线免费观看| 免费成人在线网站| 久久久国产一区二区三区四区小说| 一区二区三区不卡在线观看| 日韩一区二区电影网| 蜜臀av一区二区在线免费观看| 欧美大片在线观看| 国产成人精品一区二| 亚洲国产日韩精品| 日韩亚洲欧美高清| 国产成人免费视频一区| 久久久久久夜精品精品免费| 色婷婷av一区二区三区gif| 亚洲国产视频一区二区| 日韩欧美中文字幕精品| 精品制服美女久久| 亚洲精品成人悠悠色影视| 欧美日韩一区二区欧美激情| 久久av老司机精品网站导航| 欧美猛男gaygay网站| 国产精品996| 亚洲电影一区二区三区| 久久这里都是精品| 成人av网站在线观看| 免费人成黄页网站在线一区二区 | 国产成人免费在线观看| 国产精品久久毛片av大全日韩| 制服丝袜亚洲色图| 成人一二三区视频| 亚洲午夜日本在线观看| 欧美电视剧免费全集观看| 欧美视频一区二区三区| 国产麻豆精品95视频| 亚洲精品va在线观看| 日韩欧美国产一区在线观看| 欧美在线观看视频一区二区 | 国产精品美女久久久久久 | 欧美四级电影网| 精品一区二区久久久| 亚洲女同ⅹxx女同tv| 欧美大片在线观看一区二区| 欧美在线观看一二区| 精品亚洲国产成人av制服丝袜| 一区二区日韩电影| 国产日韩欧美精品在线| 91精品婷婷国产综合久久性色| 99久久精品免费看国产| 国产在线播精品第三| 午夜亚洲国产au精品一区二区| 国产精品久久久久婷婷| 欧美亚洲国产一区二区三区va| 国产suv精品一区二区三区| 水野朝阳av一区二区三区| ●精品国产综合乱码久久久久| 欧美一级一区二区| 欧美一二区视频| 欧美精品一二三区| 日本韩国一区二区三区视频| 成人av在线资源网| 91日韩精品一区| 成人福利电影精品一区二区在线观看 | 懂色一区二区三区免费观看| 青青草国产成人99久久| 午夜久久久久久久久久一区二区| 午夜影视日本亚洲欧洲精品| 亚洲一区免费视频| 怡红院av一区二区三区| 亚洲黄色性网站| 一区二区三区在线观看国产| 亚洲欧洲三级电影| 国产精品色哟哟| 国产精品青草久久| 日本一区二区免费在线观看视频| 国产免费久久精品| 中文字幕精品一区二区三区精品| 国产欧美一区二区精品仙草咪 | 色婷婷综合视频在线观看| 久久国产精品露脸对白| 国产原创一区二区三区| 国产在线视频一区二区三区| 国产精品一区二区果冻传媒| 精品国产99国产精品| 欧美岛国在线观看| 欧美日韩二区三区| 在线观看欧美日本| 欧美精品1区2区3区| 欧美日韩国产一级片| 91精品国产综合久久精品图片| 日韩午夜小视频| 欧美性生活大片视频| 日韩欧美在线观看一区二区三区| 久久久久久一级片| 亚洲欧洲av一区二区三区久久| 中文字幕免费不卡| 亚洲成人免费影院| 麻豆91在线看| 国产在线精品一区二区不卡了| 成人国产精品免费观看动漫| 欧美三级资源在线| 久久理论电影网| 亚洲午夜久久久久| 国产九色sp调教91| 欧美色图在线观看| 欧美国产精品劲爆| 亚洲6080在线| 99久久综合色| 欧美r级在线观看| 亚洲一线二线三线视频| 国产伦精品一区二区三区免费 | 夜夜精品浪潮av一区二区三区| 精品一区二区三区在线观看| 色综合久久精品| 久久久影视传媒| 日本成人在线不卡视频| 93久久精品日日躁夜夜躁欧美| 日韩一区二区三区视频| 亚洲人成小说网站色在线| 精品一区二区三区在线视频| 欧美高清你懂得| 国产精品传媒视频| 国产美女视频91| 91精品免费在线观看| 一区二区三区国产精华| 国产1区2区3区精品美女| 91精品国产综合久久久久久| 久久精品国产精品亚洲综合| 欧美亚洲国产怡红院影院| 久久一二三国产| 欧美在线观看你懂的| 国产丝袜欧美中文另类| 狠狠色狠狠色综合日日91app| 欧美吻胸吃奶大尺度电影| 日本一区二区综合亚洲| 欧美精品久久天天躁| 一区二区三区四区乱视频| 国产精品一区二区三区四区| 久久这里只有精品首页| 中文字幕一区二区不卡| 亚洲乱码中文字幕| 91同城在线观看| 国产精品理伦片| 成人小视频免费观看| 久久久亚洲欧洲日产国码αv| 日韩中文字幕1| 欧美日韩第一区日日骚| 亚洲高清免费一级二级三级| 91麻豆免费在线观看| 亚洲免费av在线| 一本久久精品一区二区| 日韩久久一区二区| 97久久人人超碰| 日韩一区在线免费观看| 99re6这里只有精品视频在线观看| 国产精品乱人伦中文| av一区二区三区四区| 中文字幕日韩一区二区| 91蜜桃婷婷狠狠久久综合9色| 亚洲欧美一区二区久久| 色一区在线观看| 一区二区三区在线观看视频| 欧美色爱综合网| 蜜臀av性久久久久蜜臀av麻豆| 日韩欧美国产一区二区三区 | 国产精品中文字幕一区二区三区| 欧美精品一区二| 成人动漫一区二区三区| 成人欧美一区二区三区白人| 欧美性受极品xxxx喷水| 免费视频一区二区| 国产亚洲欧美色| 日本韩国欧美一区二区三区| 婷婷久久综合九色综合伊人色| 欧美一激情一区二区三区| 国产一区二三区好的| 国产精品久久久久久亚洲伦| 欧美视频在线观看一区| 日韩精品国产欧美| 久久久精品2019中文字幕之3| 色综合欧美在线视频区| 麻豆成人久久精品二区三区红| 国产农村妇女精品| 欧美精品高清视频|