91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 15KB
    文件類型: .cpp
    金幣: 1
    下載: 1 次
    發布日期: 2023-01-12
  • 語言: C/C++
  • 標簽:

資源簡介

C++版本俄羅斯方塊代碼,小巧,但是非常經典!vs 2015 編譯通過!@

資源截圖

代碼片段和文件信息



#include?
#include?
#include?

#define?CELL?20
#define?ROWS?25
#define?COLS?15
//升級所需分數值
#define?SCORE_LEVEL_INC?80
#define?ID_TIMER?1

/////////////////全局變量/////////////////////////////
HWND?hwnd; //保存窗口句柄

int?score=0; //分數
int?level=0; //級數
int?interval_unit=25; //隨級數遞增的時間間隔增量
int?interval_base=300; //時間間隔基量
int?old_interval; //保存當前的時間間隔,用于加速操作

int?cur_leftcur_top; //記錄方塊當前的位置
int?width_blockheight_block; //方塊的寬帶和高度

bool?isPause=false; //暫停標識
UINT?timer_id=0; //保存計時器ID

static?byte?*block=NULL; //方塊,方塊為隨機大小,采用動態分配內存方式,所以這里是指針變量
byte?g_panel[ROWS][COLS]={0};
////////////////////////////////////////////////////
LRESULT?CALLBACK?WndProc?(?HWNDUINTWPARAMLPARAM?);
void?DrawPanel?(?HDC?hdc?); //繪制表格
void?RefreshPanel?(?HDC?hdc?); //刷新面板
void?DoDownShift?(?HDC?hdc?); //下移
void?DoLeftShift?(?HDC?hdc?); //左移
void?DoRightShift?(?HDC?hdc?); //右移
void?DoAccelerate?(?HDC?hdc?); //加速
void?DoRedirection?(?HDC?hdc?); //改變方向
void?ClearRow?(?HDC?hdc?); //消行
bool?ExportBlock(); //輸出方塊,
//該函數會直接修改全局變量blockwidth_blockheight_block
//cur_left和cur_top
bool?IsTouchBottom?(?HDC?hdc?); //判斷是否到達底部

int?main()
{
HINSTANCE?hInstance=GetModuleHandle?(?NULL?);
TCHAR?szAppName[]=TEXT?(?“teris“?);
MSG?msg;
WNDCLASS?wc;

wc.style=CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc=WndProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInstance;
wc.hIcon=LoadIcon?(?NULLIDI_APPLICATION?);
wc.hCursor=LoadCursor?(?NULLIDC_ARROW?);
wc.hbrBackground=?(?HBRUSH?)?GetStockobject?(?WHITE_BRUSH?);
wc.lpszMenuName=NULL;
wc.lpszClassName=szAppName;
if?(?!RegisterClass?(?&wc?)?)
{
printf?(?“RegisterClass?occur?errors!“?);
return?0;
}
hwnd=CreateWindow?(?szAppNameTEXT?(?“Teris?Demo“?)
????????????????????WS_OVERLAPPEDWINDOW
????????????????????0000
????????????????????NULL
????????????????????NULL
????????????????????hInstance
????????????????????NULL?);
ShowWindow?(?hwndSW_SHOW?);
UpdateWindow?(?hwnd?);
while?(?GetMessage?(?&msgNULL00?)?)
{
TranslateMessage?(?&msg?);
DispatchMessage?(?&msg?);
}
return?msg.wParam;
}

void?DrawPanel?(?HDC?hdc?)?? //繪制游戲面板
{
int?xy;
RECT?rect;

for?(?y=0;?y {
for?(?x=0;?x {
//計算方塊的邊框范圍
rect.top=y*CELL+1;
rect.bottom=?(?y+1?)?*CELL-1;
rect.left=x*CELL+1;
rect.right=?(?x+1?)?*CELL-1;
frameRect?(?hdc&rect?(?HBRUSH?)?GetStockobject?(?BLACK_BRUSH?)?);
}
}
}

void?DoDownShift?(?HDC?hdc?)?? //下移
{
if?(?NULL==block?)?return;

//判斷是否到達底部
if?(?IsTouchBottom?(?hdc?)?)?? //到底部
{
//消行處理
ClearRow?(?hdc?);
ExportBlock(); //輸出下一個方塊
}

cur_top++;
RefreshPanel?(?hdc?);
}

void?DoLeftShift?(?HDC?hdc?)?? //左移
{
int?xy;
if?(?NULL==block?)?return;

if?(?0==cur_left?)?return;
if?(?cur_top<0?)?return; //方塊沒有完整顯示前,不能左移
for?(?y=0;?y {
for?(?x=0;?x<

評論

共有 條評論