国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

GreedySnake貪吃蛇-測試版

2019-11-18 11:26:04
字體:
來源:轉載
供稿:網友


 

/*------------------------------------------------------------------------------
Development Notes:
Greedy Snake Game Testing Version
Based on LinkList StrUCture

Direction Control Keys are: w a s d
@DanielNW2004-----------------------------------------------------------------*/


import javax.swing.*;   // the Java eXtensions "Swing" graphics kit
import java.awt.*;      // the Java  Abstract Windowing Toolkit
import java.awt.image.*;// the AWT image  package
import java.awt.geom.*; // AWT geometry
import java.io.*;       // I/O package
import java.awt.event.*;

public class snake extends JFrame implements KeyListener
{
 public static final int DISPLAY_WIDTH = 640;
 public static final int DISPLAY_HEIGHT = 640;
 public static final int BLOCKNUM = 80;

 public int currDir = 1;
 public CanvasArea ca = new CanvasArea(DISPLAY_WIDTH/8,DISPLAY_HEIGHT/8);

 public Container con = null;
 public int flag = 0, foodNum = 4, speed = 80;
 public CellItem temp = new CellItem();

 public static void main(String[] args)
 {
  new snake();
 }
 
 public snake() {
  super("Greedy Snake PRogram Testing");
  setDefaultCloSEOperation(EXIT_ON_CLOSE);
  setResizable(false);
  con = getContentPane();
  con.setLayout(null);
  addKeyListener( this ); // make this object be the one to listen to keyboard
//----------------------------------------------------------------
//Matrix of the canvas
//----------------------------------------------------------------
  ca.canvasInit();

  ca.addFood(ca.caStr[30][32],2);
  ca.addFood(ca.caStr[18][9],2);
  ca.addFood(ca.caStr[10][20],2);
  ca.addFood(ca.caStr[10][15],2);
  //ca.displayMatrix();
  ca.addCell(ca.caStr[1][0],1);
  ca.addCell(ca.caStr[1][1],1);
  ca.addCell(ca.caStr[1][2],1);
  ca.addCell(ca.caStr[1][3],1);
  ca.addCell(ca.caStr[1][4],1);
  ca.addCell(ca.caStr[2][4],1);
  ca.moveLeft();

  //ca.moveUp();
  //ca.moveUp();
  //ca.moveUp();
  //ca.moveUp();
  //ca.moveUp();
  //ca.moveUp();
  ca.displaySnake();
//---------------------------------------------------------------- 

  DisplayArea da =
     new DisplayArea( new Rectangle( 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT ) );

  con.add ( da );

  setVisible(true);


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 温泉县| 鄢陵县| 青海省| 阳东县| 揭东县| 汤阴县| 泾阳县| 连城县| 祥云县| 新巴尔虎右旗| 博乐市| 江阴市| 平江县| 固始县| 唐河县| 榆中县| 建昌县| 平泉县| 石柱| 舞钢市| 左权县| 南郑县| 郴州市| 大关县| 通化县| 仪征市| 安图县| 绵竹市| 图木舒克市| 谢通门县| 景谷| 闻喜县| 大理市| 灌云县| 合作市| 青川县| 时尚| 通榆县| 吉首市| 西安市| 武定县|