JFrame如何弄出俄罗斯方块豪华版消除的时候有爆炸效果

当2048遇见俄罗斯方块 感觉智商瞬间爆炸!_安游在线
     
当前位置 >
当2048遇见俄罗斯方块 感觉智商瞬间爆炸!
时间: 08:49编辑:暴躁的鱼
  益智游戏是一款看起来简单,但是一玩起来就爱不释手的游戏。2048大家还记得吧!那么当2048遇见俄罗斯方块那会是什么样子呢?
  加拿大游戏开发商 Noodlecake Games 近日宣布旗下 Gamebra 工作室所开发最新益智游戏《Joinz》将在 9 月 18 日登陆 iOS 平台,价格约为12元。并公布了一段新的游戏宣传视频,一起来看看吧。
  本作的灵感来源于《俄罗斯方块》和《小三传奇》,因此玩法上结合了两者的一些优秀元素,玩家需要对游戏中出现的各种颜色的方块进行移动,组合成规定的形状从而消除这些砖块。而每一次移动都会有新的方块产生,另外需要颜色相同的方块才能互相组合在一起,而方块成型的步骤都是有限的,因此每一步玩家最好先考虑清楚再行动。
  游戏会随机的给玩家提供各种道具,玩家还可以通过连击的消除获得发动技能的能量,攒满能量后发动技能总会在危急时刻进行救场,游戏会以无尽关卡形式进行挑战,不会含有任何的时间限制等约束条件,也无内置广告,没有分数的限制,玩家可以尽情的进行游戏。
