⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gamepanle.java

📁 自己写的一个Java版本的俄罗斯方块
💻 JAVA
字号:
package lx.view;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;

import lx.entity.Ground;
import lx.entity.Shape;
import lx.util.Global;

public class GamePanle extends JPanel {

	private static final long serialVersionUID = -1758362163721181062L;
	
	private Ground ground;
	private Shape  shape;
	
	public GamePanle() {
     	   //设置Panle宽为300,高为300
	       this.setSize(Global.WIDTH * Global.CELL_SIZE,
	    		        Global.HIGHT * Global.CELL_SIZE);
	}
	
	public void dispaly(Ground ground,Shape shape){
		System.out.println("Ground's display");
		this.ground = ground;
		this.shape  = shape;
		this.repaint();
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		//重新显示
		g.setColor(new Color(0xcfcfcf));
		g.fillRect(0, 0, Global.WIDTH * Global.CELL_SIZE,
		           Global.HIGHT * Global.CELL_SIZE);
		if(shape != null && ground != null){
			shape.drawMe(g);
			ground.drawMe(g);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -