資源簡介
這是俄羅斯方塊勞拉版的源碼,這里還特意寫了一篇使用教程,讓初學者更容易寫出自己的方塊游戲。

代碼片段和文件信息
//這個類中實現了游戲的所有功能
#include?“gamearea.h“
#include?
#include?
#include?
/****************************以下是構造函數和析構函數*********************************************************/
GameArea::GameArea(QWidget?*parent)?:
????Qframe(parent)
{
????this->init_gameArea(6643043020040020600);
????this->init_Game();
}
GameArea::GameArea(int?speedQWidget?*parent)?:
????Qframe(parent)
{
????this->init_gameArea(6643043020040020600);
????this->init_Game();
????this->moveTimer?=?new?QTimer(this);
????connect(this->moveTimerSIGNAL(timeout())thisSLOT(moveTimer_upDate()));
????this->moveSpeed?=?speed;
????this->gameStart();
????this->moveTimer->start(moveSpeed);
}
GameArea::~GameArea()
{
}
/****************************以下是主要功能函數*********************************************************/
//方塊下移一步
void?GameArea::moveOneStep()
{
?????startY?+=?step;
}
//顯示下移一步后的界面
void?GameArea::do_MoveNext()
{
????this->currentItem_to_currentMap();
????this->draw_gameArea();
}
void?GameArea::nextItem()
{//先將現在的游戲區域備份再消行
????copy_Map(currentMapcopyMapmap_rowmap_col);
????this->clearRow();
}
//游戲是否已經結束
bool?GameArea::isGame_Over()
{
????if(this->isGameOver)?return?true;
????else?return?false;
}
//獲取已滿的行數
int?GameArea::getFullRowNum()
{
????return?fullRowNum;
}
//設置方塊顏色或貼圖
void?GameArea::setGameAreaColor(QColor?color)
{
????gameAreaColor?=?color;
}
void?GameArea::setBoxBrushColor(QColor?color)
{
????boxBrushColor?=?color;
}
void?GameArea::setBoxPenColor(QColor?color)
{
????boxPenColor?=?color;
}
void?GameArea::set_draw_box_picture(bool?Bool)
{
????this->is_draw_box_picture?=?Bool;
}
void?GameArea::setBoxPicture(QString?fileName)
{
????this->boxPicture?=?fileName;
}
//設置方塊顏色或貼圖
//是否下移一步如果不是則一次下移到底
void?GameArea::setKey_Down_Move_oneStep(bool?Bool)
{
????this->isKey_Down_Move_OneStep?=?Bool;
}
//是否顯示網格
void?GameArea::setDrawGrid(bool?Bool)
{
????isDrawGrid?=?Bool;
}
//是否顯示下一個要出現的圖形
void?GameArea::setDrawNextItem(bool?Bool)
{
????isDrawNextItem?=?Bool;
}
//自己往游戲區添加方塊
void?GameArea::setbox(int?rowint?col)
{
????*(copyMap+row*map_col+col)?=?1;
}
//是否播放聲音
void?GameArea::setPlaySound_moveLeft(QString?fileNamebool?Bool)
{
????this->isPlaySound_moveLeft?=?Bool;
????this->sound_moveLeft?=?fileName;
}
void?GameArea::setPlaySound_moveRight(QString?fileNamebool?Bool)
{
????this->isPlaySound_moveRight?=?Bool;
????this->sound_moveRight?=?fileName;
}
void?GameArea::setPlaySound_moveDown(QString?fileNamebool?Bool)
{
????this->isPlaySound_moveDown?=?Bool;
????this->sound_moveDown?=?fileName;
}
void?GameArea::setPlaySound_itemChange(QString?fileNamebool?Bool)
{
????this->isPlaySound_itemChange?=?Bool;
????this->sound_itemChange?=?fileName;
}
void?GameArea::setPlaySound(bool?Bool)
{
????this->isPlaySound_moveLeft?=?Bool;
????this->isPlaySound_moveRight?=?Bool;
????this->isPlaySound_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1217??2009-11-30?20:57??myBox\Tetrix\debug\box.gif
?????文件???????7496??2007-10-09?18:54??myBox\Tetrix\debug\changeItem.wav
?????文件?????356303??2009-12-21?14:46??myBox\Tetrix\debug\gamearea.o
?????文件?????115127??2009-12-21?14:46??myBox\Tetrix\debug\main.o
?????文件???????2376??2009-12-21?14:46??myBox\Tetrix\debug\moc_gamearea.cpp
?????文件?????136095??2009-12-21?14:46??myBox\Tetrix\debug\moc_gamearea.o
?????文件???????3667??2009-12-21?14:46??myBox\Tetrix\debug\moc_widget.cpp
?????文件?????127581??2009-12-21?14:46??myBox\Tetrix\debug\moc_widget.o
?????文件???????5226??2007-10-09?18:53??myBox\Tetrix\debug\moveDown.wav
?????文件???????3264??2007-10-09?18:53??myBox\Tetrix\debug\moveLeft.wav
?????文件???????6308??2009-12-21?14:46??myBox\Tetrix\debug\myitem.o
?????文件????1245066??2009-12-21?14:46??myBox\Tetrix\debug\Tetrix.exe
?????文件?????240226??2009-12-21?14:46??myBox\Tetrix\debug\widget.o
?????文件??????15796??2009-12-21?17:56??myBox\Tetrix\gamearea.cpp
?????文件???????3436??2009-12-21?14:52??myBox\Tetrix\gamearea.h
?????文件????????264??2009-12-21?10:16??myBox\Tetrix\main.cpp
?????文件???????5380??2009-12-21?14:45??myBox\Tetrix\Makefile
?????文件???????6046??2009-12-21?14:45??myBox\Tetrix\Makefile.Debug
?????文件???????6157??2009-12-21?14:45??myBox\Tetrix\Makefile.Release
?????文件???????2729??2009-12-21?17:56??myBox\Tetrix\myitem.cpp
?????文件????????271??2009-11-29?19:46??myBox\Tetrix\myitem.h
?????文件????????343??2009-12-20?17:29??myBox\Tetrix\Tetrix.pro
?????文件??????16562??2009-12-21?17:56??myBox\Tetrix\Tetrix.pro.user
?????文件???????6247??2009-12-21?14:45??myBox\Tetrix\ui_widget.h
?????文件???????5679??2009-12-21?14:19??myBox\Tetrix\widget.cpp
?????文件????????872??2009-12-21?14:09??myBox\Tetrix\widget.h
?????文件???????4796??2009-12-21?14:09??myBox\Tetrix\widget.ui
?????文件??????15796??2009-12-21?17:56??myBox\方塊類源文件\gamearea.cpp
?????文件???????3436??2009-12-21?14:52??myBox\方塊類源文件\gamearea.h
?????文件???????2729??2009-12-21?17:56??myBox\方塊類源文件\myitem.cpp
............此處省略10個文件信息
- 上一篇:精通D3.js書籍源碼
- 下一篇:基于stm32F407的音樂播放器
評論
共有 條評論