热点文章推荐
更多精彩图文
热门游戏推荐
游戏名称:怪物猎人OL
游戏状态:公测
游戏厂商:腾讯
网游测试时间表
时间游戏名称状态抢号
05-10封测03-28封测07-21商业化04-11商业化03-27公测
最新游戏新闻攻略
经营许可证:皖ICP备号-1 公安机关备案:71 网站合作:1104747俄罗斯方块Java版
简单版的俄罗斯方块,还可以添加菜单和下一个块提示,等分等等扩展
import java.awt.G
import java.awt.P
import java.awt.event.ActionE
import java.awt.event.ActionL
import java.awt.event.KeyE
import java.awt.event.KeyL
import javax.swing.JP
import javax.swing.T
public class Tetris extends JPanel{
private static final long serialVersionUID = 1L;
private static int TimeDelay = 1000;
private static final int BlockSize = 30;
private static final int BlockWidth = 6;
private static final int BlockHeigth = 10;
private boolean[][] currBlock = Block.Shape[(int)(Math.random()*Block.Shape.length)];
private Point newBlockPosition = new Point(BlockWidth/2, 0);
private boolean[][] fixedBlock = new boolean[BlockHeigth][BlockWidth];
public Tetris() {
this.addKeyListener(keyListener);
timer = new Timer(Tetris.TimeDelay, this.TimerListener);
timer.start();
public void newBlock() {
currBlock =
Block.Shape[(int)(Math.random()*Block.Shape.length)];
newBlockPosition = new Point(BlockWidth/2, 0);
public boolean isTouchWall() {
for(int i=0; i&currBlock. i++)
for(int j=0; j&currBlock[0]. j++) {
if(currBlock[i][j])
if(j + newBlockPosition.x &= 0 || j + newBlockPosition.x &= (BlockWidth + 1)) {
System.out.println("碰墙");
return true;
return false;
public boolean isTouchFixedBlock() {
for(int i=0; i&currBlock. i++)
for(int j=0; j&currBlock[0]. j++) {
if(currBlock[i][j])
if(i + newBlockPosition.y &= BlockHeigth || j + newBlockPosition.x &= BlockWidth + 1 ||
fixedBlock[i + newBlockPosition.y][j + newBlockPosition.x - 1]) {
System.out.println("要固定了");
return true;
return false;
public void fixBlock() {
for(int i=0; i&currBlock. i++)
for(int j=0; j&currBlock[0]. j++) {
if(currBlock[i][j])
fixedBlock[i + newBlockPosition.y][j + newBlockPosition.x-1] = true;
System.out.println("fixed");
newBlock();
for(int i=0; i&BlockH i++) {
boolean isFull = true;
for(int j=0; j&BlockW j++) {
if(!fixedBlock[i][j]) {
isFull = false;
if(isFull) {
for(int p=i; p & 0; p--)
for(int k=0; k&BlockW k++)
fixedBlock[p][k] = fixedBlock[p-1][k];
for(int k=0; k&BlockW k++)
fixedBlock[0][k] = false;
public void transfer() {
int row = currBlock.
int col = currBlock[0].
boolean[][] temp = new boolean[row][col];
for(int i=0; i& i++)
for(int j=0; j& j++)
temp[j][col - 1 - i] = currBlock[i][j];
currBlock =
public static void main(String[] args) {
new Tetris();
protected void paintComponent(Graphics g) {
super.paintComponent(g);
for(int i=0; i&=BlockH i++) {
g.drawRect(0 * BlockSize, i * BlockSize, BlockSize, BlockSize);
g.drawRect((BlockWidth + 1) * BlockSize, i * BlockSize, BlockSize, BlockSize);
for(int i=1; i&=BlockW i++) {
g.drawRect(i * BlockSize, BlockHeigth * BlockSize, BlockSize, BlockSize);
for(int i=0; i&BlockH i++)
for(int j=0; j&BlockW j++) {
if(fixedBlock[i][j])
g.fillRect((1+j) * BlockSize, i * BlockSize, BlockSize, BlockSize);
for(int i=0; i&currBlock. i++)
for(int j=0; j&currBlock[0]. j++) {
if(currBlock[i][j])
g.fillRect((j + newBlockPosition.x) * BlockSize, (i + newBlockPosition.y) * BlockSize, BlockSize, BlockSize);
ActionListener TimerListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
newBlockPosition.y++;
if(isTouchFixedBlock()) {
newBlockPosition.y--;
fixBlock();
repaint();
KeyListener keyListener = new KeyListener() {
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DOWN:
newBlockPosition.y++;
if(isTouchFixedBlock())
newBlockPosition.y--;
case KeyEvent.VK_UP:
transfer();
case KeyEvent.VK_RIGHT:
newBlockPosition.x++;
if(isTouchWall() || isTouchFixedBlock())
newBlockPosition.x--;
case KeyEvent.VK_LEFT:
newBlockPosition.x--;
if(isTouchWall() || isTouchFixedBlock())
newBlockPosition.x++;
repaint();
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
import javax.swing.JF
public class TetrisApp extends JFrame{
private static final long serialVersionUID = 1L;
Tetris tetris = new Tetris();
public TetrisApp() {
this.add(tetris);
this.setLocationRelativeTo(null);
setSize(400, 400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
tetris.setFocusable(true);
public static void main(String[] args) {
new TetrisApp().setVisible(true);
要点就是:下标的控制,有时候加1,还是减1还是要明白清楚
用Java写俄罗斯方块
Java 写俄罗斯方块感想
用java写的俄罗斯方块小程序
俄罗斯方块java实现(附完整注释)
新手向!超详细!Java俄罗斯方块程序面向对象编程全记录
使用Java实现小游戏:俄罗斯方块
JAVA实战练习——俄罗斯方块(超简易版)
Java ——简易俄罗斯方块
没有更多推荐了,俄罗斯方块论文_图文_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
俄罗斯方块论文
&&俄罗斯方块 java 毕业论文
阅读已结束,下载本文需要
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩60页未读,
定制HR最喜欢的简历
你可能喜欢人生在勤,不索何获
俄罗斯方块游戏的菜单栏和工具栏的实现
俄罗斯方块游戏的菜单栏和工具栏的实现,主要帮助我
掌握菜单和工具栏的实现机制;
建立俄罗斯方块游戏菜单类;
建立俄罗斯方块游戏工具栏类(选做);
建立“退出游戏”菜单的事件处理机制,并实现退出功能;
5, 实现对CMenu类的测试。
具体实现代码:
者:Heloway
*类说明: 菜单栏
public class CMenu {
private JMenuBar menuB
private JMenu gameMenu,appMenu,aboutMenu,netMenu,dataM
private JMenuItem newGameMenuItem,exitMenuItem,saveInfoMenuItem,getInfoMenuI
private JCheckBoxMenuItem netSendInfoMenu,netRecInfoM
private JMenuItem[] aboutMenuItemA
private String[] aboutStrings=new String[]{"作者:hlw","版本:V1.0"};
private ActionL
* 创建出所有菜单和菜单项的对象实例
public CMenu() {
menuBar=new JMenuBar();
gameMenu=new JMenu("游戏");
appMenu=new JMenu("应用");
aboutMenu=new JMenu("关于");
netMenu=new JMenu("网络");
dataMenu=new JMenu("数据库");
newGameMenuItem=new JMenuItem("新游戏");
exitMenuItem=new JMenuItem("退出");
saveInfoMenuItem=new JMenuItem("保存游戏信息");
getInfoMenuItem=new JMenuItem("获取游戏信息");
netSendInfoMenu=new JCheckBoxMenuItem("发送信息");
netSendInfoMenu.setSelected(true);
netRecInfoMenu=new JCheckBoxMenuItem("接收信息");
aboutMenuItemArrays=new JMenuItem[2];
for (int i = 0; i & aboutMenuItemArrays. i++) {
aboutMenuItemArrays[i]=new JMenuItem(aboutStrings[i]);
* 创建菜单结构
public JMenuBar createMenuStruct() {
menuBar.add(gameMenu);
menuBar.add(appMenu);
menuBar.add(aboutMenu);
gameMenu.add(newGameMenuItem);
gameMenu.addSeparator();//分隔符
gameMenu.add(exitMenuItem);
appMenu.add(netMenu);
appMenu.add(dataMenu);
netMenu.add(netSendInfoMenu);
netMenu.add(netRecInfoMenu);
dataMenu.add(saveInfoMenuItem);
dataMenu.add(getInfoMenuItem);
for (int i = 0; i & aboutMenuItemArrays. i++) {
aboutMenu.add(aboutMenuItemArrays[i]);
return menuB
* 通过这个方法可以获取所有菜单对应的监听器
* @param l
public void addActionListener(ActionListener l) {
if (l!=null) {
this.listener=l;
exitMenuItem.addActionListener(l);
public interface GameListener extends ActionListener{
者: Helloway
名:CController
*类说明: 实现GameListener接口
public class CController implements GameListener{
* 实现actionEvent事件的方法
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("退出")) {
System.exit(0);
者:Helloway
名:TextMyGame
*类说明:用户创建窗口开始游戏及测试其他的类的正确性
public class TestMyGame {
public static void main(String[] args) {
JFrame myFrame=new JFrame("我的俄罗斯方块");
CControlPanel myControlPanel = new CControlPanel();
CMessagePanel myMsgPanel= new CMessagePanel();
//添加菜单栏
CController myController = new CController();
CMenu myMenu=new CMenu();
myMenu.addActionListener(myController);
myFrame.setJMenuBar(myMenu.createMenuStruct());
Container con=myFrame.getContentPane();
con.add(myControlPanel,BorderLayout.EAST);
con.add(myMsgPanel,BorderLayout.SOUTH);
myFrame.setSize(400, 500);
CGlobal.showCenter(myFrame);
myFrame.setVisible(true);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
界面展示:
如何创建和菜单栏分开的工具栏呀?
俄罗斯方块
VC实现俄罗斯方块的基本功能
C语言之俄罗斯方块游戏实现
C#版俄罗斯方块
[原创]MFC实现的俄罗斯方块
使用Unity制作俄罗斯方块游戏
CocosCreater的俄罗斯方块游戏实现
俄罗斯方块源码
没有更多推荐了,俄罗斯方块(一) 界面设计与实现
近期尝试了一下俄罗斯方块游戏,基本功能和界面的设计已经初步完成。分界面和功能实现两个模块简要地介绍一下实现过程。
一 界面设计与实现
界面示意图如图所示,主要实现了界面以任意比例拉伸或缩小,界面中控件的位置和大小相对位置保持不变,图是界面最大化显示的效果。
图1-1设计效果图
图1-2界面设计最大化示意图
界面中的所有控件 包括等控件均为动态生成,位置大小需要简单地数学计算获取。关于控件,已为例进行说明它的创建和位置确定的实现过程,其他的控件参考附录中界面部分完整的实现代码以及注释。游戏区域界面的背景绘制的实现也将做一个简要的说明。
1 控件的创建以及位置的确定,响应消息等等
以为例,首先在类的头文件中声明这两个对象,
//游戏类型选项
CButton m_radioS//单人游戏选项
CButton m_radioD//双人游戏选项
添加标识选中哪一个的变量,含义参考注释
int m_iR//默认为单人游戏 双人游戏
然后在OnCreate函数中创建这两个对象,
int CTerisView::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_radioSingle.Create(_T("单人游戏"),WS_EX_TRANSPARENT|WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, CRect(0,0,0,0), this, ID_RADIOBUTTON_SINGLE);
m_radioSingle.SetCheck(ID_RADIOBUTTON_SINGLE);//设置默认项
m_radioDouble.Create(_T("双人游戏"),WS_EX_TRANSPARENT|WS_CHILD|WS_VISIBLE|BS_AUTORADIOBUTTON, CRect(0,0,0,0), this, ID_RADIOBUTTON_DOUBLE);
这里只是创建了两个RadioButton对象,他们的位置并没有确定,下一步还需要确定他们在界面中的位置。这个位置要求满足界面大小改变时它们在界面中的相对位置保持不变。实现这一效果需要用到消息,详细信息可以参考前面的那一篇博文:
在函数中添加下面的代码:
void CTerisView::OnSize(UINT nType, int cx, int cy)
//cx 指定工作区的新的宽度 //cy 指定工作区的新的高度
//计算控件的位置
m_radioSingle.MoveWindow(4*cx/5,91,100,30);
m_radioDouble.MoveWindow(4*cx/5,140,100,30);
CView::OnSize(nType, cx, cy);
4*cx/5:cx 指定工作区的新的宽度,当窗口大小改变时可以实时获取到这个值,因为游戏区宽度设计的是占整个边框的2/3,因此确定这个按钮的左边界为整个界面宽度的;
91:50(空白区高度)(标题区)(距离标题区的高度);
100:按钮的宽度;
30:按钮的高度。
这样,这两个按钮的在界面中的大小和相对位置以确定。后面是消息的响应。
在中给按钮添加消息响应函数详细信息可以参考前面的博文:
具体地在附录中可以参考详细的代码实现和注释。
只是在消息响应函数中给前面声明的那个标识变量m_iRadio分别赋值,当为1的时候可以响应单击游戏,当为时,响应双人游戏。
2 游戏区背景框的绘制
这一部分主要是在函数中进行
//获取主窗口的大小
GetWindowRect(&rect);
//游戏区域绘制 背景及其他
CPen*myoldpen_
//创建蓝色的画笔
pen_gamearea.CreatePen(PS_SOLID,3,RGB(0,0,255));
myoldpen_gamearea=pDC-&SelectObject(&pen_gamearea);
pDC-&MoveTo(0,rect.Height()-20);//到左下顶点 左侧边线和左边框重合 不绘制边线
pDC-&LineTo(rect.Width()*2/3,rect.Height()-20); //底部边线
pDC-&LineTo(rect.Width()*2/3,51); //右部边线
//方块游戏区域
CRect rect_gamearea(0,50,rect.Width()*2/3,rect.Height()-20);
CBrush mybrush_
//创建画刷 绿色
mybrush_gamearea.CreateSolidBrush(RGB(0,222,0));
//绘制背景
pDC-&FillRect(rect_gamearea,&mybrush_gamearea);
pDC-&SelectObject(myoldpen_gamearea);
//底部的空白部分添加背景bottom
//底部区域
//CRect的四个参数分别为 l t r b
CRect rect_bottomarea(0,rect.Height()-18,rect.Width(),rect.Height());
CBrush mybrush_
//创建画刷
mybrush_bottomarea.CreateSolidBrush(RGB(200,222,0));
//绘制背景
pDC-&FillRect(rect_bottomarea,&mybrush_bottomarea);
//游戏进行区域
//下一个方块区域 70=50+20
CRect rect_nextBoxarea(rect.Width()/3-60,70,rect.Width()/3+60,170);//
CBrush mybrush_nextB
//创建画刷
mybrush_nextBoxarea.CreateSolidBrush(RGB(0,0,0));
//绘制背景
pDC-&FillRect(rect_nextBoxarea,&mybrush_nextBoxarea);
//绘制红色边线
//游戏区域绘制 背景及其他
CPen*myoldpen_
//创建蓝色的画笔
pen_nextbox.CreatePen(PS_SOLID,2,RGB(200,0,0));
myoldpen_nextbox=pDC-&SelectObject(&pen_nextbox);
pDC-&MoveTo(rect.Width()/3-60,70);//到左下顶点 左侧边线和左边框重合 不绘制边线
pDC-&LineTo(rect.Width()/3-60,170); //zuo部边线
pDC-&LineTo(rect.Width()/3+60,170); //di部边线
pDC-&LineTo(rect.Width()/3+60,70); //右部边线
pDC-&LineTo(rect.Width()/3-60,70); //上部边线
//游戏进行区
CRect rect_mainGameareaSingle(rect.Width()/6,200,rect.Width()/2,rect.Height()-21);//
CBrush mybrush_mainGameareaS
//创建画刷
mybrush_mainGameareaSingle.CreateSolidBrush(RGB(0,0,0));
//绘制背景
pDC-&FillRect(rect_mainGameareaSingle,&mybrush_mainGameareaSingle);
//绘制红色边线
//游戏区域绘制 背景及其他
CPen pen_GameareaS
CPen*myoldpen_GameareaS
//创建蓝色的画笔
pen_GameareaSingle.CreatePen(PS_SOLID,2,RGB(200,0,0));
myoldpen_GameareaSingle=pDC-&SelectObject(&pen_GameareaSingle);
pDC-&MoveTo(rect.Width()/6,200);//到左下顶点 左侧边线和左边框重合 不绘制边线
pDC-&LineTo(rect.Width()/6,rect.Height()-21); //zuo部边线
pDC-&LineTo(rect.Width()/2,rect.Height()-21); //di部边线
pDC-&LineTo(rect.Width()/2,200); //右部边线
pDC-&LineTo(rect.Width()/6,200); //shang部边线
//基本计分区域 120=20*6
CRect rect_Scorearea(rect.Width()/2+10,rect.Height()-21-125,rect.Width()/2+10+100/*rect.Width()/2+10+rect.Width()/8*/,rect.Height()-30);
CBrush mybrush_S
//创建画刷
mybrush_Scorearea.CreateSolidBrush(RGB(255,182,193));
//绘制背景
pDC-&FillRect(rect_Scorearea,&mybrush_Scorearea);
//输出块数
//添加此行代码避免文字背景色破坏了图像 背景遮盖
pDC-&SetBkMode(TRANSPARENT);
//添加文字
pDC-&TextOut(rect.Width()/2+10+30,rect.Height()-21-123,_T("块数"));
CString str1=_T("10");
pDC-&SetTextColor(RGB(255,0,0)); //设置数值字体颜色
pDC-&TextOut(rect.Width()/2+10+30+5,rect.Height()-21-103,str1);
pDC-&SetTextColor(RGB(0,0,0)); //设置字体颜色黑色
pDC-&TextOut(rect.Width()/2+10+30,rect.Height()-21-83,_T("分数"));
CString str2=_T("20");
pDC-&SetTextColor(RGB(0,255,0)); //设置数值字体颜色
pDC-&TextOut(rect.Width()/2+10+30+5,rect.Height()-21-63,str2);
pDC-&SetTextColor(RGB(0,0,0)); //设置字体颜色黑色
pDC-&TextOut(rect.Width()/2+10+30,rect.Height()-21-43,_T("行数"));
CString str3=_T("30");
pDC-&SetTextColor(RGB(0,0,255)); //设置数值字体颜色
pDC-&TextOut(rect.Width()/2+10+30+5,rect.Height()-21-24,str3);
pDC-&SetTextColor(RGB(0,0,0)); //设置字体颜色黑色
注意:这里的块数、分数和行数是动态变化的,程序的实现部分将会将些值实时地传递给相应的变量并显示出来。
界面实现源码下载地址:
UNITY 开发日记/教程 俄罗斯方块 (三) 搭建场景UI
没有更多推荐了,

我要回帖

更多关于 俄罗斯方块豪华版 的文章

 

随机推荐