Palette.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Timers;
namespace Snake_s
{
class Palette
{
private int _width = 20; //宽度
private int _height = 20; //高度
private Color _backgrondColor; //背景颜色
private Graphics _gPaletts; //画布
private ArrayList _blocks; //block列表
private Direction _direction; //snake前进方向
// 下载于www.51aspx.com
public Direction Direction
{
get { return _direction; }
set { _direction = value; }
}
public Timer timerBlock; //计时器
private Block _food; //snake当前食物
private int _size = 20; //snake单位大小
private int _level = 1; //等级
private bool _isGameOver = false;//游戏状态
private int[] _speed = new int[] { 120, 80, 50, 35 }; //速度
//构造函数(初始化)
public Palette(int width, int height, int size, Color backgrondColor, Graphics g, int level,bool timerChange)
{
this._width = width;
this._height = height;
this._backgrondColor = backgrondColor;
this._gPaletts = g;
this._size = size;
this._level = level;
//初始化蛇块列表
this._blocks = new ArrayList();
//在画布的正中央产生一个只有一节的贪吃蛇。
this._blocks.Insert(0, (new Block(Color.DarkRed, this._size, new Point(width / 2, height / 2))));
this._direction = Direction.Right;
}
//开始游戏
public void StartGame()
{
this._food=GetFood();//生成一个食物
//初始化计时器
timerBlock=new System.Timers.Timer(_speed[0]);//实例化Timer类,设置间隔时间
timerBlock.Elapsed+=new System.Timers.ElapsedEventHandler(OnBlockTimedEvent);//到达时间的时候执行事件
timerBlock.AutoReset=true;//一直执行
timerBlock.Start();
后面还有 124 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。