当前位置:   article > 正文

贪吃蛇大作战双人版完整代码

贪吃蛇大作战双人版完整代码
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Windows.Threading;
  16. namespace 贪吃蛇
  17. {
  18. /// <summary>
  19. /// MainWindow.xaml 的交互逻辑
  20. /// </summary>
  21. public partial class MainWindow : Window
  22. {
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26. this.Background = Brushes.Pink;
  27. }
  28. Random ra = new Random();
  29. Border food;
  30. Border bd1;
  31. DispatcherTimer dt;
  32. string s = "";
  33. string s1 = "";
  34. List<Border> snack = new List<Border>();
  35. List<Border> snakeback = new List<Border>();
  36. List<Border> snack1 = new List<Border>();
  37. List<Border> snakeback1 = new List<Border>();
  38. //创建一个放食物的集合
  39. List<Border> foodback = new List<Border>();
  40. private void Window_Loaded(object sender, RoutedEventArgs e)
  41. {
  42. this.Left = 0;
  43. this.Top = 0;
  44. //this.Width = SystemParameters.FullPrimaryScreenWidth;
  45. //this.Height = SystemParameters.FullPrimaryScreenHeight;
  46. this.Width = 800;
  47. this.Height = 600;
  48. for (int i = 0; i < 5; i++)
  49. {
  50. Border bd = new Border();
  51. if (i == 0)
  52. {
  53. bd.Background = Brushes.Red;
  54. }
  55. else
  56. {
  57. bd.Background = Brushes.Black;
  58. }
  59. bd.Height = bd.Width = 10;
  60. bd.CornerRadius = new CornerRadius(5);
  61. Canvas.SetLeft(bd, 200);
  62. Canvas.SetTop(bd, 200 + i * bd.Height);
  63. back.Children.Add(bd);
  64. snack.Add(bd);
  65. //存储蛇的位置的border
  66. Border bdback = new Border();
  67. Canvas.SetLeft(bdba
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/750256
推荐阅读
相关标签
  

闽ICP备14008679号