各个悟俄罗斯方块258关

c\u8bed\u8a00\u4fc4\u7f57\u65af\u65b9\u5757\u4ee3\u7801

#include #include #include #include #include #ifdef __cplusplus #define __CPPARGS ... #else #define __CPPARGS #endif #define MINBOXSIZE 15 /* \u6700\u5c0f\u65b9\u5757\u7684\u5c3a\u5bf8 */ #define BGCOLOR 7 /* \u80cc\u666f\u7740\u8272 */ #define GX 200 #define GY 10 #define SJNUM 10000 /* \u6bcf\u5f53\u73a9\u5bb6\u6253\u5230\u4e00\u4e07\u5206\u7b49\u7ea7\u52a0\u4e00\u7ea7*/ /* \u6309\u952e\u7801*/ #define VK_LEFT 0x4b00 #define VK_RIGHT 0x4d00 #define VK_DOWN 0x5000 #define VK_UP 0x4800 #define VK_HOME 0x4700 #define VK_END 0x4f00 #define VK_SPACE 0x3920 #define VK_ESC 0x011b #define VK_ENTER 0x1c0d /* \u5b9a\u4e49\u4fc4\u7f57\u65af\u65b9\u5757\u7684\u65b9\u5411\uff08\u6211\u5b9a\u4e49\u4ed6\u4e3a4\u79cd\uff09*/ #define F_DONG 0 #define F_NAN 1 #define F_XI 2 #define F_BEI 3 #define NEXTCOL 20 /* \u8981\u51fa\u7684\u4e0b\u4e00\u4e2a\u65b9\u5757\u7684\u7eb5\u5750\u6807*/ #define NEXTROW 12 /* \u8981\u51fa\u7684\u4e0b\u4e00\u4e2a\u65b9\u5757\u7684\u6a2a\u4ece\u6807*/ #define MAXROW 14 /* \u6e38\u620f\u5c4f\u5e55\u5927\u5c0f*/ #define MAXCOL 20 #define SCCOL 100 /*\u6e38\u620f\u5c4f\u5e55\u5927\u663e\u793a\u5668\u4e0a\u7684\u76f8\u5bf9\u4f4d\u7f6e*/ #define SCROW 60 int gril[22][16]; /* \u6e38\u620f\u5c4f\u5e55\u5750\u6807*/ int col=1,row=7; /* \u5f53\u524d\u65b9\u5757\u7684\u6a2a\u7eb5\u5750\u6807*/ int boxfx=0,boxgs=0; /* \u5f53\u524d\u5bfa\u5757\u7684\u5f62\u58ee\u548c\u65b9\u5411*/ int nextboxfx=0,nextboxgs=0,maxcol=22;/*\u4e0b\u4e00\u4e2a\u65b9\u5757\u7684\u5f62\u58ee\u548c\u65b9\u5411*/ int minboxcolor=6,nextminboxcolor=6; int num=0; /*\u6e38\u620f\u5206*/ int dj=0,gamedj[10]={18,16,14,12,10,8,6,4,2,1};/* \u6e38\u620f\u7b49\u7ea7*/ /* \u4ee5\u4e0b\u6211\u7528\u4e86\u4e00\u4e2a3\u7ef4\u6570\u7ec4\u6765\u7eaa\u5f55\u65b9\u5757\u7684\u6700\u521d\u5f62\u72b6\u548c\u65b9\u5411*/ int boxstr[7][4][16]={{ {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}, {0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0}, {1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0}, {0,1,0,0,1,1,0,0,1,0,0,0,0,0,0,0}}, { {0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0}, {1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0}, {0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0}, {1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0}}, { {1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0}, {1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0}, {1,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0}, {0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0}}, { {1,1,0,0,1,0,0,0,1,0,0,0,0,0,0,0}, {1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0}, {0,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0}, {1,1,1,0,0,0,1,0,0,0,0,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,1,1,1,1,0,0,0,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,1,1,1,1,0,0,0,0,0,0,0,0}}, { {1,1,0,0,1,1,0,0,0,0,0,0.0,0,0,0}, {1,1,0,0,1,1,0,0,0,0,0,0.0,0,0,0}, {1,1,0,0,1,1,0,0,0,0,0,0.0,0,0,0}, {1,1,0,0,1,1,0,0,0,0,0,0.0,0,0,0}}, { {0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0}, {1,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0}, {0,1,0,0,1,1,1,0,0,0,0,0.0,0,0,0}, {0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0}} }; /* \u968f\u673a\u5f97\u5230\u5f53\u524d\u65b9\u5757\u548c\u4e0b\u4e00\u4e2a\u65b9\u5757\u7684\u5f62\u72b6\u548c\u65b9\u5411*/ void boxrad(){ minboxcolor=nextminboxcolor; boxgs=nextboxgs; boxfx=nextboxfx; nextminboxcolor=random(14)+1; if(nextminboxcolor==4||nextminboxcolor==7||nextminboxcolor==8) nextminboxcolor=9; nextboxfx=F_DONG; nextboxgs=random(7); } /*\u521d\u59cb\u5316\u56fe\u5f62\u6a21\u8bd5*/ void init(int gdrive,int gmode){ int errorcode; initgraph(&gdrive,&gmode,"e:\\tc"); errorcode=graphresult(); if(errorcode!=grOk){ printf("error of: %s",grapherrormsg(errorcode)); exit(1); } } /* \u5728\u56fe\u5f62\u6a21\u5f0f\u4e0b\u7684\u6e05\u5c4f */ void cls() { setfillstyle(SOLID_FILL,0); setcolor(0); bar(0,0,640,480); } /*\u5728\u56fe\u5f62\u6a21\u5f0f\u4e0b\u7684\u9ad8\u7ea7\u6e05\u5c4f*/ void clscr(int a,int b,int c,int d,int color){ setfillstyle(SOLID_FILL,color); setcolor(color); bar(a,b,c,d); } /*\u6700\u5c0f\u65b9\u5757\u7684\u7ed8\u5236*/ void minbox(int asc,int bsc,int color,int bdcolor){ int a=0,b=0; a=SCCOL+asc; b=SCROW+bsc; clscr(a+1,b+1,a-1+MINBOXSIZE,b-1+MINBOXSIZE,color); if(color!=BGCOLOR){ setcolor(bdcolor); line(a+1,b+1,a-1+MINBOXSIZE,b+1); line(a+1,b+1,a+1,b-1+MINBOXSIZE); line(a-1+MINBOXSIZE,b+1,a-1+MINBOXSIZE,b-1+MINBOXSIZE); line(a+1,b-1+MINBOXSIZE,a-1+MINBOXSIZE,b-1+MINBOXSIZE); } } /*\u6e38\u620f\u4e2d\u51fa\u73b0\u7684\u6587\u5b57*/ void txt(int a,int b,char *txt,int font,int color){ setcolor(color); settextstyle(0,0,font); outtextxy(a,b,txt); } /*windows \u7ed8\u5236*/ void win(int a,int b,int c,int d,int bgcolor,int bordercolor){ clscr(a,b,c,d,bgcolor); setcolor(bordercolor); line(a,b,c,b); line(a,b,a,d); line(a,d,c,d); line(c,b,c,d); } /* \u5f53\u524d\u65b9\u5757\u7684\u7ed8\u5236*/ void funbox(int a,int b,int color,int bdcolor){ int i,j; int boxz[4][4]; for(i=0;i1;i--) for(j=1;j=0;i--) for(j=3;j>=0;j--) if(a[j] && gril[col+i][row+j]) k=0; return(k); } /*\u5f53\u524d\u65b9\u5757\u843d\u4e0b\u4e4b\u540e\uff0c\u7ed9\u5c4f\u5e55\u5750\u6807\u4f5c\u6807\u8bb0*/ void setgril(){ int i,j,a[4][4]; funbox(0,0,minboxcolor,0); for(i=0;i0;i--) for(j=1;j3) boxfx=0; funbox(0,0,minboxcolor,0); break; } case VK_LEFT:{ /*\u5de6\u65b9\u5411\u952e\uff0c\u7eb5\u5750\u6807\u51cf\u4e00*/ if(leftok()) row--; funbox(0,0,minboxcolor,0); break; } case VK_RIGHT:{ /*\u53f3\u65b9\u5411\u952e\uff0c\u7eb5\u5750\u6807\u52a0\u4e00*/ if(rightok()) row++; funbox(0,0,minboxcolor,0); break; } case VK_SPACE: /*\u7a7a\u683c\u952e\uff0c\u76f4\u63a5\u843d\u5230\u6700\u540e\u53ef\u4ee5\u843d\u5230\u7684\u4eec\u7f6e*/ while(downok()) col++; funbox(0,0,minboxcolor,0); setgril(); nextfunbox(NEXTCOL,NEXTROW,4,4); boxrad(); nextfunbox(NEXTCOL,NEXTROW,nextminboxcolor,0); delete(); break; default: { txt(423,53,"worng key!",1,4); txt(428,80,"Plese Enter Anly Key AG!",1,4); getch(); clscr(420,50,622,97,BGCOLOR); } } } /*\u65f6\u95f4\u4e2d\u65ad\u5f00\u59cb*/ void timezd(void){ int key; SetTimer(newhandler); boxrad(); nextfunbox(NEXTCOL,NEXTROW,nextminboxcolor,0); for(;;){ if(bioskey(1)){ key=bioskey(0); funbox(0,0,BGCOLOR,BGCOLOR); if(key==VK_ESC) break; call_key(key); } if(TimerCounter>gamedj[dj]){ TimerCounter=0; if(downok()){ funbox(0,0,BGCOLOR,BGCOLOR); col++; funbox(0,0,minboxcolor,0); } else { if(col==1){ gameover(); getch(); break; } setgril(); delete(); funbox(0,0,minboxcolor,0); col=1;row=7; funbox(0,0,BGCOLOR,BGCOLOR); nextfunbox(NEXTCOL,NEXTROW,4,4); boxrad(); nextfunbox(NEXTCOL,NEXTROW,nextminboxcolor,0); } } } } /*\u4e3b\u7a0b\u5e8f\u5f00\u59cb*/ void main(void){ int i,j; char *nm="00000"; init(VGA,VGAHI); cls(); /*\u5c4f\u5e55\u5750\u6807\u521d\u59cb\u5316*/ for(i=0;i<=MAXCOL+1;i++) for(j=0;j<=MAXROW+1;j++) gril[i][j]=0;for(i=0;i<=MAXCOL+1;i++) { gril[i][0]=1;gril[i][15]=1;} for(j=1;j<=MAXROW;j++){ gril[0][j]=1; gril[21][j]=1; } clscr(0,0,640,480,15); win(1,1,639,479,4,15); win(SCCOL+MINBOXSIZE-2,SCROW+MINBOXSIZE-2,SCCOL+15*MINBOXSIZE+2,SCROW+21*MINBOXSIZE+2,BGCOLOR,0); nextboxgs=random(8); nextboxfx=random(4); sprintf(nm,"%d",num); txt(456,173,"Number:",1,15); txt(456,193,nm,1,15); txt(456,243,"Next Box:",1,15); timezd(); KillTimer(); closegraph(); getch();}

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Tetris_CS
{
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel screenPanel;
private System.Windows.Forms.Panel nextPanel;
private System.Windows.Forms.Timer timer;
private System.Windows.Forms.MainMenu mainMenu;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem gameMenu;
private System.Windows.Forms.MenuItem startMenu;
private System.Windows.Forms.MenuItem stopMenu;
private System.Windows.Forms.MenuItem exitMenu;
private System.Windows.Forms.MenuItem helpMenu;
private System.Windows.Forms.MenuItem aboutMenu;
private System.ComponentModel.IContainer components;
private Random rndShape = new Random();
private Shape nextShape;
private Body mainBody = new Body();
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label speedLabel;
private System.Windows.Forms.Label scoreLabel;
private GAME_STATUS gameStatus;

private int speed;
private int score;
private System.Windows.Forms.Label linesLabel;
private System.Windows.Forms.PictureBox pictureBox1;
private int lines;

enum GAME_STATUS {GAME_STOP, GAME_RUN, GAME_OVER};

public MainForm()
{
//
// Windows \u7a97\u4f53\u8bbe\u8ba1\u5668\u652f\u6301\u6240\u5fc5\u9700\u7684
//
InitializeComponent();

//
// TODO: \u5728 InitializeComponent \u8c03\u7528\u540e\u6dfb\u52a0\u4efb\u4f55\u6784\u9020\u51fd\u6570\u4ee3\u7801
//
Shape.InitTetrisDefine();
}

///
/// \u6e05\u7406\u6240\u6709\u6b63\u5728\u4f7f\u7528\u7684\u8d44\u6e90\u3002
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// \u8bbe\u8ba1\u5668\u652f\u6301\u6240\u9700\u7684\u65b9\u6cd5 - \u4e0d\u8981\u4f7f\u7528\u4ee3\u7801\u7f16\u8f91\u5668\u4fee\u6539
/// \u6b64\u65b9\u6cd5\u7684\u5185\u5bb9\u3002
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.screenPanel = new System.Windows.Forms.Panel();
this.nextPanel = new System.Windows.Forms.Panel();
this.timer = new System.Windows.Forms.Timer(this.components);
this.mainMenu = new System.Windows.Forms.MainMenu();
this.gameMenu = new System.Windows.Forms.MenuItem();
this.startMenu = new System.Windows.Forms.MenuItem();
this.stopMenu = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.exitMenu = new System.Windows.Forms.MenuItem();
this.helpMenu = new System.Windows.Forms.MenuItem();
this.aboutMenu = new System.Windows.Forms.MenuItem();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.speedLabel = new System.Windows.Forms.Label();
this.linesLabel = new System.Windows.Forms.Label();
this.scoreLabel = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// screenPanel
//
this.screenPanel.BackColor = System.Drawing.Color.White;
this.screenPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.screenPanel.Dock = System.Windows.Forms.DockStyle.Left;
this.screenPanel.Name = "screenPanel";
this.screenPanel.Size = new System.Drawing.Size(206, 305);
this.screenPanel.TabIndex = 0;
//
// nextPanel
//
this.nextPanel.BackColor = System.Drawing.Color.White;
this.nextPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.nextPanel.Location = new System.Drawing.Point(280, 0);
this.nextPanel.Name = "nextPanel";
this.nextPanel.Size = new System.Drawing.Size(104, 96);
this.nextPanel.TabIndex = 1;
//
// timer
//
this.timer.Interval = 300;
this.timer.Tick += new System.EventHandler(this.OnTimer);
//
// mainMenu
//
this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.gameMenu,
this.helpMenu});
//
// gameMenu
//
this.gameMenu.Index = 0;
this.gameMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.startMenu,
this.stopMenu,
this.menuItem4,
this.exitMenu});
this.gameMenu.Text = "\u6587\u4ef6(&F)";
//
// startMenu
//
this.startMenu.Index = 0;
this.startMenu.Text = "\u5f00\u59cb(&S)";
this.startMenu.Click += new System.EventHandler(this.startMenu_Click);
//
// stopMenu
//
this.stopMenu.Enabled = false;
this.stopMenu.Index = 1;
this.stopMenu.Text = "\u505c\u6b62(&T)";
this.stopMenu.Click += new System.EventHandler(this.stopMenu_Click);
//
// menuItem4
//
this.menuItem4.Index = 2;
this.menuItem4.Text = "-";
//
// exitMenu
//
this.exitMenu.Index = 3;
this.exitMenu.Text = "\u9000\u51fa(&X)";
this.exitMenu.Click += new System.EventHandler(this.exitMenu_Click);
//
// helpMenu
//
this.helpMenu.Index = 1;
this.helpMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.aboutMenu});
this.helpMenu.Text = "\u5e2e\u52a9(&H)";
//
// aboutMenu
//
this.aboutMenu.Index = 0;
this.aboutMenu.Text = "\u5173\u4e8eTetris...(&A)";
//
// label1
//
this.label1.Location = new System.Drawing.Point(216, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 16);
this.label1.TabIndex = 2;
this.label1.Text = "\u4e0b\u4e00\u4e2a\uff1a";
//
// label2
//
this.label2.Location = new System.Drawing.Point(216, 120);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 3;
this.label2.Text = "\u5206 \u6570\uff1a";
//
// label3
//
this.label3.Location = new System.Drawing.Point(216, 144);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 16);
this.label3.TabIndex = 4;
this.label3.Text = "\u884c \u6570\uff1a";
//
// label4
//
this.label4.Location = new System.Drawing.Point(216, 168);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 16);
this.label4.TabIndex = 5;
this.label4.Text = "\u901f \u5ea6\uff1a";
//
// speedLabel
//
this.speedLabel.Location = new System.Drawing.Point(288, 168);
this.speedLabel.Name = "speedLabel";
this.speedLabel.Size = new System.Drawing.Size(56, 16);
this.speedLabel.TabIndex = 8;
this.speedLabel.Text = "0";
//
// linesLabel
//
this.linesLabel.Location = new System.Drawing.Point(288, 144);
this.linesLabel.Name = "linesLabel";
this.linesLabel.Size = new System.Drawing.Size(56, 16);
this.linesLabel.TabIndex = 7;
this.linesLabel.Text = "0";
//
// scoreLabel
//
this.scoreLabel.Location = new System.Drawing.Point(288, 120);
this.scoreLabel.Name = "scoreLabel";
this.scoreLabel.Size = new System.Drawing.Size(56, 16);
this.scoreLabel.TabIndex = 6;
this.scoreLabel.Text = "0";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(276, 258);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(36, 28);
this.pictureBox1.TabIndex = 9;
this.pictureBox1.TabStop = false;
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(386, 305);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.pictureBox1,
this.speedLabel,
this.linesLabel,
this.scoreLabel,
this.label4,
this.label3,
this.label2,
this.label1,
this.nextPanel,
this.screenPanel});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.Menu = this.mainMenu;
this.Name = "MainForm";
this.Text = "Tetris";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown);
this.Load += new System.EventHandler(this.MainForm_Load);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.MainFormPaint);
this.ResumeLayout(false);

}
#endregion

