diff --git a/Tetris/Resource.h b/Tetris/Resource.h index 8b237da..ffe2f69 100644 --- a/Tetris/Resource.h +++ b/Tetris/Resource.h @@ -24,6 +24,11 @@ #define IDB_RIGHTCOL 332 #define IDB_MIDDLE 333 #define IDB_START_BK 335 +#define IDR_UPGRADE_WAVE 345 +#define IDR_BGM_WAVE 346 +#define IDR_FAIL_WAVE 349 +#define IDR_WAVE2 350 +#define IDR_VICTORY_WAVE 350 #define IDC_BUTTON1 1000 #define IDC_LEVEL_EDIT 1001 #define IDC_NAME_EDIT 1002 @@ -71,7 +76,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 344 +#define _APS_NEXT_RESOURCE_VALUE 351 #define _APS_NEXT_COMMAND_VALUE 32793 #define _APS_NEXT_CONTROL_VALUE 1017 #define _APS_NEXT_SYMED_VALUE 310 diff --git a/Tetris/Rule.cpp b/Tetris/Rule.cpp index 51b60c7..2aa1fb0 100644 --- a/Tetris/Rule.cpp +++ b/Tetris/Rule.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "Rule.h" #include - +#include "resource.h" CRule::CRule() { m_nLevel = 1; @@ -19,11 +19,10 @@ void CRule::SetLevel(int nLevel) int CRule::UpLevel(int nLine, int &countline) { - LPCWSTR UPM = L".\\sound\\upgrade.wav"; if (nLine / 2) //如果可以整除,等级升级 { m_nLevel++; - sndPlaySound(UPM, SND_ASYNC); + PlaySound((LPCTSTR)IDR_UPGRADE_WAVE, AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC); countline = 0; // 行数清零 } @@ -32,11 +31,9 @@ int CRule::UpLevel(int nLine, int &countline) bool CRule::Win(int Now[4][4], int Russia[100][100], CPoint NowPosition) { - LPCWSTR VM = L".\\sound\\victory.wav"; - LPCWSTR FM = L".\\sound\\fail.wav"; if (m_nLevel == 11) //游戏等级超过最高 { //超过10级游戏结束 - sndPlaySound(VM, SND_ASYNC); + PlaySound((LPCTSTR)IDR_VICTORY_WAVE, AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC); return true; } @@ -48,7 +45,7 @@ bool CRule::Win(int Now[4][4], int Russia[100][100], CPoint NowPosition) {//到了顶点 if (Russia[i + NowPosition.x][j + NowPosition.y] == 1) { - sndPlaySound(FM, SND_ASYNC); + PlaySound((LPCTSTR)IDR_FAIL_WAVE, AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC); return true; //游戏结束 } } diff --git a/Tetris/Russia.cpp b/Tetris/Russia.cpp index 82edfbe..c137c73 100644 --- a/Tetris/Russia.cpp +++ b/Tetris/Russia.cpp @@ -138,21 +138,21 @@ void CRussia::Move(int direction) bool CRussia::Change(int a[][4], CPoint p, int b[][100]) { int tmp[4][4]; - int i, j; + // int i, j; int k = 4, l = 4; - for (i = 0; i<4; i++) + for (int i = 0; i<4; i++) { - for (j = 0; j<4; j++) + for (int j = 0; j<4; j++) { tmp[i][j] = a[j][3 - i]; After[i][j] = 0; //存放变换后的方块矩阵 } } - for (i = 0; i<4; i++) + for (int i = 0; i<4; i++) { - for (j = 0; j<4; j++) + for (int j = 0; j<4; j++) { if (tmp[i][j] == 1) { @@ -161,17 +161,17 @@ bool CRussia::Change(int a[][4], CPoint p, int b[][100]) } } } - for (i = k; i<4; i++) + for (int i = k; i<4; i++) { - for (j = l; j<4; j++) + for (int j = l; j<4; j++) { After[i - k][j - l] = tmp[i][j]; } //把变换后的矩阵移到左上角 } //判断是否接触,是:返回失败 - for (i = 0; i<4; i++) + for (int i = 0; i<4; i++) { - for (j = 0; j<4; j++) + for (int j = 0; j<4; j++) { if (After[i][j] == 0) { diff --git a/Tetris/Tetris.rc b/Tetris/Tetris.rc index 20aba86..68d1d20 100644 --- a/Tetris/Tetris.rc +++ b/Tetris/Tetris.rc @@ -372,6 +372,20 @@ BEGIN END +///////////////////////////////////////////////////////////////////////////// +// +// WAVE +// + +IDR_UPGRADE_WAVE WAVE "Sound\\upgrade.wav" + +IDR_BGM_WAVE WAVE "Sound\\BGM.wav" + +IDR_FAIL_WAVE WAVE "Sound\\fail.wav" + +IDR_VICTORY_WAVE WAVE "Sound\\victory.wav" + + ///////////////////////////////////////////////////////////////////////////// // // String Table diff --git a/Tetris/Tetris.vcxproj b/Tetris/Tetris.vcxproj index 1a41199..a180037 100644 --- a/Tetris/Tetris.vcxproj +++ b/Tetris/Tetris.vcxproj @@ -226,7 +226,10 @@ + + + @@ -254,6 +257,12 @@ + + + + + + diff --git a/Tetris/Tetris.vcxproj.filters b/Tetris/Tetris.vcxproj.filters index bbcd7f7..2a1210e 100644 --- a/Tetris/Tetris.vcxproj.filters +++ b/Tetris/Tetris.vcxproj.filters @@ -111,6 +111,15 @@ Resource Files + + Resource Files + + + Resource Files + + + Resource Files + @@ -179,4 +188,18 @@ Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + + Resource Files + + \ No newline at end of file diff --git a/Tetris/TetrisView.cpp b/Tetris/TetrisView.cpp index ad93869..1be75c7 100644 --- a/Tetris/TetrisView.cpp +++ b/Tetris/TetrisView.cpp @@ -309,8 +309,7 @@ void CTetrisView::OnGameLevel() void CTetrisView::OnBkmusicOn() { // 打开背景音乐 - LPCWSTR BGM = L".\\sound\\BGM.wav"; - sndPlaySound(BGM, SND_ASYNC | SND_LOOP); + PlaySound((LPCTSTR)IDR_BGM_WAVE, AfxGetInstanceHandle(), SND_RESOURCE | SND_SYNC | SND_LOOP); }