求一个java俄罗斯方块上涨功能模块

Ann725 2011-08-15 06:32:23
描述一下:我的图形是用一个二维数组定义的,如100101010这样子的。画的时候画1的那快
再线等/。。。。
...全文
131 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
jokers_i 2011-08-17
  • 打赏
  • 举报
回复
试试这个,将下落的方块和已经固定的方块做不同的标记,一个是1一个是2.

http://blog.csdn.net/jokers_i/article/details/6455828
Ann725 2011-08-17
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 jokers_i 的回复:]

试试这个,将下落的方块和已经固定的方块做不同的标记,一个是1一个是2.

http://blog.csdn.net/jokers_i/article/details/6455828
[/Quote]
你帮我看看呗
Ann725 2011-08-16
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 nbda1121440 的回复:]

下面的代码只是给了一个最基本的思路,将原先的东西上移一行,再随机生成最后一行,楼主可以参考下
Java code

public class Test
{
public static void rise(int[][] map)
{
int height = map.length;
int width = map[0].length;
……
[/Quote]
好的
周靖峰 2011-08-16
  • 打赏
  • 举报
回复
下面的代码只是给了一个最基本的思路,将原先的东西上移一行,再随机生成最后一行,楼主可以参考下

public class Test
{
public static void rise(int[][] map)
{
int height = map.length;
int width = map[0].length;

//原先存在的上移一格,没有考虑越界这种情况
for (int i = 0; i < height - 1; i++)
{
for (int j = 0; j < width; j++)
{
map[i][j] = map[i + 1][j];
}
}

//最后一行随机生成
while (true)
{
int t = 0; //用来记录最后一行1的个数

for (int j = 0; j < width; j++)
{
map[height - 1][j] = (int) (Math.random() * 2);
if (map[height - 1][j] == 1)
{
t++;
}
}

//只有当最后一行不全为0且不全为1时才结束
if (t != 0 && t != width)
{
break;
}
}
}

public static void printMap(int[][] map)
{
for (int i = 0; i < map.length; i++)
{
for (int j = 0; j < map[i].length; j++)
{
System.out.print(map[i][j]);
}
System.out.println();
}
}

public static void main(String[] args)
{
int[][] map = {{0, 0, 0, 0, 0},
{0, 1, 0, 0, 0},
{0, 1, 1, 0, 0},
{0, 1, 1, 1, 0},
{1, 1, 1, 1, 0}};
System.out.println("上涨前");
printMap(map);
System.out.println("上涨后");
rise(map);
printMap(map);
}
}
waynell 2011-08-15
  • 打赏
  • 举报
回复
看了好久还是不明白你究竟想要什么
Ann725 2011-08-15
  • 打赏
  • 举报
回复
让我等这么久 太不够意思了吧
Ann725 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 nbda1121440 的回复:]

什么叫上涨模块,楼主要说的清楚点啊

可以参考下那个300行代码的俄罗斯方块,http://topic.csdn.net/u/20100612/03/a8d7b257-4385-4bb8-82ff-4a51ac3bd810.html?98964还是挺不错的
[/Quote]
那个300行的代码太不靠谱了
Ann725 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 nbda1121440 的回复:]

什么叫上涨模块,楼主要说的清楚点啊

可以参考下那个300行代码的俄罗斯方块,http://topic.csdn.net/u/20100612/03/a8d7b257-4385-4bb8-82ff-4a51ac3bd810.html?98964还是挺不错的
[/Quote]
就是在玩的时候底下障碍物会自动上涨的功能呀
周靖峰 2011-08-15
  • 打赏
  • 举报
回复
什么叫上涨模块,楼主要说的清楚点啊

可以参考下那个300行代码的俄罗斯方块,http://topic.csdn.net/u/20100612/03/a8d7b257-4385-4bb8-82ff-4a51ac3bd810.html?98964还是挺不错的
Ann725 2011-08-15
  • 打赏
  • 举报
回复
没人吗

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