///
/// \u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u5165\u53e3\u70b9\u3002
///
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}

public void DrawScreen()
{
if (gameStatus == GAME_STATUS.GAME_RUN || gameStatus == GAME_STATUS.GAME_OVER)
{
ReDrawNextShape();

Graphics grMain = screenPanel.CreateGraphics();
grMain.FillRectangle(new SolidBrush(Color.White), 0, 0, screenPanel.Width, screenPanel.Height);
mainBody.Draw(grMain);
}
if (gameStatus == GAME_STATUS.GAME_STOP || gameStatus == GAME_STATUS.GAME_OVER)
{
Graphics grMain = screenPanel.CreateGraphics();
string logo = "TETRIS";

DrawText(logo, grMain, new Point(20, (int)(screenPanel.Height*0.28)), 30);
}
if (gameStatus == GAME_STATUS.GAME_OVER)
{
Graphics grMain = screenPanel.CreateGraphics();
string logo = "GAME OVER";

DrawText(logo, grMain, new Point(20, (int)(screenPanel.Height*0.42)), 21);
}
}

private void MainFormPaint(object sender, System.Windows.Forms.PaintEventArgs e)
{
DrawScreen();
}

private void OnTimer(object sender, System.EventArgs e)
{
if (gameStatus == GAME_STATUS.GAME_RUN)
{
Graphics grMain = screenPanel.CreateGraphics();
if (mainBody.MoveShape(grMain, Body.MOVE_TYPE.MOVE_DOWN))
{
DisposeShapeDown();
}
}
}

