terris.rar

  • PUDN用户
    了解作者
  • Visual C++
    开发工具
  • 1.2MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 5
    下载次数
  • 2009-11-21 17:48
    上传日期
我们平时玩的俄罗斯方块游戏,用C语言的形式通过API函数编写的,
terris.rar
  • 俄罗斯方块源程序API(部分注释)
  • Debug
  • terris.pch
    3.4MB
  • Terris.obj
    58.9KB
  • vc60.idb
    137KB
  • terris.exe
    208.1KB
  • vc60.pdb
    76KB
  • terris.pdb
    417KB
  • rsrc.res
    4.4KB
  • terris.ilk
    242.8KB
  • terris.opt
    48.5KB
  • rsrc.rc
    3.4KB
  • TerrisBig.ico
    1.1KB
  • rsrc.aps
    6.7KB
  • TerrisSmall.ico
    2.2KB
  • terris.ncb
    57KB
  • hand.cur
    326B
  • terris.h
    3KB
  • resource.h
    451B
  • terris.plg
    246B
  • terris.dsw
    537B
  • terris.dsp
    3.8KB
  • Terris.cpp
    41.5KB
内容介绍
#include <windows.h> #include <time.h> #include "terris.h" const char MenuName[]=TEXT("TerrisMenu"); int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst, LPSTR CommandLine,int CommandShow) { MSG msg; if(!InitClass(hInstance)) return (0); if(!InitWindow(hInstance)) return (0); while(GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (msg.wParam); } BOOL InitClass(HINSTANCE hInstMain) { WNDCLASSEX wc; wc.cbSize=sizeof(WNDCLASSEX); wc.style=CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc=(WNDPROC)(WndProc); wc.cbClsExtra=0; wc.cbWndExtra=0; wc.hInstance=hInstMain; wc.hIcon=LoadIcon(hInstMain,"TerrisBig"); wc.hIconSm=LoadIcon(hInstMain,"TerrisSmall"); wc.hCursor=LoadCursor(NULL,IDC_ARROW); wc.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1); wc.lpszMenuName=MenuName; wc.lpszClassName="Terris"; if (RegisterClassEx(&wc)) return (TRUE); else return (FALSE); } BOOL InitWindow(HINSTANCE hInstMain) { HWND hwnd=CreateWindowEx(WS_EX_CLIENTEDGE, "Terris", "Terris", WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX | WS_VISIBLE, CW_USEDEFAULT,CW_USEDEFAULT,300,460, NULL,NULL,hInstMain,NULL); if(hwnd) return (TRUE); else return (FALSE); } LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { HDC hdc; PAINTSTRUCT ps; static HINSTANCE hInst; static BLOCK BlockArray[ROWS][COLS]; static TimerInterval; static bool FlagGameJustStart = TRUE; switch(uMsg) { case WM_CREATE: hInst=((LPCREATESTRUCT)lParam)->hInstance; TimerInterval = EasyInterval; CheckMenuRadioItem( GetMenu(hWnd), IDM_EASY,IDM_DIFFICULT,IDM_EASY,MF_BYCOMMAND); break; case WM_TIMER: if(NeedGenerateNewBlock(BlockArray)) { KillFullLine(hWnd,BlockArray); if(GameOver(BlockArray)) { KillTimer(hWnd,TIMERID); EnableMenuItem( GetMenu(hWnd ),IDM_START,MF_ENABLED); EnableMenuItem( GetMenu(hWnd ),IDM_PAUSE,MF_GRAYED); FlagGameJustStart = TRUE; ChangeBlockStyleToGray(BlockArray); RefreshWindow(hWnd,BlockArray); MessageBox(hWnd,"对不起,请再来一盘","注意",MB_OK | MB_ICONEXCLAMATION); } else { MoveBlockFromPreviewToGameArea(hWnd,BlockArray); GenerateNewBlock(hWnd,BlockArray); } } else { if (CanBlockMoveDown(BlockArray)) MoveBlockDown(hWnd,BlockArray); else { Moveable2Stable(BlockArray); } } break; case WM_KEYDOWN: if ( GetMenuState(GetMenu(hWnd), IDM_START, MF_BYCOMMAND) != MF_GRAYED ) break; switch(wParam) { case VK_RIGHT: if(CanBlockMoveRight(BlockArray)) { MoveBlockRight(hWnd,BlockArray); } break; case VK_LEFT: if(CanBlockMoveLeft(BlockArray)) { MoveBlockLeft(hWnd,BlockArray); } break; case VK_DOWN: if(CanBlockMoveDown(BlockArray)) { MoveBlockDown(hWnd,BlockArray); } break; case VK_UP: switch(JudgeBlockStyle(BlockArray)) { case 0: RotateStyleZero(hWnd,BlockArray); break; case 1: RotateStyleOne(hWnd,BlockArray); break; case 2: RotateStyleTwo(hWnd,BlockArray); break; case 3: RotateStyleThree(hWnd,BlockArray); break; case 4: RotateStyleFour(hWnd,BlockArray); break; case 5: break; case 6: RotateStyleSix(hWnd,BlockArray); break; } break; } break; case WM_COMMAND: switch (LOWORD (wParam)) { case IDM_START: if ( FlagGameJustStart == TRUE) { InitializeBlock( BlockArray ); RefreshWindow(hWnd, BlockArray ); FlagGameJustStart = FALSE; } SetTimer(hWnd,TIMERID,TimerInterval,NULL); EnableMenuItem( GetMenu(hWnd), IDM_START, MF_GRAYED); EnableMenuItem( GetMenu(hWnd), IDM_PAUSE, MF_ENABLED); break; case IDM_PAUSE: KillTimer(hWnd,TIMERID); EnableMenuItem( GetMenu(hWnd), IDM_START,MF_ENABLED); EnableMenuItem( GetMenu(hWnd), IDM_PAUSE,MF_GRAYED); break; case IDM_EXIT: if ( GetMenuState(GetMenu(hWnd), IDM_START, MF_BYCOMMAND) == MF_GRAYED) KillTimer( hWnd,TIMERID); DestroyWindow(hWnd); break; case IDM_EASY: TimerInterval = EasyInterval; CheckMenuRadioItem( GetMenu(hWnd),IDM_EASY,IDM_DIFFICULT,IDM_EASY,MF_BYCOMMAND); if(GetMenuState(GetMenu(hWnd),IDM_START,MF_BYCOMMAND) == MF_GRAYED) { KillTimer(hWnd,TIMERID); SetTimer(hWnd,TIMERID,TimerInterval,NULL); } break; case IDM_MEDIUM: TimerInterval = MediumInterval; CheckMenuRadioItem( GetMenu(hWnd),IDM_EASY,IDM_DIFFICULT,IDM_MEDIUM,MF_BYCOMMAND); if(GetMenuState(GetMenu(hWnd),IDM_START,MF_BYCOMMAND) == MF_GRAYED) { KillTimer(hWnd,TIMERID); SetTimer(hWnd,TIMERID,TimerInterval,NULL); } break; case IDM_DIFFICULT: TimerInterval = DifficultInterval; CheckMenuRadioItem( GetMenu(hWnd),IDM_EASY,IDM_DIFFICULT,IDM_DIFFICULT,MF_BYCOMMAND); if(GetMenuState(GetMenu(hWnd),IDM_START,MF_BYCOMMAND) == MF_GRAYED) { KillTimer(hWnd,TIMERID); SetTimer(hWnd,TIMERID,TimerInterval,NULL); } break; case IDM_ABOUT: DialogBoxParam(hInst,"DLG_ABOUT",hWnd,\ (DLGPROC)AboutDialogProc,(LPARAM)0); break; } break; case WM_PAINT: hdc=BeginPaint(hWnd,&ps); DrawBackground(hdc); RefreshWindow(hWnd,BlockArray); EndPaint(hWnd,&ps); break; case WM_DESTROY: KillTimer(hWnd,TIMERID); PostQuitMessage(0); break; default: return DefWindowProc(hWnd,uMsg,wParam,lParam); } return (0); } void DrawBackground(HDC hdc) { HBRUSH hBrush; POINT pt[8]; pt[0].x = OriginXPos; pt[0].y = OriginYPos + 4 * BLOCKSIZE; pt[1].x = OriginXPos; pt[1].y = OriginYPos + ROWS * BLOCKSIZE; pt[2].x = pt[1].x + COLS * BLOCKSIZE; pt[2].y = pt[1].y; pt[3].x = pt[2].x; pt[3].y = pt[0].y; pt[4].x = pt[3].x + 5; pt[4].y = pt[3].y; pt[5].x = pt[4].x; pt[5].y = pt[2].y + 5; pt[6].x = pt[0].x - 5; pt[6].y = pt[1].y + 5; pt[7].x = pt[6].x; pt[7].y = pt[0].y; SelectObject(hdc,GetStockObject(NULL_PEN)); SelectObject(hdc,GetStockObject(WHITE_BRUSH)); Polygon(hdc,pt,8); SelectObject(hdc,GetStockObject(BLACK_BRUSH)); Polygon(hdc,pt,4); pt[0].x=OriginXPos; pt[0].y=OriginYPos; pt[1].x=pt[0].x + BLOCKSIZE * COLS; pt[1].y=pt[0].y; pt[2].x=pt[1].x; pt[2].y=pt[1].y + BLOCKSIZE * 4; pt[3].x=pt[0].x; pt[3].y=pt[2].y; hBrush=CreateSolidBrush(GetPixel(hdc,0,0)); SelectObject(hdc,hBrush); Polygon(hdc,pt,4); SelectObject(hdc,GetStockObject(BLACK_PEN)); SelectObject(hdc,GetStockObject(NULL_BRUSH)); DeleteObject(hBrush); } void DrawBlock(HDC hdc,int row,int column,int BlockStyle) { POINT pt[4]; COLORREF BrightBrushColor[8]={RGB(255,0,0),RGB(0,255,0),RGB(0,0,255),\ RGB(0,255,255),RGB(255,0,255),RGB(255,255,0),\ RGB(200,200,200),RGB(200,200,200)}; COLORREF MediumBrushColor[8]={RGB(180,0,0),RGB(0,180,0),RGB(0,0,180),\ RGB(0,200,200),RGB(200,0,200),RGB(200,200,0),\ RGB(90,90,90),RGB(140,140,140)}; COLORREF DarkBrushColor[8]={RGB(90,0,0),RGB(0,90,0),RGB(0,0,90),\ RGB(0,90,90),RGB(90,0,90),RGB(90,90,0),\ RGB(40,40,40),RGB(100,100,100)}; HBRUSH hBrushBright,hBrushMedium,hBrushDark; hBrushBright=CreateSolidBrush(BrightBrushColor[BlockStyle]); hBrushMedium=CreateS
评论
    相关推荐
    • terris.zip
      一个使用Windows API编写的俄罗斯方块的游戏。对与初学Windows 编程的人来说是个不错的参考。
    • 游戏俄罗斯方块.rar
      游戏,俄罗斯方块,非常经典的游戏,老少皆宜
    • terris.rar
      同3++写成的d3d的俄罗斯方块........功能一般
    • Terris.rar
      J2ME实现的俄罗斯方块,在netbeans中实现
    • Terris.rar
      这是一个j2me游戏j2me俄罗斯方块,对于初学者有很好的帮助。
    • 用C++编写的简易版的俄罗斯方块小游戏
      用C++语言自己写的俄罗斯方块小游戏,需要用编写C++的工具运行后才能玩,主要是想练习自己编写C++代码的能力,跟大家一起分享。
    • 自己修改后的俄罗斯方块
      NULL 博文链接:https://yu-chuang.iteye.com/blog/900649
    • ADTQ.rar
      游戏,俄罗斯方块,非常经典的游戏,老少皆宜,挺好的
    • and.rar
      游戏,俄罗斯方块,非常经典的游戏,老少皆宜,挺好的
    • snowglobe-src-viewer-2.0.0-r0.tar.gz
      国外的开源游戏引擎,能够承载上千人,属于社交类的游戏