开发学院WEB开发Jsp GreedySnake贪吃蛇-测试版 阅读

GreedySnake贪吃蛇-测试版

 2008-01-05 18:41:14 来源:WEB开发网   
核心提示: /*--Development Notes:Greedy Snake Game Testing Version Based on LinkList StrUCtureDirection Control Keys are: w a s d@DanielNW2004-*/import javax.swing.*; //


 

/*------------------------------------------------------------------------------
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);

Tags:GreedySnake 贪吃

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接