private void startMenu_Click(object sender, System.EventArgs e)
{
StartGame();
}

private void stopMenu_Click(object sender, System.EventArgs e)
{
GameOver();
}

private void exitMenu_Click(object sender, System.EventArgs e)
{
this.Close();
}

public void StartGame()
{
score = 0;
speed = 0;
lines = 0;

ChangeLines(0);
timer.Interval = SpeedToTime(speed);
timer.Enabled = true;
startMenu.Enabled = false;
stopMenu.Enabled = true;
gameStatus = GAME_STATUS.GAME_RUN;
mainBody.Reset();
GetNextShape(true);
DrawScreen();
}

public bool GetNextShape()
{
return GetNextShape(false);
}

private void MainForm_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
int key = e.KeyValue;
bool ret;
Graphics grMain = screenPanel.CreateGraphics();
if (gameStatus == GAME_STATUS.GAME_RUN)
{
switch (key)
{
case 38: // up
ret = mainBody.MoveShape(grMain, Body.MOVE_TYPE.MOVE_ROATE);
break;
case 37: // left
ret = mainBody.MoveShape(grMain, Body.MOVE_TYPE.MOVE_LEFT);
break;
case 39: // right
ret = mainBody.MoveShape(grMain, Body.MOVE_TYPE.MOVE_RIGHT);
break;
case 40: // fall down
ret = mainBody.MoveShape(grMain, Body.MOVE_TYPE.MOVE_FALL);
break;
default:
ret = false;
break;
}
if (ret && key == 40)
{
DisposeShapeDown();
}
}
}

