求C#自动玩贪吃蛇的源代码

来源:百度知道 编辑:UC知道 时间:2024/05/24 17:35:44
有的朋友请发到:king_jjj2008@163.com

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private bool i;//开关
snake a_snake = new snake(5);//实例化个长度为5的蛇
food afood = new food();//实例化一个食物
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
if (i)//点击了开始button
{
a_snake.drawsnake(g);//画出蛇
afood.drawfood(g);//画出来食物
}
if (a_snake.deadsnake())//如果蛇死亡事件为真
{