2048小游戏
程序简介
2048是一款益智小游戏,玩家需要在l6个格子中通过数字叠加旳措施将最初旳数字2凑成数字2048。有16个格子,初始时会有两个格子上安放了两个数字2, 每次可以选择上下左右其中一种方向去滑动, 每滑动一次, ;
import ;
import java)(.swing_border.*;
import java)(.;
public class Copy2048 extends JFrame{
private JPanel scoresPane;
private JPanel mainPane;
private JLabel labelMaxScores;
private JLabel labelScores;
private JLabel tips;
private JTextField textMa)(Scores; private JLabel textScores;
private JLabel[] [] texts;
privatelcorl icon2;
private int times= 16;
private int scores= 0;
private int11 ,l2,l3,l4,l5;
//提示操作t示签
//-记录剩余空方块数目
//-记最分数
//用 -]-'判断游戏与否失败
Font font= new Font(”H, ,14); Font font2 = new Font(-', ,30); Random random= new Random0;
/般置字体类型和大小//设立字体类型和大小
//随机类实例化
public static void main(StringI] args){
(new Runnable0{
public void run0{
try{
Copy2048 ffame= new Copy20480;
(true);
}
catch(Exception e1){
e1 .prlntStact(Trace0;
}
}
});
}
public Copy20480{
super0;
setFiesizable(false);
(null);
setBounds(500, 50, 500, 615);
setDefaultC⊠oseOperation(J Frame. EX「「0N_CLOSE) ; setTltle("2048PC版")
scoresPane= new JPanel0;
();
(20, 20, 460, 40);
((2, 2, 2, 2,,));
(scoresPane);
(null);
labelMaxScores= new JLabel("最高分:"); (font) ;
(10, 5, 50, 30);
(labelMaxScores);
textMaxScores= new JTextField(" ");
(60, 5, 150, 30);
(font);
(false);
scores (textMaxScores) ;
数面ili , 1 '
labelScores= new JLabel(”得 分:"); (font) ;
(240, 5, 50, 30); (labelScores);
textSoores= new JL
2048小游戏设计 来自淘豆网m.daumloan.com转载请标明出处.