private void MainForm_Load(object sender, System.EventArgs e)
{

}

public bool GetNextShape(bool initGame)
{
int shapeCount = 7;
if (initGame)
{
int indexShape = rndShape.Next(shapeCount);
nextShape = new Shape(indexShape);
}

bool ret = mainBody.SetNextShape(nextShape);
int indNextShape = rndShape.Next(shapeCount);
nextShape = new Shape(indNextShape);
return ret;
}

public void DisposeShapeDown()
{
int count = mainBody.ClearLines();
if (GetNextShape())
{
GameOver();
}

if (count > 0)
{
ChangeLines(count);
DrawScreen();
}
else
{
ReDrawNextShape();
}
}

public void ReDrawNextShape()
{
Graphics grNext = nextPanel.CreateGraphics();
grNext.FillRectangle(new SolidBrush(Color.White), 0, 0, nextPanel.Width, nextPanel.Height);
nextShape.Draw(grNext, nextPanel.Size);

Graphics grMain = screenPanel.CreateGraphics();
mainBody.DrawNextShape(grMain);
}

public void GameOver()
{
gameStatus = GAME_STATUS.GAME_OVER;
timer.Enabled = false;
startMenu.Enabled = true;
stopMenu.Enabled = false;
DrawScreen();
}

public void DrawText(string text, Graphics g, Point pt, int font)
{
Font drawFont = new Font("Courier new", font, FontStyle.Bold);

for (int i=0; i<text.Length; i++)
{
int corIndex = i;
if (i >= 7)
corIndex = i % 7;
SolidBrush drawBrush = new SolidBrush(Block.GetColor(corIndex));
string drawText = new String(' ', i);
drawText += text.Substring(i, 1);
g.DrawString(drawText, drawFont, drawBrush, pt);
}
}

