SnakeMainForm.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
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 Snake_s
{
public partial class SnakeMainForm : Form
{
private Palette p;
bool timeChange=true;
public SnakeMainForm()
{
InitializeComponent();
}
// 下载于www.51aspx.com
//private void SnakeMainForm_Load(object sender, EventArgs e)
//{
// //定义画布、蛇块属性
// int width = 30, height = 30, size = 15;
// //设定Form窗体大小
// this.pbx1.Width = width * size;
// this.pbx1.Height = height * size;
// //this.Width = pbx1.Width + 30;
// //this.Height = pbx1.Height + 60;
// p=new Palette(width,height,size,this.pbx1.BackColor,
// Graphics.FromHwnd(this.pbx1.Handle),5);
// p.StartGame();
//}
private void SnakeMainForm_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == Keys.W || e.KeyCode == Keys.Up) && p.Direction != Direction.Down)//e.KeyValue == 38等同于e.KeyCode == Keys.Up
{
p.Direction = Direction.Up;
return;
}
if ((e.KeyCode == Keys.S || e.KeyValue == 40) && p.Direction != Direction.Up)
{
p.Direction = Direction.Down;
return;
}
if ((e.KeyCode == Keys.A || e.KeyValue == 37) && p.Direction != Direction.Right)
{
p.Direction = Direction.Left;
return;
}
if ((e.KeyCode == Keys.D || e.KeyValue == 39) && p.Direction != Direction.Left)
{
p.Direction = Direction.Right;
return;
}
}//关于控制移动,问题:wasd可用,上下左右键无法使用,键值KeyValue,键码KeyCode试过无效
后面还有 75 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。