资源简介
C# 实现贪吃蛇小游戏的设计编写,vs2015
键盘方向键控制。有初、中、高三个级别

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace 贪吃蛇小游戏
{
public partial class frmMain : Form
{
public static bool isStart = false;//判断是否开始
public static int speed = 400;//移动的速度
public static bool isPause = false;//是否暂停游戏
SnakeGame game = new SnakeGame();
private int snakeH = 20;//蛇的一节高度
private int snakeW = 20;//蛇的一节宽度
public frmMain()
{
InitializeComponent();
}
private void DrawGamePoint(Graphics g)
{
for (int i = 0; i <= panel1.Width / snakeW; i++)
{
g.DrawLine(new Pen(Color.Black 1) new Point(i * snakeW 0) new Point(i * snakeW panel1.Height));
}
for (int i = 0; i <= panel1.Height / snakeH; i++)
{
g.DrawLine(new Pen(Color.Black 1) new Point(0 i * snakeH) new Point(panel1.Width i * snakeH));
}
}
private void panel1_Paint(object sender PaintEventArgs e)
{
Graphics g = panel1.CreateGraphics();
DrawGamePoint(g);
if (!isStart)
{
SnakeGame.timer = timer1;
SnakeGame.label = label2;
game.CreateSnake(panel1 snakeH);
}
else
{
for (int i = 0; i < SnakeGame.List.Count; i++)
{
g.FillRectangle(SnakeGame.SnakeColor ((Point)SnakeGame.List[i]).X + 1 ((Point)SnakeGame.List[i]).Y + 1 snakeW - 1 snakeH - 1);
}
g.FillRectangle(SnakeGame.FoodColor SnakeGame.Food.X + 1 SnakeGame.Food.Y + 1 snakeW - 1 snakeH - 1);
if (SnakeGame.ifGame)
{
e.Graphics.DrawString(“GAME OVER“ new Font(“宋体“ 30 Fontstyle.Bold) new SolidBrush(Color.DarkSlateGray) new PointF(150 130));
}
}
}
///
/// 控制游戏开始,暂停,结束
///
/// 根据标识位(1=开始,2=暂停,3=结束)
private void ControlGame(int tag)
{
switch (tag)
{
case 1://开始游戏
{
isStart = false;
Graphics g = panel1.CreateGraphics();
g.FillRectangle(SnakeGame.PlanColor 0 0 panel1.Width panel1.Height);
DrawGamePoint(g);
isStart = true;
game.CreateSnake(panel1 snakeH);
timer1.Interval = speed;
timer1.Start();
isPause = true;
label2.Text = “0“;
break;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-12 16:45 贪吃蛇小游戏\
目录 0 2018-12-11 16:49 贪吃蛇小游戏\bin\
目录 0 2018-12-12 16:39 贪吃蛇小游戏\bin\Debug\
文件 16896 2018-12-12 16:39 贪吃蛇小游戏\bin\Debug\贪吃蛇小游戏.exe
文件 34304 2018-12-12 16:39 贪吃蛇小游戏\bin\Debug\贪吃蛇小游戏.pdb
文件 22688 2018-12-12 16:38 贪吃蛇小游戏\bin\Debug\贪吃蛇小游戏.vshost.exe
文件 490 2015-10-22 09:54 贪吃蛇小游戏\bin\Debug\贪吃蛇小游戏.vshost.exe.manifest
目录 0 2018-12-11 16:49 贪吃蛇小游戏\bin\Release\
文件 8321 2018-12-12 16:45 贪吃蛇小游戏\frmMain.cs
文件 10320 2018-12-12 16:36 贪吃蛇小游戏\frmMain.Designer.cs
文件 6210 2018-12-12 16:36 贪吃蛇小游戏\frmMain.resx
目录 0 2018-12-11 16:49 贪吃蛇小游戏\obj\
目录 0 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\
文件 1452 2018-12-12 14:28 贪吃蛇小游戏\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6878 2018-12-11 17:20 贪吃蛇小游戏\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2018-12-11 16:49 贪吃蛇小游戏\obj\Debug\TempPE\
文件 648 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.csproj.FileListAbsolute.txt
文件 1014 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.csproj.GenerateResource.Cache
文件 16896 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.exe
文件 180 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.frmMain.resources
文件 34304 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.pdb
文件 180 2018-12-12 16:39 贪吃蛇小游戏\obj\Debug\贪吃蛇小游戏.Properties.Resources.resources
文件 501 2018-12-11 17:03 贪吃蛇小游戏\Program.cs
目录 0 2018-12-11 16:49 贪吃蛇小游戏\Properties\
文件 1362 2018-12-11 16:49 贪吃蛇小游戏\Properties\AssemblyInfo.cs
文件 2849 2018-12-11 16:49 贪吃蛇小游戏\Properties\Resources.Designer.cs
文件 5612 2018-12-11 16:49 贪吃蛇小游戏\Properties\Resources.resx
文件 1105 2018-12-11 16:49 贪吃蛇小游戏\Properties\Settings.Designer.cs
文件 249 2018-12-11 16:49 贪吃蛇小游戏\Properties\Settings.settings
文件 9048 2018-12-12 16:33 贪吃蛇小游戏\SnakeGame.cs
文件 3800 2018-12-11 17:42 贪吃蛇小游戏\贪吃蛇小游戏.csproj
............此处省略0个文件信息
相关资源
- C# TIP文件生成和拆解
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论