public void ChangeLines(int count)
{
switch (count)
{
case 1:
score += 100;
break;
case 2:
score += 300;
break;
case 3:
score += 500;
break;
case 4:
score += 1000;
break;
default:
break;
}
if ((lines+count) / 30 > lines / 30)
{
speed++;
timer.Interval = SpeedToTime(speed);
}
lines += count;

scoreLabel.Text = score.ToString();
speedLabel.Text = speed.ToString();
linesLabel.Text = lines.ToString();
}

public int SpeedToTime(int nSpeed)
{
switch (nSpeed)
{
case 0:
return(1000);
case 1:
return(900);
case 2:
return(800);
case 3:
return(700);
case 4:
return(600);
case 5:
return(500);
case 6:
return(400);
case 7:
return(300);
case 8:
return(200);
case 9:
return(150);
default:
return(150);
}
}
}
}
\u90e8\u5206\u4ee3\u7801\uff0c\u8fd8\u6709\u4e00\u90e8\u5206\uff0c\u4f60\u6700\u597d\u81ea\u5df1\u60f3

如果右上角的深紫色是三个一行的,你可以把橘色的放在最下面,然后放一个深紫色的【如果你是要把右面填满的话】

这关题目出错了,不可能完成😏

  • 鍚勪釜鎮熶縿缃楁柉鏂瑰潡258鍏
    绛旓細濡傛灉鍙充笂瑙掔殑娣辩传鑹叉槸涓変釜涓琛岀殑锛屼綘鍙互鎶婃鑹茬殑鏀惧湪鏈涓嬮潰锛岀劧鍚庢斁涓涓繁绱壊鐨勩愬鏋滀綘鏄鎶婂彸闈㈠~婊$殑璇濄
  • 扩展阅读:免费版俄罗斯方块下载 ... 俄罗斯方块图片大全 ... 俄罗斯方块全免费 ... 俄罗斯方块游戏免费版 ... 俄罗斯方块怀旧版免费 ... 俄罗斯方块苹果版下载 ... 俄罗斯方块完整图片 ... 俄罗斯方块经典版 ... 俄罗斯方块消消乐 ...

    本站交流只代表网友个人观点,与本站立场无关
    欢迎反馈与建议,请联系电邮
    2024© 车视网