剛寫的乙個俄羅斯方塊程式

2021-04-08 18:12:43 字數 3453 閱讀 7158

這是我做的:

#define win32_lean_and_mean

#include

#include

#include

#define  id_timer 1

#define  white    0

#define  black    1

int level=1;

int score=0;

int global[18][16];

int diamond[4][2];

int current_max=18;

int current_type=0;

int xbase,ybase;

int game_over;

#include "mmsystem.h"

int i;

bool init(char * title,int xstart,int ystart,int width,int height);   //window initialization

void drawunit(hwnd hwnd,int m,int n,int color);

void drawdiamond(int color);

void initdiamond(hwnd hwnd,int a,int b,int current_type);

void downline(hwnd hwnd,int baseline); //all rows above the success row down one stair

bool checkleft();

void moveleft();

bool checkright();

void moveright();

void downquickly();

void rotate();

lresult callback wndproc(hwnd,uint,wparam,lparam);

int winapi winmain(hinstance hinstance,hinstance previnstance,pstr szcmdline,int icmdshow)

showwindow(hwnd,sw_show);

updatewindow(hwnd);

return true;

}lresult callback wndproc(hwnd hwnd,uint message,wparam wparam,lparam lparam)

else

if(dwerror=mcisendcommand(wmidideviceid,mci_play,mci_notify,(dword)(lpvoid)&mciplayparams))

return 0;

case wm_keydown:

switch(wparam)

break;

case vk_right:

if(checkright())

break;

case vk_up:      //rotate

rotate();

break;

case vk_down:

downquickly();

break;

}return 0;

case wm_timer:

if(done)

srand((unsigned)time(null));

current_type=rand()%19;

xbase=0;

ybase=7;

initdiamond(hwnd,xbase,ybase,current_type);

drawdiamond(black);

down=true;

done=false;

}else

}if(down==true)    //then refresh

drawdiamond(black);

}else

else}}

if(diamond[0][0]!=0 && diamond[0][1]!=0)

}return 0;

case wm_destroy:

postquitmessage(0);

return 0;

}return defwindowproc(hwnd,message,wparam,lparam);

}void drawunit(hwnd hwnd,int m,int n,int color)

rectangle(hdcnow,32*n+150,32*m,32*n+150+32,32*m+32);

releasedc(hwnd,hdcnow);

}void drawdiamond(int color)

void initdiamond(hwnd hwnd,int a,int b,int current_type)

diamond[0][0]=a;

diamond[0][1]=b;

diamond[1][0]=c; 

diamond[1][1]=d;

diamond[2][0]=e;

diamond[2][1]=f;

diamond[3][0]=g;

diamond[3][1]=h;

}void downline(hwnd hwnd,int baseline)

else*/}

}invalidaterect(hwnd,null,false);

}bool checkleft()

}return canleft;

}void moveleft()

drawdiamond(black);

}bool checkright()

}return canright;

}void moveright()

drawdiamond(black);

}void downquickly()

}if(down==true)

drawdiamond(black);}}

void rotate()

}bool can_rotate=true;

xbase=diamond[0][0];

ybase=diamond[0][1];

switch(current_type)

initdiamond(hwnd,xbase,ybase,new_type);

for(m=0;m<4;m++)

}if(current_type!=8 && can_rotate==true)

}drawdiamond(white);

current_type=new_type;

initdiamond(hwnd,xbase,ybase,current_type);

drawdiamond(black);

}if(can_rotate==false)     //restore the diamond}}

}

俄羅斯方塊分步程式

按照物件導向方法,對遊戲進行細分,可以分為小區域和大塊,大塊由小區域組成 using system using system.collections.generic using system.componentmodel using system.data using system.drawing ...

用python寫乙個俄羅斯方塊小遊戲

感覺還是蠻好玩吧!接下來,我就分享一下這個遊戲的原始碼過程啊!先用python建立乙個py檔案 定義這次程式所需要的類 import sys import time import pygame from pygame.localsimport import blocks 然後寫出它所需要的模組 si...

乙個簡單的俄羅斯方塊實現

最近在看 net遊戲程式設計入門經典 c 篇 第一章介紹了如何製作俄羅斯方塊,自己試了試按照書上的步驟,可算是完成了。於是寫下這篇文章留作紀念。1.類的設計 在充分分析遊戲的特點後,遊戲大概可以分為3個類 square小正方形,block由4個小正方形組合成的乙個圖形,gamefield遊戲的驅動引...