📄 gamepanel.java
字号:
package com.zhanggang.teris.view;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import com.zhang.teris.util.Global;
import com.zhanggang.teris.entities.Ground;
import com.zhanggang.teris.entities.Shape;
public class GamePanel extends JPanel {
Ground ground;
Shape shape;
public void display(Ground ground, Shape shape) {
System.out.println("GamePanel's display");
this.ground = ground;
this.shape = shape;
repaint();
}
@Override
protected void paintComponent(Graphics g) {
Color c = g.getColor();
g.setColor(new Color(0xb2b2bf));
g.fillRect(0, 0, this.getWidth(), this.getHeight());
g.setColor(c);
if(ground != null && shape != null) {
ground.drawMe(g);
shape.drawMe(g);
}
}
public GamePanel() {
setSize(Global.WIDTH * Global.CELL_SIZE, Global.HEIGHT * Global.CELL_SIZE);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -