package MyProjects;
import java.awt.Color;
import java.awt.Container;
import java.awt.Graphics; //Graphics 类是所有图形上下文的抽象基类
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;
public class TanChiShe2 extends JFrame implements ActionListener,KeyListener,Runnable{
//使用到的全局变量
private JMenuBar menuBar;
private Toolkit toolkit;
private JMenu youXiMenu;
private JMenuItem kaiShiYouXi;
private JMenuItem exitItem;
private JMenu nanDuMenu;
private JCheckBoxMenuItem cJianDan;
private JCheckBoxMenuItem cPuTong;
private JCheckBoxMenuItem cKunNan;
private JMenu fenShuMenu;
private JMenuItem fenShuItem;
private JMenu guanYuMenu;
private JMenuItem zuoZheItem;
private int length=6;
private int life = 0;
private int foods = 0;
private int fenshu = 0;
private Thread she = null;
private int i,x,y,z,objectX,objectY,object = 0,growth = 0,time; //objectX,Y为食物坐标,Z为蛇前进方向
private int m[] = new int[50];
private int n[] = new int[50];
public static void main(String[] args)
{
new TanChiShe2();
}
//**************绘制游戏界面**********************
public TanChiShe2()
{
setVisible(true);
menuBar = new JMenuBar();
Container con = this.getContentPane(); //?????
toolkit = getToolkit();
//游戏菜单对象
youXiMenu = new JMenu("游戏");
kaiShiYouXi = new JMenuItem("开始游戏");
exitItem = new JMenuItem("退出游戏");
//困难程度对象
nanDuMenu = new JMenu("困难程度");
cJianDan = new JCheckBoxMenuItem("简单");
cPuTong = new JCheckBoxMenuItem("普通");