zoukankan      html  css  js  c++  java
  • 站立会议的内容(第六次)

     

    以下是对我们最新升级版的程序的form主体文件的编写,今天我们非常努力,但是程序还应该进一步改善。

      1 using System;
      2 using System.Collections.Generic;
      3 using System.ComponentModel;
      4 using System.Data;
      5 using System.Drawing;
      6 using System.Linq;
      7 using System.Text;
      8 using System.Windows.Forms;
      9 using System.Xml;
     10 using System.Media;
     11 using PlayPlane_01.BLL;
     12 
     13 namespace PlayPlane_01
     14 {
     15     public partial class Form1 : Form
     16     {
     17         Plane plane;
     18 
     19         Timer t_draw;
     20 
     21         List<Enemy> enemy_lsit = new List<Enemy>();
     22         List<Bullet> bullet_lsit = new List<Bullet>();
     23         List<Explosion> explosion_list = new List<Explosion>();
     24         List<Reward> reward_list = new List<Reward>();
     25         int score = 0;
     26         int boom_count = 5;
     27         bool pause = false;
     28         Bitmap background;
     29 
     30         public Form1()
     31         {
     32             //this.SetStyle(ControlStyles.UserPaint, true);
     33             //this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
     34             //this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 双缓冲
     35             this.StartPosition = FormStartPosition.CenterScreen;
     36             this.Load += new System.EventHandler(this.Form1_Load);
     37             this.MouseMove += new MouseEventHandler(Form1_MouseMove);
     38             this.MouseClick += new MouseEventHandler(Form1_MouseClick);
     39             this.KeyPress += new KeyPressEventHandler(Form1_KeyPress);
     40             InitializeComponent();
     41         }
     42 
     43         private void Form1_Load(object sender, EventArgs e)
     44         {
     45             //this.FormBorderStyle = FormBorderStyle.None;
     46             //this.WindowState = FormWindowState.Maximized;
     47             EntityFactory.InitFactory("resource/plane.xml");
     48             background = new Bitmap(Image.FromFile(@"resource/bg_02.jpg"));
     49             plane = EntityFactory.GenPlane("normal");
     50             this.Cursor.Dispose();
     51             Cursor.Position = new Point(plane.X + this.Location.X, plane.Y + this.Location.Y);
     52             t_draw = new Timer();
     53             t_draw.Interval = 20;
     54             send_interval = 100 / t_draw.Interval;
     55             block_interval = 260 / t_draw.Interval;
     56             reward_interval = 5000 / t_draw.Interval;
     57             t_draw.Tick += new EventHandler(t_draw_Tick);
     58             t_draw.Start();
     59         }
     60 
     61         void Form1_MouseClick(object sender, MouseEventArgs e)
     62         {
     63             if (!pause && e.Button == MouseButtons.Right)
     64             {
     65                 if (boom_count > 0)
     66                 {
     67                     boom_count--;
     68                     for (int i = 0; i < enemy_lsit.Count; i++)
     69                     {
     70                         //socre ++
     71                         if (enemy_lsit[i].Name == "small") score += 1000;
     72                         else if (enemy_lsit[i].Name == "mid") score += 6000;
     73                         else if (enemy_lsit[i].Name == "big") score += 25000;
     74                         //add to explosion
     75                         explosion_list.Add(EntityFactory.GenExplosion("small", enemy_lsit[i].X, enemy_lsit[i].Y));
     76 
     77                         new DXPlay(this, @"resource/BOMB3.wav").ThreadPlay();
     78                     }
     79                     enemy_lsit.Clear();
     80                 }
     81             }
     82         }
     83 
     84         void Form1_MouseMove(object sender, MouseEventArgs e)
     85         {
     86             if (!pause)
     87             {
     88                 plane.X = e.X;
     89                 plane.Y = e.Y;
     90             }
     91         }
     92 
     93         void Form1_KeyPress(object sender, KeyPressEventArgs e)
     94         {
     95             if (e.KeyChar == ' ')
     96             {
     97                 pause = !pause;
     98                 if (pause)
     99                 {
    100                     this.Cursor = new Cursor (Cursors.Arrow.CopyHandle());
    101                 }
    102                 else
    103                 {
    104                     this.Cursor.Dispose();
    105                     Cursor.Position = new Point(plane.X + this.Location.X, plane.Y + this.Location.Y);
    106                 }
    107             }
    108             /*else if (e.KeyChar == 27)
    109             {
    110                 this.WindowState = FormWindowState.Normal;
    111             }
    112             else if (e.KeyChar == '
    ')
    113             {
    114                 this.WindowState = FormWindowState.Maximized;
    115             }*/
    116         }

     

  • 相关阅读:
    由PhysicalFileProvider构建的物理文件系统
    Net Core WebApi单元测试
    多个项目使用NET Core
    ReactNative
    定制样式插入到ueditor
    ES6的Class
    Redis存储Session
    二叉 查找树 排序树 搜索树
    SignalR实现实时日志监控
    KNN(k-nearest neighbor的缩写)又叫最近邻算法
  • 原文地址:https://www.cnblogs.com/BLZ1/p/5499337.html
Copyright © 2011-2022 走看看