重新细分项目结构

This commit is contained in:
2026-04-23 19:08:06 +08:00
parent 35c2fab170
commit 05e9f30c15
20 changed files with 55 additions and 48 deletions
+57
View File
@@ -0,0 +1,57 @@
// Tetris.cpp : 程序入口、窗口初始化与消息处理
#include "stdafx.h"
#include "Tetris.h"
#define MAX_LOADSTRING 100
HINSTANCE hInst;
TCHAR szTitle[MAX_LOADSTRING];
TCHAR szWindowClass[MAX_LOADSTRING];
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
// TODO(作业1): 补全 Win32 程序入口函数。
return 0;
}
ATOM MyRegisterClass(HINSTANCE hInstance)
{
// TODO(作业2): 注册窗口类。
UNREFERENCED_PARAMETER(hInstance);
return 0;
}
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
// TODO(作业3): 创建并显示主窗口。
UNREFERENCED_PARAMETER(hInstance);
UNREFERENCED_PARAMETER(nCmdShow);
return FALSE;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO(作业4): 补全主窗口消息处理函数。
return DefWindowProc(hWnd, message, wParam, lParam);
}
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
// TODO(作业5): 补全“关于”对话框的消息处理。
UNREFERENCED_PARAMETER(hDlg);
UNREFERENCED_PARAMETER(message);
UNREFERENCED_PARAMETER(wParam);
return (INT_PTR)FALSE;
}
+148
View File
@@ -0,0 +1,148 @@
#include "stdafx.h"
#include "Tetris.h"
int nType = 0;
int type = 0;
int state = 0;
int tScore = 0;
bool gameOverFlag = false;
bool suspendFlag = false;
bool targetFlag = false;
int workRegion[20][10] = { 0 };
Point point = { 0, 0 };
Point target = { 0, 0 };
int bricks[7][4][4][4] =
{
{
{{0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
{{0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}},
{{0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}}
},
{
{{0, 0, 0, 0}, {0, 0, 2, 0}, {0, 2, 2, 2}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 0, 2, 0}, {0, 0, 2, 2}, {0, 0, 2, 0}},
{{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 2, 2, 2}, {0, 0, 2, 0}},
{{0, 0, 0, 0}, {0, 0, 2, 0}, {0, 2, 2, 0}, {0, 0, 2, 0}}
},
{
{{0, 3, 0, 0}, {0, 3, 0, 0}, {0, 3, 3, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {3, 3, 3, 0}, {3, 0, 0, 0}, {0, 0, 0, 0}},
{{3, 3, 0, 0}, {0, 3, 0, 0}, {0, 3, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 3, 0}, {3, 3, 3, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
},
{
{{0, 0, 4, 0}, {0, 0, 4, 0}, {0, 4, 4, 0}, {0, 0, 0, 0}},
{{0, 4, 0, 0}, {0, 4, 4, 4}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 4, 4}, {0, 0, 4, 0}, {0, 0, 4, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 4, 4, 4}, {0, 0, 0, 4}, {0, 0, 0, 0}}
},
{
{{0, 0, 0, 0}, {0, 5, 5, 0}, {0, 5, 5, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 5, 5, 0}, {0, 5, 5, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 5, 5, 0}, {0, 5, 5, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 5, 5, 0}, {0, 5, 5, 0}, {0, 0, 0, 0}}
},
{
{{0, 6, 0, 0}, {0, 6, 6, 0}, {0, 0, 6, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 6, 6, 0}, {6, 6, 0, 0}, {0, 0, 0, 0}},
{{6, 0, 0, 0}, {6, 6, 0, 0}, {0, 6, 0, 0}, {0, 0, 0, 0}},
{{0, 6, 6, 0}, {6, 6, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}
},
{
{{0, 0, 7, 0}, {0, 7, 7, 0}, {0, 7, 0, 0}, {0, 0, 0, 0}},
{{0, 7, 7, 0}, {0, 0, 7, 7}, {0, 0, 0, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 7}, {0, 0, 7, 7}, {0, 0, 7, 0}, {0, 0, 0, 0}},
{{0, 0, 0, 0}, {0, 7, 7, 0}, {0, 0, 7, 7}, {0, 0, 0, 0}}
}
};
COLORREF BrickColor[7] =
{
RGB(255, 0, 0),
RGB(0, 255, 0),
RGB(0, 0, 255),
RGB(0, 255, 255),
RGB(255, 150, 0),
RGB(255, 255, 0),
RGB(168, 0, 168)
};
bool CanMoveDown()
{
// TODO(作业6): 判断当前方块是否可以继续下落。
return true;
}
bool CanMoveLeft()
{
// TODO(作业7): 判断当前方块是否可以向左移动。
return true;
}
bool CanMoveRight()
{
// TODO(作业8): 判断当前方块是否可以向右移动。
return true;
}
void MoveDown()
{
// TODO(作业9): 方块下移一格。
point.y = point.y;
}
void MoveLeft()
{
// TODO(作业10): 方块左移一格。
point.x = point.x;
}
void MoveRight()
{
// TODO(作业11): 方块右移一格。
point.x = point.x;
}
void Rotate()
{
// TODO(作业12): 旋转当前方块。
}
void DropDown()
{
// TODO(作业13): 实现“一键到底”。
}
void Fixing()
{
// TODO(作业14): 将当前方块固定到工作区,并生成下一个方块。
}
void DeleteOneLine(int number)
{
// TODO(作业15): 删除指定行,并让其上方所有行整体下移。
UNREFERENCED_PARAMETER(number);
}
void DeleteLines()
{
// TODO(作业16): 完成消行与计分逻辑。
}
bool GameOver()
{
// TODO(作业17): 判断游戏是否结束。
return false;
}
void ComputeTarget()
{
// TODO(作业18): 计算瞄准器的预测落点。
}
void Restart()
{
// TODO(作业19): 重置游戏状态。
}
+9
View File
@@ -0,0 +1,9 @@
#include "stdafx.h"
#include "Tetris.h"
void TDrawScreen(HDC hdc, HWND hWnd)
{
// TODO(作业20): 完整绘制游戏界面。
UNREFERENCED_PARAMETER(hdc);
UNREFERENCED_PARAMETER(hWnd);
}
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : 只包括标准包含文件的源文件
// Tetris.pch 将作为预编译头
// stdafx.obj 将包含预编译类型信息
#include "stdafx.h"
// TODO: 在 STDAFX.H 中
// 引用任何所需的附加头文件,而不是在此文件中引用