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

📄 test.java

📁 这是一个贪食蛇的游戏源代码 代码的设计模式室调停者
💻 JAVA
字号:
package com.zhang.teris.test;

import javax.swing.JFrame;

import com.zhang.teris.controller.Controller;
import com.zhanggang.teris.entities.Ground;
import com.zhanggang.teris.entities.Shape;
import com.zhanggang.teris.view.GamePanel;

public class Test {

	public static void main(String[] args) {
		
		Shape shape = new Shape();
		Ground ground = new Ground();
		GamePanel gamePanel = new GamePanel();
		Controller controller = new Controller(ground, shape, gamePanel);
		
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//之所以加10是因为frame要比gamepanel稍稍大一些,因为frame有自己的边框要容纳,这个边框差不多为30个像素
		frame.setSize(gamePanel.getWidth()+ 10, gamePanel.getHeight() + 30);
		frame.add(gamePanel);
		frame.addKeyListener(controller);
		frame.setLocation(300, 200);
		frame.setVisible(true);
		
		controller.newGame();
	}

}

⌨️ 快捷键说明

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