一、贪吃蛇注册界面:a、b玩家注册用户名,用户名不能为空,不能为纯数字,玩家用户名不能一样,并且注册成功后完成与游戏界面的跳转

1、页面设计

<Window x:Class="贪吃蛇.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:贪吃蛇"mc:Ignorable="d"Title="MainWindow"   WindowStartupLocation="CenterScreen"  WindowStyle="None"  Width="540" Height="810" Loaded="Window_Loaded"><Canvas Width="540" Height="810"><Image Source="18426340.jpg" Width="540" Height="810"/><Button Content="开始游戏" FontSize="30" Background="Yellow" Canvas.Left="184" Canvas.Top="657" Width="166" Height="47" Click="Button_Click"/><Button Content="退出游戏" FontSize="30" Background="OrangeRed" Canvas.Left="184" Canvas.Top="709" Width="166" Height="48" Click="Button_Click_1"/><Canvas Height="90" Canvas.Left="184" Canvas.Top="520" Width="166" Background="Yellow"/><TextBox Name="a" Width="166" Canvas.Left="184" Canvas.Top="520" Height="45" FontSize="15"><TextBox.Resources><VisualBrush x:Key="HintText" TileMode="None" Opacity="0.5" Stretch="None" AlignmentX="Center" AlignmentY="Center"><VisualBrush.Visual><TextBlock FontStyle="Italic" Text="A玩家请输入用户名"/></VisualBrush.Visual></VisualBrush></TextBox.Resources><TextBox.Style><Style TargetType="{x:Type TextBox}"><Style.Triggers><Trigger Property="Text" Value="{x:Null}"><Setter Property="Background" Value="{StaticResource HintText}"/></Trigger><Trigger Property="Text" Value=""><Setter Property="Background" Value="{StaticResource HintText}"/></Trigger></Style.Triggers></Style></TextBox.Style></TextBox><TextBox Name="b" Width="166" Canvas.Left="184" Canvas.Top="565" Height="45" FontSize="15"><TextBox.Resources><VisualBrush x:Key="HintText" TileMode="None" Opacity="0.5" Stretch="None" AlignmentX="Center" AlignmentY="Center"><VisualBrush.Visual><TextBlock FontStyle="Italic" Text="B玩家请输入用户名"/></VisualBrush.Visual></VisualBrush></TextBox.Resources><TextBox.Style><Style TargetType="TextBox"><Style.Triggers><Trigger Property="Text" Value="{x:Null}"><Setter Property="Background" Value="{StaticResource HintText}"/></Trigger><Trigger Property="Text" Value=""><Setter Property="Background" Value="{StaticResource HintText}"/></Trigger></Style.Triggers></Style></TextBox.Style></TextBox><Button Name="zhuce" FontSize="30" Content="注册" Canvas.Left="184" Canvas.Top="610" Width="166" Height="45" Background="Yellow" Click="Button_Click_2"/></Canvas>
</Window>

2、功能实现:用户名的验证,开始及退出游戏,页面跳转

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.IO;namespace 贪吃蛇
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{public MainWindow(){InitializeComponent();}private void Window_Loaded(object sender, RoutedEventArgs e){}//用户名合法后开始游戏private void Button_Click(object sender, RoutedEventArgs e){if (zhuce.Content.ToString() == "注册成功"){Window1 ppp = new Window1();this.Hide();ppp.Show();//写入FileStream file = new FileStream("贪吃蛇.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file);writer.Write("|"+a.Text);writer.Write("|" + b.Text );writer.Close();}}//退出游戏private void Button_Click_1(object sender, RoutedEventArgs e){Application.Current.Shutdown();}//点击注册,判断用户名是否合法bool aa = true;bool bb = true;private void Button_Click_2(object sender, RoutedEventArgs e){string pattern = @"^\d+$";while (aa){if (string.IsNullOrWhiteSpace(a.Text)){MessageBox.Show("玩家A的姓名不能为空,请重新输入");a.Text = "";}else if (Regex.IsMatch(a.Text, pattern)){MessageBox.Show("玩家A的姓名不能是纯数字,请重新输入");a.Text = "";}else{aa = false;}break;}while (bb){if (string.IsNullOrWhiteSpace(a.Text)){MessageBox.Show("玩家B的姓名不能为空,请重新输入");b.Text = "";}else if (Regex.IsMatch(b.Text, pattern)){MessageBox.Show("玩家B的姓名不能是纯数字,请重新输入");b.Text = "";}else if (a.Text==b.Text){MessageBox.Show("玩家B的姓名不能与玩家A相同,请重新输入");b.Text = "";}else{bb = false;}break;}if (aa==false&& bb==false){zhuce.Content = "注册成功";}}}
}

二、游戏界面,两条蛇两个食物,分别用wads跟方向键控制蛇的移动,蛇碰墙,碰自己,碰另一条蛇都判定为死亡,分别记录两条蛇的得分,做一统计

1、页面设计

<Window x:Class="贪吃蛇.Window1"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:贪吃蛇"mc:Ignorable="d"Title="Window1"  Name="youxi" WindowStyle="None" WindowStartupLocation="CenterScreen" WindowState="Maximized" AllowsTransparency="True" Background="Transparent" Loaded="Youxi_Loaded" KeyDown="Youxi_KeyDown" ><DockPanel Name="bg"  ><Canvas Name="game"><Canvas Name="map"></Canvas><Border Name="bd" ></Border></Canvas><Canvas Name="meu"></Canvas></DockPanel></Window>

