81 lines
1.2 KiB
C#
81 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Snake
|
|
{
|
|
public class PointSnake
|
|
{
|
|
public int x;
|
|
public int y;
|
|
|
|
public PointSnake(int px, int py)
|
|
{
|
|
x = px;
|
|
y = py;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public partial class Form1 : Form
|
|
{
|
|
|
|
|
|
List<PointSnake> list = new List<PointSnake>();
|
|
|
|
|
|
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
initSnake();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
public void initSnake()
|
|
{
|
|
PointSnake head = new PointSnake(400, 200);
|
|
|
|
list.Add(head);
|
|
}
|
|
|
|
|
|
|
|
private void Panel1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
Graphics graphics = e.Graphics;
|
|
|
|
Pen _pen = new Pen(Color.Black);
|
|
|
|
using (var p = _pen)
|
|
{
|
|
graphics.DrawRectangle(_pen, list[0].x , list[0].y , 10, 10);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|