`
- 浏览:
62268 次
- 性别:
- 来自:
苏州
-
这里先给出shape类的所有代码
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Text;
namespace Fang
...{
public class sharp
...{
//用于记录分数
//用于记录已经触底的图像
protected PictureBox[] oldpb=new PictureBox[1000];
//用于控制移动中的图像
public PictureBox[] pb = new PictureBox[4];
//图像的初始化位置
private int initX = 100;
private int initY = 10;
//构造函数[参数用于制定控件添加到什么窗口]
public sharp(Form f)
...{
newObj(f);
}
//用于给定时器调用 向下移动
public void moveDown(Form f)
...{
for (int i = 0; i < 4; i++)
...{
//向下移动
pb[i].Location = new Point(pb[i].Location.X, pb[i].Location.Y + 10);
}
//调用check来判断是否到底
if (check(f))
...{
//到底着构建新图像
makeNew();
}
}
//用于旋转图形
public void Roll()
...{
int Sx = pb[2].Location.X - pb[0].Location.X;
int Sy = pb[2].Location.Y - pb[0].Location.Y;
//根据计算
if (Sx >= 0 && Sy < 0) Rollx(-1,-1);
else if (Sx < 0 && Sy <= 0) Rollx(-1,1);
else if (Sx <= 0 && Sy > 0) Rollx(1,1);
else if (Sx > 0 && Sy >= 0) Rollx(1,-1);
}
//ROllX()由下面的4个方法综合而成
/**/////四个象限的旋转方法
//private void Roll1()//在第一象限转第二象限
// {
// for (int i = 1; i < 4; i++)
// {
// int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
// int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
// pb[i].Location = new Point(pb[0].Location.X - y, pb[0].Location.Y - x);
// }
// //如果坐标越界就进行反旋转
// if (pb[0].Location.X > 200 || pb[1].Location.X > 200 || pb[2].Location.X > 200 || pb[3].Location.X > 200) Roll4();
// if (pb[0].Location.X < 0 || pb[1].Location.X < 0 || pb[2].Location.X < 0 || pb[3].Location.X < 0) Roll4();
// }
// private void Roll2()//在2转3
// {
// for (int i = 1; i < 4; i++)
// {
// int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
// int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
// pb[i].Location = new Point(pb[0].Location.X - y, pb[0].Location.Y + x);
// }
// //如果坐标越界就进行反旋转
// if (pb[0].Location.X < 0 || pb[1].Location.X < 0 || pb[2].Location.X < 0 || pb[3].Location.X < 0) Roll1();
// if (pb[0].Location.X > 200 || pb[1].Location.X > 200 || pb[2].Location.X > 200 || pb[3].Location.X > 200) Roll1();
// }
// private void Roll3()//在3转4
// {
// for (int i = 1; i < 4; i++)
// {
// int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
// int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
// pb[i].Location = new Point(pb[0].Location.X + y, pb[0].Location.Y + x);
// }
// //如果坐标越界就进行反旋转
// if (pb[0].Location.X < 0 || pb[1].Location.X < 0 || pb[2].Location.X < 0 || pb[3].Location.X < 0) Roll2();
// if (pb[0].Location.X > 200 || pb[1].Location.X > 200 || pb[2].Location.X > 200 || pb[3].Location.X > 200) Roll2();
// }
// private void Roll4()//在4转1
// {
// for (int i = 1; i < 4; i++)
// {
// int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
// int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
// pb[i].Location = new Point(pb[0].Location.X + y, pb[0].Location.Y - x);
// }
// //如果坐标越界就进行反旋转
// if (pb[0].Location.X > 200 || pb[1].Location.X > 200 || pb[2].Location.X > 200 || pb[3].Location.X > 200) Roll3();
// if (pb[0].Location.X < 0 || pb[1].Location.X < 0 || pb[2].Location.X < 0 || pb[3].Location.X < 0) Roll3();
// }
//检查是否到底 到底则进行转换
private void Rollx(int a,int b)
...{
bool flag=true;
PictureBox[] tmpPB=new PictureBox[4];
for(int i=0;i<4;i++)
...{
tmpPB[i]=new PictureBox();
int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
tmpPB[i].Location = new Point(pb[0].Location.X +a* y, pb[0].Location.Y +b*x);
if (!checkPes(tmpPB[i].Location)) flag = false;
}
if (flag)
...{
for (int i = 0; i < 4; i++)
...{
int x = System.Math.Abs(pb[0].Location.X - pb[i].Location.X);
int y = System.Math.Abs(pb[0].Location.Y - pb[i].Location.Y);
pb[i].Location = new Point(pb[0].Location.X + a * y, pb[0].Location.Y + b * x);
}
}
}
public bool check(Form f)
...{
for(int i=0;i<4;i++)
...{
if (pb[i].Location.Y > 500)
...{
//任一一个图像到底则整个图像进行转换
changToOld(f);
return true;
}
//判断该图像所对应的位置的下方是否有已经触底的图形
int x
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
C#实现俄罗斯方块 广西机电职业技术学院 C#视频教程 代码 可直接运行
逐步讲解用C#实现俄罗斯方块之核心代码[上] 逐步讲解用C#实现俄罗斯方块之核心代码[中] 逐步讲解用C#实现俄罗斯方块之核心代码[下]
C#俄罗斯方块游戏源代码,程序设计时加入了背景音乐和声音特效,可以说是一套成熟的作品,正在学习C#开发的童鞋不妨好好参考一下,感谢您对烈火下载的支持与厚爱,但是不要将源码用于商业用途!
C#实现俄罗斯方块游戏代码,注释完整,代码规范,供大家学习使用 C#Winform实现俄罗斯方块休息代码 C#绘图,GDI绘图,GDI+绘图 学习资源
C#实现俄罗斯方块,为用C#编写的一个游戏,希望对C#爱好着有帮助。在vs2005,vs2008 调试通过
C#实现俄罗斯方块,具有完整代码,可以直接运行!
c#俄罗斯方块游戏源代码,c#俄罗斯方块游戏源代码
C#实现 俄罗斯方块代码 经典
C#俄罗斯方块(winform)C#俄罗斯方块(winform)C#俄罗斯方块(winform)C#俄罗斯方块(winform)C#俄罗斯方块(winform)C#俄罗斯方块(winform)C#俄罗斯方块(winform)
顶下俄罗斯方块 c#俄罗斯方块 c#俄罗斯方块 c#顶下俄罗斯方块 c#俄罗斯方块 c#俄罗斯方块 c#顶下俄罗斯方块 c#俄罗斯方块 c#俄罗斯方块 c#顶下俄罗斯方块 c#俄罗斯方块 c#俄罗斯方块 c#
用c#实现俄罗斯方块!程序已经在vs2008上通过调试
c#俄罗斯方块源代码,c#实现俄罗斯方块(带消层,翻转,靠边判断)
主要参考了这篇博文 http://blog.csdn.net/aofengdaxia/article/details/5301934 原博是winform,这是wpf实现
C#俄罗斯方块的源代码及文档 C#俄罗斯方块的源代码及文档 C#俄罗斯方块的源代码及文档C#俄罗斯方块的源代码及文档
本源代码为c#俄罗斯方块代码,代码结构简单清晰,没有冗余的文件; 代码注释详细,方便学习,便于修改; 代码下载后可以直接运行; 游戏功能完备,一般俄罗斯方块的功能都有; 本代码适合c#编程新手,更适合修改后...
C# 俄罗斯方块源代码,方便初学者学习使用
用C#语言编写的俄罗斯方块游戏源代码,界面炫酷还有音乐。
简单的俄罗斯方块C#源码 适合初学者哦···········