2、功能实现:控制蛇的移动、蛇吃食物;蛇的速度为3档,50分一下一档,50-100一档,100往上一档;空格暂停/继续游戏,Esc退出游戏;得分统计,速度展示;一分食物,两分食物显示效果,蛇身显示动画;与结束界面及注册界面的跳转…

using System;
using System.Collections.Generic;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.IO;namespace 贪吃蛇
{/// <summary>/// Window1.xaml 的交互逻辑/// </summary>public partial class Window1 : Window{//枚举,记录蛇的方向enum SnakeDirction{Left,Right,Up,Down}enum SnakeDirction2{Left,Right,Up,Down}public Window1(){InitializeComponent();}DispatcherTimer T = new DispatcherTimer();TextBox txt = new TextBox();TextBox txt2 = new TextBox();TextBox txt3 = new TextBox();TextBox txt4 = new TextBox();TextBox txt5 = new TextBox();int fenshu = 0;int fenshu2 = 0;//int zongfen = 0;SoundPlayer Sound = new SoundPlayer(@"E:\VS\跳转贪吃蛇\贪吃蛇\bg.wav");SoundPlayer over = new SoundPlayer(@"E:\VS\跳转贪吃蛇\贪吃蛇\7896.wav");bool b1 = true;//第一条蛇活着bool b2 = true;//第二条蛇活着private void Youxi_Loaded(object sender, RoutedEventArgs e){Sound.PlayLooping();bg.Width = this.Width;bg.Height = this.Height;//bg.Background = Brushes.Yellow;game.Width = 0.9 * bg.Width;game.Height = bg.Height;//game.Background = Brushes.Blue;meu.Background = new RadialGradientBrush(Colors.Yellow, Colors.OrangeRed);bd.Width = game.Width;bd.Height = game.Height;bd.BorderThickness = new Thickness(20);bd.BorderBrush = Brushes.Red;bd.Opacity = 1;Canvas.SetLeft(bd, 0);Canvas.SetTop(bd, 0);map.Width = (Convert.ToInt32(game.Width / 20) - 2) * 20;map.Height = (Convert.ToInt32(game.Height / 20) - 2) * 20;Canvas.SetLeft(map, 20);Canvas.SetTop(map, 20);map.Background = new LinearGradientBrush(Colors.OrangeRed, Colors.Yellow, 45);map.Opacity = 0.8;SnakeCreate();T.Interval = new TimeSpan(0, 0, 0, 0, 120);T.Tick += T_Tick;T.Start();lie = Convert.ToInt32(map.Width / ssize);hang = Convert.ToInt32(map.Height / ssize);FoodCreate();//记录第一条蛇得分txt.Background = Brushes.Transparent;           txt.BorderThickness = new Thickness(0);//txt.Text = "绿头蛇" + fenshu;txt.Width = 0.1 * this.Width;txt.Height = 0.05 * this.Height;txt.FontSize = 25;txt.FontFamily = new FontFamily("楷体");           Canvas.SetTop(txt, 20);meu.Children.Add(txt);//记录第二条蛇得分txt2.Background = Brushes.Transparent;txt2.BorderThickness = new Thickness(0);txt2.Width = 0.1 * this.Width;txt2.Height = 0.05 * this.Height;txt2.FontSize = 25;txt2.FontFamily = new FontFamily("楷体");Canvas.SetTop(txt2, 60);meu.Children.Add(txt2);//胜负榜txt3.Background = Brushes.Transparent;txt3.BorderThickness = new Thickness(0);txt3.Text = "红头蛇VS绿头蛇";txt3.Width = 0.1 * this.Width;txt3.Height = 0.05 * this.Height;txt3.FontSize = 21;txt3.FontFamily = new FontFamily("楷体");Canvas.SetTop(txt3, 100);meu.Children.Add(txt3);//游戏介绍txt4.Background = Brushes.Transparent;txt4.BorderThickness = new Thickness(0);txt4.Text = "游戏设有红头绿头两条蛇,分别用上下左右,W、A、D、S键控制移动方向,蛇头穿过边界,自己或敌方身体判定为死亡,两种食物,吃闪烁食物长两节身体记2分,普通食物长一节身体记1分,两者总分超过50速度变为2,超过100速度变为3,两个玩家可相互缠绕博弈,活到最后为胜者,敌方死后胜方可单独刷分";txt4.FontSize =24;txt4.TextWrapping = TextWrapping.Wrap;txt4.Width = 0.1 * this.Width;txt4.Height = 0.9* this.Height;txt4.FontFamily = new FontFamily("楷体");Canvas.SetTop(txt4, 180);meu.Children.Add(txt4);//速度级别显示txt5.Background = Brushes.Transparent;txt5.BorderThickness = new Thickness(0);txt5.Text = "速度:1";txt5.Width = 0.1 * this.Width;txt5.Height = 0.05 * this.Height;txt5.FontSize = 30;txt5.Foreground = new RadialGradientBrush(Colors.Red,Colors.Blue);//txt5.Foreground = new SolidColorBrush(Colors.Red);txt5.FontFamily = new FontFamily("楷体");Canvas.SetTop(txt5, 135);meu.Children.Add(txt5);}//造蛇//const  初始化的值不能改变const int sl = 4;const int ssize = 20;List<Border> snake = new List<Border>();SnakeDirction dirction = SnakeDirction.Right;string s = "you";//造第二条蛇List<Border> snake2 = new List<Border>();SnakeDirction2 dirction2 = SnakeDirction2.Right;string q = "you";void SnakeCreate(){for (int i = 0; i < sl; i++){Border br = new Border();br.Width = br.Height = ssize;br.BorderThickness = new Thickness(2);snake.Add(br);Canvas.SetLeft(snake[0], 300);Canvas.SetTop(snake[0], 300);br.CornerRadius = new CornerRadius(10);if (i == 0){br.Background = Brushes.Green;br.BorderBrush = Brushes.Black;}else{br.Background = Brushes.Cyan;br.BorderBrush = Brushes.Black;Canvas.SetLeft(snake[i], Canvas.GetLeft(snake[i - 1]) - ssize);Canvas.SetTop(snake[i], Canvas.GetTop(snake[i - 1]));}map.Children.Add(br);//造第二条蛇Border br2 = new Border();br2.Width = br2.Height = ssize;br2.BorderThickness = new Thickness(2);snake2.Add(br2);Canvas.SetLeft(snake2[0], 300);Canvas.SetTop(snake2[0], 600);br2.CornerRadius = new CornerRadius(10);if (i == 0){br2.Background = Brushes.Red;br2.BorderBrush = Brushes.Black;}else{br2.Background = Brushes.Yellow;br2.BorderBrush = Brushes.Black;Canvas.SetLeft(snake2[i], Canvas.GetLeft(snake2[i - 1]) - ssize);Canvas.SetTop(snake2[i], Canvas.GetTop(snake2[i - 1]));}map.Children.Add(br2);}}private void T_Tick(object sender, EventArgs e){//读出FileStream file2 = new FileStream("贪吃蛇.txt", FileMode.Open, FileAccess.Read);StreamReader reader = new StreamReader(file2);string str = reader.ReadLine();          string[] strlist = str.Split(new char[] { '|' });int len= strlist.Length;txt.Text = strlist[len - 2]+":" + fenshu;txt2.Text = strlist[len - 1] +":" + fenshu2;reader.Close();//第一条蛇活着才能动做出相应动作if (b1==true){//第一条蛇动for (int i = snake.Count - 1; i > 0; i--){Canvas.SetLeft(snake[i], Canvas.GetLeft(snake[i - 1]));Canvas.SetTop(snake[i], Canvas.GetTop(snake[i - 1]));}if (dirction == SnakeDirction.Up){if (s != "xia"){Canvas.SetTop(snake[0], Canvas.GetTop(snake[0]) - ssize);s = "shang";}else if (s == "xia"){Canvas.SetTop(snake[0], Canvas.GetTop(snake[0]) + ssize);}}if (dirction == SnakeDirction.Down){if (s != "shang"){Canvas.SetTop(snake[0], Canvas.GetTop(snake[0]) + ssize);s = "xia";}else if (s == "shang"){Canvas.SetTop(snake[0], Canvas.GetTop(snake[0]) - ssize);}}if (dirction == SnakeDirction.Left){if (s == "you"){Canvas.SetLeft(snake[0], Canvas.GetLeft(snake[0]) + ssize);}else if (s != "you"){Canvas.SetLeft(snake[0], Canvas.GetLeft(snake[0]) - ssize);s = "zuo";}}if (dirction == SnakeDirction.Right){if (s != "zuo"){Canvas.SetLeft(snake[0], Canvas.GetLeft(snake[0]) + ssize);s = "you";}else if (s == "zuo"){Canvas.SetLeft(snake[0], Canvas.GetLeft(snake[0]) - ssize);}}//判断第一条蛇是否吃到小食物if (Canvas.GetTop(snake[0]) == Canvas.GetTop(f) && Canvas.GetLeft(snake[0]) == Canvas.GetLeft(f)){fenshu++;if (fenshu+fenshu2>=50){T.Interval = new TimeSpan(0, 0, 0, 0,70);txt5.Text = "速度:2";}if (fenshu + fenshu2 >= 100){T.Interval = new TimeSpan(0, 0, 0, 0, 40);txt5.Text = "速度:3";}txt.Text = strlist[len - 2] + ":" + fenshu;f.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));Canvas.SetLeft(f, r.Next(0, lie) * ssize);Canvas.SetTop(f, r.Next(0, hang) * ssize);Border br = new Border();br.Width = br.Height = ssize;br.BorderThickness = new Thickness(2);br.Background = Brushes.Red;br.BorderBrush = Brushes.Cyan;Storyboard sto = new Storyboard();ThicknessAnimation dongcidaci = new ThicknessAnimation(new Thickness(0), new Thickness(10), new Duration(TimeSpan.FromSeconds(1)));Storyboard.SetTarget(dongcidaci, br);Storyboard.SetTargetProperty(dongcidaci, new PropertyPath("(Border.BorderThickness)"));dongcidaci.AutoReverse = true;dongcidaci.RepeatBehavior = RepeatBehavior.Forever;sto.Children.Add(dongcidaci);sto.Begin();br.CornerRadius = new CornerRadius(10);Canvas.SetLeft(br, Canvas.GetLeft(snake[snake.Count - 1]));Canvas.SetTop(br, Canvas.GetTop(snake[snake.Count - 1]));snake.Add(br);map.Children.Add(br);}//判断第一条蛇是否吃到大食物if (Canvas.GetTop(snake[0]) == Canvas.GetTop(f2) && Canvas.GetLeft(snake[0]) == Canvas.GetLeft(f2)){fenshu+=2;if (fenshu + fenshu2 >= 50){T.Interval = new TimeSpan(0, 0, 0, 0, 70);txt5.Text = "速度:2";}if (fenshu + fenshu2 >= 100){T.Interval = new TimeSpan(0, 0, 0, 0, 40);txt5.Text = "速度:3";}txt.Text = strlist[0] + ":" + fenshu;f2.BorderBrush = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));f2.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));Canvas.SetLeft(f2, r.Next(0, lie) * ssize);Canvas.SetTop(f2, r.Next(0, hang) * ssize);for (int i = 0; i < 2; i++){Border br = new Border();br.Width = br.Height = ssize;br.BorderThickness = new Thickness(2);br.Background = Brushes.Red;br.BorderBrush = Brushes.Cyan;Storyboard sto = new Storyboard();ThicknessAnimation dongcidaci = new ThicknessAnimation(new Thickness(0), new Thickness(10), new Duration(TimeSpan.FromSeconds(1)));Storyboard.SetTarget(dongcidaci, br);Storyboard.SetTargetProperty(dongcidaci, new PropertyPath("(Border.BorderThickness)"));dongcidaci.AutoReverse = true;dongcidaci.RepeatBehavior = RepeatBehavior.Forever;sto.Children.Add(dongcidaci);sto.Begin();br.CornerRadius = new CornerRadius(10);Canvas.SetLeft(br, Canvas.GetLeft(snake[snake.Count - 1]));Canvas.SetTop(br, Canvas.GetTop(snake[snake.Count - 1]));snake.Add(br);map.Children.Add(br);}}//判断第一条是否撞墙if (Canvas.GetTop(snake[0]) < 0 || Canvas.GetTop(snake[0]) >= map.Height || Canvas.GetLeft(snake[0]) < 0 || Canvas.GetLeft(snake[0]) >= map.Width){b1 = false;over.Play();T.Stop();txt3.Text = "红头蛇胜";if (b2 == true){if (MessageBox.Show("绿头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int j = 0; j < snake.Count; j++){map.Children.Remove(snake[j]);}snake.Clear();return;}else if (b2 == false){over.Play();MessageBox.Show("绿头蛇撞墙!!!游戏结束");T.Stop();//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}}//判断第一条是否吃到自己for (int i = 3; i < snake.Count; i++){if (Canvas.GetLeft(snake[0]) == Canvas.GetLeft(snake[i]) && Canvas.GetTop(snake[0]) == Canvas.GetTop(snake[i])){b1 = false;over.Play();T.Stop();txt3.Text = "红头蛇胜";if (b2 == true){if (MessageBox.Show("绿头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int j = 0; j < snake2.Count; j++){map.Children.Remove(snake[j]);}snake.Clear();return;}else if (b2 == false){over.Play();MessageBox.Show("绿头蛇碰到自己!!!游戏结束");T.Stop();//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}}}//首先得保证敌方蛇活着才能进入判断if (b2==true){//判断第一条蛇有没有碰到敌方蛇for (int i = 0; i < snake2.Count; i++){if (Canvas.GetLeft(snake[0]) == Canvas.GetLeft(snake2[i]) && Canvas.GetTop(snake[0]) == Canvas.GetTop(snake2[i])){b1 = false;over.Play();T.Stop();txt3.Text = "红头蛇胜";                           if (MessageBox.Show("绿头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int j = 0; j < snake.Count; j++){map.Children.Remove(snake[j]);}snake.Clear();return;                            }}}}//第二条蛇活着才能做出相应动作if (b2==true){//第二条蛇动for (int i = snake2.Count - 1; i > 0; i--){Canvas.SetLeft(snake2[i], Canvas.GetLeft(snake2[i - 1]));Canvas.SetTop(snake2[i], Canvas.GetTop(snake2[i - 1]));}if (dirction2 == SnakeDirction2.Up){if (q != "xia"){Canvas.SetTop(snake2[0], Canvas.GetTop(snake2[0]) - ssize);q = "shang";}else if (q == "xia"){Canvas.SetTop(snake2[0], Canvas.GetTop(snake2[0]) + ssize);}}if (dirction2 == SnakeDirction2.Down){if (q != "shang"){Canvas.SetTop(snake2[0], Canvas.GetTop(snake2[0]) + ssize);q = "xia";}else if (q == "shang"){Canvas.SetTop(snake2[0], Canvas.GetTop(snake2[0]) - ssize);}}if (dirction2 == SnakeDirction2.Left){if (q == "you"){Canvas.SetLeft(snake2[0], Canvas.GetLeft(snake2[0]) + ssize);}else if (q != "you"){Canvas.SetLeft(snake2[0], Canvas.GetLeft(snake2[0]) - ssize);q = "zuo";}}if (dirction2 == SnakeDirction2.Right){if (q != "zuo"){Canvas.SetLeft(snake2[0], Canvas.GetLeft(snake2[0]) + ssize);q = "you";}else if (q == "zuo"){Canvas.SetLeft(snake2[0], Canvas.GetLeft(snake2[0]) - ssize);}}//判断第二条蛇是否吃到小食物if (Canvas.GetTop(snake2[0]) == Canvas.GetTop(f) && Canvas.GetLeft(snake2[0]) == Canvas.GetLeft(f)){fenshu2++;if (fenshu + fenshu2 >= 50){T.Interval = new TimeSpan(0, 0, 0, 0, 70);txt5.Text = "速度:2";}if (fenshu + fenshu2 >= 100){T.Interval = new TimeSpan(0, 0, 0, 0, 40);txt5.Text = "速度:3";}txt2.Text = strlist[1] + ":" + fenshu2;f.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));Canvas.SetLeft(f, r.Next(0, lie) * ssize);Canvas.SetTop(f, r.Next(0, hang) * ssize);Border br2 = new Border();br2.Width = br2.Height = ssize;br2.BorderThickness = new Thickness(2);br2.Background = Brushes.YellowGreen;br2.BorderBrush = Brushes.Purple;Storyboard sto = new Storyboard();ThicknessAnimation dongcidaci = new ThicknessAnimation(new Thickness(0), new Thickness(10), new Duration(TimeSpan.FromSeconds(1)));Storyboard.SetTarget(dongcidaci, br2);Storyboard.SetTargetProperty(dongcidaci, new PropertyPath("(Border.BorderThickness)"));dongcidaci.AutoReverse = true;dongcidaci.RepeatBehavior = RepeatBehavior.Forever;sto.Children.Add(dongcidaci);sto.Begin();br2.CornerRadius = new CornerRadius(10);Canvas.SetLeft(br2, Canvas.GetLeft(snake2[snake2.Count - 1]));Canvas.SetTop(br2, Canvas.GetTop(snake2[snake2.Count - 1]));snake2.Add(br2);map.Children.Add(br2);}//判断第二条蛇是否吃到大食物if (Canvas.GetTop(snake2[0]) == Canvas.GetTop(f2) && Canvas.GetLeft(snake2[0]) == Canvas.GetLeft(f2)){fenshu2+=2;if (fenshu + fenshu2 >= 50){T.Interval = new TimeSpan(0, 0, 0, 0, 70);txt5.Text = "速度:2";}if (fenshu + fenshu2 >= 100){T.Interval = new TimeSpan(0, 0, 0, 0, 40);txt5.Text = "速度:3";}txt2.Text = strlist[1] + ":" + fenshu2;f2.BorderBrush = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));f2.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));Canvas.SetLeft(f2, r.Next(0, lie) * ssize);Canvas.SetTop(f2, r.Next(0, hang) * ssize);for (int i = 0; i < 2; i++){Border br2 = new Border();br2.Width = br2.Height = ssize;br2.BorderThickness = new Thickness(2);br2.Background = Brushes.YellowGreen;br2.BorderBrush = Brushes.Purple;Storyboard sto = new Storyboard();ThicknessAnimation dongcidaci = new ThicknessAnimation(new Thickness(0), new Thickness(10), new Duration(TimeSpan.FromSeconds(1)));Storyboard.SetTarget(dongcidaci, br2);Storyboard.SetTargetProperty(dongcidaci, new PropertyPath("(Border.BorderThickness)"));dongcidaci.AutoReverse = true;dongcidaci.RepeatBehavior = RepeatBehavior.Forever;sto.Children.Add(dongcidaci);sto.Begin();br2.CornerRadius = new CornerRadius(10);Canvas.SetLeft(br2, Canvas.GetLeft(snake2[snake2.Count - 1]));Canvas.SetTop(br2, Canvas.GetTop(snake2[snake2.Count - 1]));snake2.Add(br2);map.Children.Add(br2);}}//判断第二条是否撞墙if (Canvas.GetTop(snake2[0]) < 0 || Canvas.GetTop(snake2[0]) >= map.Height || Canvas.GetLeft(snake2[0]) < 0 || Canvas.GetLeft(snake2[0]) >= map.Width){                  b2 = false;over.Play();T.Stop();txt3.Text = "绿头蛇胜";if (b1 == true){if (MessageBox.Show("红头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int i = 0; i < snake2.Count; i++){map.Children.Remove(snake2[i]);}                       snake2.Clear();return;}                  else if (b1 == false){over.Play();MessageBox.Show("红头蛇撞墙!!!游戏结束");T.Stop();//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}}//判断第二条是否吃到自己for (int i = 3; i < snake2.Count; i++){if (Canvas.GetLeft(snake2[0]) == Canvas.GetLeft(snake2[i]) && Canvas.GetTop(snake2[0]) == Canvas.GetTop(snake2[i])){b2 = false;over.Play();T.Stop();txt3.Text = "绿头蛇胜";if (b1 == true){if (MessageBox.Show("红头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int j = 0; j < snake2.Count; j++){map.Children.Remove(snake2[j]);}snake2.Clear();return;}else if (b1 == false){over.Play();MessageBox.Show("红头蛇碰到自己!!!游戏结束");T.Stop();//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}}}//敌方蛇活着才能进入判断if (b1==true){//判断第二条蛇有没有碰到敌方蛇for (int i = 1; i < snake.Count; i++){if (Canvas.GetLeft(snake2[0]) == Canvas.GetLeft(snake[i]) && Canvas.GetTop(snake2[0]) == Canvas.GetTop(snake[i])){b2 = false;over.Play();T.Stop();txt3.Text = "绿头蛇胜";if (MessageBox.Show("红头蛇死,是否继续游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){T.Start();Sound.PlayLooping();}else{//Application.Current.Shutdown();Window2 qqq = new Window2();this.Hide();qqq.Show();FileStream file3 = new FileStream("得分.txt", FileMode.Append, FileAccess.Write);StreamWriter writer = new StreamWriter(file3);writer.Write("|" + ":" + txt.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Write("|" + ":" + txt2.Text + "分" + ":" + DateTime.Now.ToString("MM月dd日 dddd HH:mm:ss"));writer.Close();}for (int j = 0; j < snake2.Count; j++){map.Children.Remove(snake2[j]);}snake2.Clear();return;                          }}}                } }bool a = true;//键盘事件private void Youxi_KeyDown(object sender, KeyEventArgs e){if (e.Key == Key.Up ){dirction = SnakeDirction.Up;}if (e.Key == Key.Down ){dirction = SnakeDirction.Down;}if (e.Key == Key.Left){dirction = SnakeDirction.Left;}if (e.Key == Key.Right){dirction = SnakeDirction.Right;}if (e.Key==Key.W){dirction2 = SnakeDirction2.Up;}if (e.Key == Key.S){dirction2 = SnakeDirction2.Down;}if (e.Key == Key.A){dirction2 = SnakeDirction2.Left;}if (e.Key == Key.D){dirction2 = SnakeDirction2.Right;}if (e.Key == Key.Space && a == true){T.Stop();Sound.Stop();a = false;}else if (e.Key == Key.Space && a == false){T.Start();Sound.PlayLooping();a = true;}if (e.Key == Key.Escape){T.Stop();if (MessageBox.Show("是否退出游戏?", "贪吃蛇", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes){MainWindow qqq = new MainWindow();this.Hide();qqq.Show(); }else{T.Start();}}}//创建食物Border f = new Border();Border f2 = new Border();Random r = new Random();int hang = 0;int lie = 0;void FoodCreate(){            f.Width = f.Height = ssize;f.BorderBrush = Brushes.Black;f.BorderThickness = new Thickness(2);f.CornerRadius = new CornerRadius(10);f.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));Canvas.SetLeft(f, r.Next(0, lie) * ssize);Canvas.SetTop(f, r.Next(0, hang) * ssize);map.Children.Add(f);f2.Width = f2.Height = ssize;f2.BorderBrush = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));f2.Background = new SolidColorBrush(Color.FromRgb((byte)r.Next(0, 256), (byte)r.Next(0, 256), (byte)r.Next(0, 256)));f2.BorderThickness = new Thickness(2);f2.CornerRadius = new CornerRadius(10);Canvas.SetLeft(f2, r.Next(0, lie) * ssize);Canvas.SetTop(f2, r.Next(0, hang) * ssize);map.Children.Add(f2);Storyboard sto = new Storyboard();ThicknessAnimation dongcidaci = new ThicknessAnimation(new Thickness(0), new Thickness(10), new Duration(TimeSpan.FromSeconds(1)));Storyboard.SetTarget(dongcidaci, f2);Storyboard.SetTargetProperty(dongcidaci, new PropertyPath("(Border.BorderThickness)"));dongcidaci.AutoReverse = true;dongcidaci.RepeatBehavior = RepeatBehavior.Forever;sto.Children.Add(dongcidaci);sto.Begin();     }}
}

