日韩精品 中文字幕 动漫,91亚洲午夜一区,在线不卡日本v一区v二区丶,久久九九国产精品自在现拍

正文

游戲案例:GemDrops(16)

Windows移動游戲開發(fā)實(shí)戰(zhàn) 作者:(美)Adam Dawes


 

程序清單8-20  對一對新的由玩家控制的寶石對象進(jìn)行初始化

/// <summary>

/// Create two new gems for the player to control.

/// </summary>

private void InitPlayerGems()

{

// Instantiate and initialize two new gems for the player to control.

// Set the gem colors to be those colors stored for the next gems.

_playerGems[0] = new CObjGem(this, BOARD_GEMS_ACROSS / 2, 0,

_playerNextGems[0].GemColor);

_playerGems[1] = new CObjGem(this, BOARD_GEMS_ACROSS / 2, 1,

_playerNextGems[1].GemColor);

// These are the player controlled gems

_playerGems[0].GemType = CObjGem.GemTypes.PlayerControlled;

_playerGems[1].GemType = CObjGem.GemTypes.PlayerControlled;

// Set the gems as falling into the position we have set

_playerGems[0].FallDistance = 1;

_playerGems[1].FallDistance = 1;

// Set the drop speed to increase based on the number of pieces already 

// dropped.

_playerGems[0].FallSpeed = 0.02f + (_piecesDropped * 0.0004f);

_playerGems[1].FallSpeed = _playerGems[0].FallSpeed;

// Add the gems to the game

GameObjects.Add(_playerGems[0]);

GameObjects.Add(_playerGems[1]);

// Check that the board space is actually available.

// If not, the game is finished.

CheckGameOver();

if (GameOver)

{

// The game is finished, so no further work is required here

return;

}

// Set two new 'next' gems

_playerNextGems[0].GemColor = GenerateRandomGemColor();

_playerNextGems[1].GemColor = GenerateRandomGemColor();

// Flag the next gems as having moved so that they are re-rendered in 

// their new colors.

_playerNextGems[0].HasMoved = true;

_playerNextGems[1].HasMoved = true;

// Increase the pieces dropped count

_piecesDropped += 1;

}


上一章目錄下一章

Copyright ? 讀書網(wǎng) rgspecialties.com 2005-2020, All Rights Reserved.
鄂ICP備15019699號 鄂公網(wǎng)安備 42010302001612號