三、成绩展示页面 ,有当局成绩展示及历史得分记录展示两部分

1、页面设计

<Window x:Class="贪吃蛇.Window2"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:贪吃蛇"mc:Ignorable="d"Title="Window2" Name="youxi" WindowStyle="None" WindowStartupLocation="CenterScreen" WindowState="Maximized" AllowsTransparency="True" Background="Transparent" Loaded="Youxi_Loaded" KeyDown="Youxi_KeyDown" ><Canvas Name="canv"></Canvas>
</Window>

2、功能实现:当局得分展示;开始游戏,退出游戏;历史得分前十位排序,每次更新得分排名;实现界面跳转

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using System.IO;
using System.Collections;namespace 贪吃蛇
{/// <summary>/// Window2.xaml 的交互逻辑/// </summary>public partial class Window2 : Window{public Window2(){InitializeComponent();}//重新开始或退出游戏按钮Button btn1 = new Button();Button btn2 = new Button();//查看成绩Button btn3 = new Button();//胜负,比分TextBox txt1 = new TextBox();//历史记录TextBox txt2 = new TextBox();//计时器DispatcherTimer timer = new DispatcherTimer();Dictionary<string, int> lt = new Dictionary<string, int>();private void Youxi_Loaded(object sender, RoutedEventArgs e){canv.Width = this.Width;canv.Height = this.Height;canv.Background = new RadialGradientBrush(Colors.Purple, Colors.Yellow);txt1.Width = this.Width / 2 - 100;txt1.Height = 600;txt1.Opacity = 0.7;txt1.BorderBrush = Brushes.Black;txt1.FontFamily = new FontFamily("楷体");txt1.FontSize = 40;txt1.TextWrapping = TextWrapping.Wrap;txt1.TextAlignment = TextAlignment.Center;txt1.Text += "\n" + "本局对战情况" + "\n" + "\n";Canvas.SetLeft(txt1, 100);Canvas.SetTop(txt1, 50);canv.Children.Add(txt1);txt2.Width = this.Width / 2 - 100;txt2.Height = 600;txt2.Opacity = 0.7;txt2.BorderBrush = Brushes.Black;txt2.FontFamily = new FontFamily("楷体");txt2.TextWrapping = TextWrapping.Wrap;txt2.FontSize = 40;txt2.TextAlignment = TextAlignment.Center;Canvas.SetLeft(txt2, this.Width - txt2.Width - 100);Canvas.SetTop(txt2, 50);canv.Children.Add(txt2);txt2.Text += "历史前10得分榜:" + "\n";btn1.Width = 200;btn1.Height = 60;btn1.FontFamily = new FontFamily("楷体");btn1.FontSize = 30;btn1.Background = Brushes.Orange;btn1.Content = "再玩一次";Canvas.SetLeft(btn1, this.Width / 2 - btn1.Width - 20);Canvas.SetTop(btn1, this.Height - 200);canv.Children.Add(btn1);btn1.Click += Btn1_Click;btn2.Width = 200;btn2.Height = 60;btn2.FontFamily = new FontFamily("楷体");btn2.FontSize = 30;btn2.Background = Brushes.Orange;btn2.Content = "退出游戏";Canvas.SetLeft(btn2, this.Width / 2 + 50);Canvas.SetTop(btn2, this.Height - 200);canv.Children.Add(btn2);btn2.Click += Btn2_Click;btn3.Width = 200;btn3.Height = 60;btn3.FontFamily = new FontFamily("楷体");btn3.FontSize = 30;btn3.Background = Brushes.Orange;btn3.Content = "查看成绩";Canvas.SetLeft(btn3, this.Width / 2 - btn1.Width/2);Canvas.SetTop(btn3, this.Height - 286);canv.Children.Add(btn3);btn3.Click += Btn3_Click;}private void Btn3_Click(object sender, RoutedEventArgs e){if (txt2.Text == "历史前10得分榜:" + "\n"){FileStream file = new FileStream("得分.txt", FileMode.Open, FileAccess.Read);StreamReader reader = new StreamReader(file);string str = reader.ReadLine();string[] strlist = str.Split(new char[] { '|' });int len = strlist.Length;//A玩家string a = strlist[len - 2];string[] alist = a.Split(new char[] { ':' });//B玩家            string b = strlist[len - 1];string[] blist = b.Split(new char[] { ':' });txt1.Text += alist[1] + ":" + alist[2] + "\n" + alist[3] + ":" + alist[4] + ":" + alist[5] + "\n" + "\n";txt1.Text += blist[1] + ":" + blist[2] + "\n" + blist[3] + ":" + blist[4] + ":" + blist[5] + "\n" + "\n";//截取AB玩家的分数,int类型int aa = Convert.ToInt32(alist[2].Remove(alist[2].Length - 1, 1));int bb = Convert.ToInt32(blist[2].Remove(blist[2].Length - 1, 1));if (aa > bb){txt1.Text += alist[1] + "胜" + "\n";}else if (aa == bb){txt1.Text += "平局" + "\n";}else if (aa < bb){txt1.Text += blist[1] + "胜" + "\n";}//历史成绩:冒泡排序//分数ArrayList list = new ArrayList();//玩家名称ArrayList list2 = new ArrayList();//时间ArrayList list3 = new ArrayList();SortedList sl = new SortedList();//字典for (int i = 1; i < strlist.Length; i++){string[] alllist = strlist[i].Split(new char[] { ':' });lt.Add(alllist[1] + alllist[3].Remove(0, 10) + ":" + alllist[4] + ":" + alllist[5], Convert.ToInt32(alllist[2].Remove(alllist[2].Length - 1, 1)));}var dicSort = from objDic in lt orderby objDic.Value descending select objDic;int p = 0;foreach (KeyValuePair<string, int> kvp in dicSort){p++;if (p < 11){txt2.Text += "第" + p + "名:" + kvp.Key + "   " + kvp.Value + "分" + "\n";}}/*foreach (KeyValuePair<string, int> kvp in dicSort){txt2.Text += "第"+i+"名:" + (kvp.Key + "   " + kvp.Value + "分" + "\n");}*///Dictionary<string, int> dic1desc = lt.OrderByDescending(o => o.Key).ToDictionary(o => o.Key, p => p.Value);//for (int i = 1; i < sl.Count; i++)//{//    for (int j = 1; j < sl.Count - i; j++)//    {//        if (Convert.ToInt32(sl.GetByIndex(j)) < Convert.ToInt32(sl.GetByIndex(j + 1)))//        {//            int q = sl.IndexOfValue(sl.GetByIndex(j));//            sl.IndexOfValue(sl.GetByIndex(j)) = sl.IndexOfValue(sl.GetByIndex(j + 1));//            sl.IndexOfValue(sl.GetByIndex(j + 1)) = q;//        }//    }//}//冒泡排序历史得分记录//for (int j = 0; j < list.Count - 1; j++)//{//    for (int k = 0; k < list.Count - j - 1; k++)//    {//        if (Convert.ToInt32(list[k]) < Convert.ToInt32(list[k + 1]))//        {//            int q = Convert.ToInt32(list[k]);//            list[k] = list[k + 1];//            list[k + 1] = q;//        }//    }//}//if (lt .Count >= 10)//{//    for (int i = 1; i <= 10; i++)//    {//        txt2.Text += "第" + i + "名:" + lt.Keys + "   " + lt.Values + "分" + "\n";//    }//}//else if (lt.Count < 10)//{//    for (int i = 1; i <= lt.Count; i++)//    {//        txt2.Text += "第" + i + "名:" + lt.Keys + "   " + lt.Values + "分" + "\n";//    }//}reader.Close();}}private void Btn2_Click(object sender, RoutedEventArgs e){Application.Current.Shutdown();}private void Btn1_Click(object sender, RoutedEventArgs e){Window1 window1 = new Window1();this.Hide();window1.Show();}//窗口最小化private void Youxi_KeyDown(object sender, KeyEventArgs e){if (e.Key == Key.Escape){this.WindowState = WindowState.Minimized;}}}
}

贪吃蛇大作战,C# WPF 实现两条贪吃蛇,有用户名注册,成绩展示,历史记录排序相关推荐

  1. 贪吃蛇大作战ai_当玩家发现《贪吃蛇大作战》是单机游戏后 世界都炸了

    贪吃蛇大作战是最近朋友圈最火爆的手游,不少玩家都通过分享得分进行炫耀并邀请好友加入游戏.这种火爆很快引起了多方关注,有不少媒体开始揭露<贪吃蛇大作战>只是包裹在完美AI模式下的单机游戏.近 ...

  2. C语言贪吃蛇大作战实训心得,在《贪吃蛇大作战》中感悟一些道理

    最近很火(严格说应该是前段时间开始很火).这种诺基亚时代的玩法,跟其他旧IP新作一样,通过平台移植和改良,通常很火.涉及的玩家感情旧回忆那些就不说了.还有盈利模式单一,玩到最后通盘只有自己大蛇的寂寞. ...

  3. laya游戏开发之贪吃蛇大作战(一)

    laya游戏开发之贪吃蛇大作战 一.背景 二.引擎选择 三.整体架构 3.1 玩法分析 3.2 游戏架构 3.3 技术选型 一.背景 需要快速实现一个贪吃蛇的 demo 以验证功能,非传统贪吃蛇玩法, ...

  4. 贪吃蛇大作战类游戏的实现

    贪吃蛇大作战类游戏的实现 前段时间玩了一个叫做贪吃蛇大作战的手机游戏,一下子就喜欢上了,然后就有了尝试实现的想法. 制作的平台环境:vs2012/cocos2dx3.8.1/C++ 关于贪吃蛇游戏的了 ...

  5. 贪吃蛇大作战中的“马太效应”

    贪吃蛇大作战中的"马太效应"     贪吃蛇大作战是这段时间很火的一款手机游戏,这个游戏的乐趣在于简单粗暴,对的,当下为工作生活而忙忙碌碌的我们是很难为一个手机游戏而牺牲太多的脑细 ...

  6. 贪吃蛇大作战JavaFx版完整源码

    贪吃蛇大作战 Java版 项目源码:https://github.com/silence1772/JavaFX-GreedySnake (记得点star啊,收藏一个项目最好的方式是star而不是for ...

  7. html5小游戏 typescript,使用TypeScript和Canvas编写移动端贪吃蛇大作战游戏

    基本介绍 一款移动端贪吃蛇大作战游戏.(只支持移动端) 这是一个临近 deadline 的课设项目,为了方便地使用TS,我直接使用angular-cli生成了TypeScript的项目结构.如果你有好 ...

  8. 基于Java实现的贪吃蛇大作战小游戏

    贪吃蛇大作战小游戏 整体思路与架构 本项目主要分为三个部分,即UI界面.游戏逻辑与网络传输. UI界面部分,主要是为了实现不同界面之间的切换.包括了注册登陆窗口(loginFrame)与游戏主窗口(G ...

  9. laya游戏开发之贪吃蛇大作战(二)—— 贪吃蛇客户端

    文章目录 一 功能分析 二 实现方案 1. 代码结构 2. 关键函数实现 2.1 游戏主循环(GameLoop) 2.2 数据层(Model) 2.3 画面绘制层(View) 帧同步的困难与解决方法 ...

最新文章

  1. io获取 pcl_点云数据可视化之PCL滤波学习
  2. 为什么watch机制不是银弹?
  3. 最全面的Android Studio使用教程【申明:来源于网络】
  4. java代码修改触发编译_gcc -O0仍然优化了“未使用”的代码 . 是否有一个编译标志来改变它?...
  5. 业务中台01:中台解决方案本质在解决什么问题?
  6. 192.168.8.1手机登陆_手机怎么登陆192.168.2.1入口?
  7. 基础的c语言题目,几个c语言的基础题目
  8. 智能家居实训系统的项目有感!
  9. QQ号能否成为互联网通行证?
  10. 凯撒/摩斯/栅栏/维吉尼亚/元音密码加解密的Python实现
  11. 希尔密码的加密、解密与破解
  12. y = mapminmax(‘apply‘,x,ps)与mapminmax(‘reverse‘,y,ps)
  13. Excel VBA | 一键批量生成对账单
  14. 开始讨厌现在这种生活
  15. php判断无理数,经典证明:几乎所有有理数都是无理数的无理数次方
  16. 接口测试|postman发送POST请求
  17. Photoshop CS6 在 4k屏上非常小的解决办法
  18. Jackknife,Bootstraping, bagging, boosting, AdaBoosting, Random forest 和 gradient boosting的区别
  19. Houdini 节点
  20. 计算机中复制和移动的操作系统,如何将旧电脑中的全部文件复制到新电脑中,包括操作系统?...

热门文章

  1. java 监视文件夹下的文件是否发生变化,当发生变时重新获取文件夹里的内容
  2. android app Preference设置自定义背景和去掉分割线以及设置分割线高度
  3. 毕业生必须知道:干部身份、三方协议、派遣证【转】
  4. 我读《计算机科学概论》第12版 J.Gleen.Brookshear Dennis Brylow
  5. 利用MS-SAMR协议修改用户密码
  6. 用JS简单实现Vue的双向绑定
  7. Vue自定义组件——自定义下拉框
  8. mysql高可用面试题_MySQL - MySQL面试题
  9. 锐龙r5 4500U和i7 1065G7 哪个好
  10. 根据下面一元二次方程求根公式,计算并输出一元二次方程x2+x-2=0的两个实根,要求精确到小数点后4位。程序中所有浮点数的数据类型均为float..