Пример #1
0
        private void lb_Update()
        {
            try
            {
                System.Convert.ToInt32(txbScore.Text);
                System.Convert.ToInt32(txbTime.Text);
            }
            catch (Exception ex)
            {
                txbScore.Text = "0";
                txbTime.Text  = "0";
            }

            Snake     = new GDI_Computing_Method.Snake_Info(100, 4, 0);
            Food      = new GDI_Computing_Method.Food_Info(tbrFood.Value, 100);
            Game_info = new GDI_Computing_Method.Game_Info(Keys.Right, (int)GDI_Computing_Method.Game_Info.game_state_enum.Ready, tbrSpeed.Value, 1000 * 60 * System.Convert.ToInt32(txbTime.Text), System.Convert.ToInt32(txbScore.Text));
            uint Around = (uint)tbrSea.Value;

            Oe_info      = new GDI_Computing_Method.Obstacle_Info((uint)tbrGreen.Value, (uint)tbrSP.Value, (uint)tbrTree.Value, false, Around, Around, Around, Around, 300, 301, 302, 303);
            lbTree.Text  = tbrTree.Value.ToString();
            lbGreen.Text = tbrGreen.Value.ToString();
            lbSP.Text    = tbrSP.Value.ToString();
            lbSea.Text   = tbrSea.Value.ToString();
            lbFood.Text  = tbrFood.Value.ToString();
            lbSpeed.Text = string.Format("{0}ms", tbrSpeed.Value);
        }
Пример #2
0
 private void rbPT_CheckedChanged(object sender, EventArgs e)
 {
     gbDiy.Enabled = false;
     Snake         = new GDI_Computing_Method.Snake_Info(100, 4, 0);
     Food          = new GDI_Computing_Method.Food_Info(1, 100);
     Game_info     = new GDI_Computing_Method.Game_Info(Keys.Right, (int)GDI_Computing_Method.Game_Info.game_state_enum.Ready, 150, 1000 * 60 * 2, 25);
     Oe_info       = new GDI_Computing_Method.Obstacle_Info(1, 2, 5, false, 10, 10, 10, 10, 300, 301, 302, 303);
 }
Пример #3
0
        //窗口第一次显示
        private void frmGameStart_Shown(object sender, EventArgs e)
        {
            int total = GDI_Computing_Method.M_x * GDI_Computing_Method.M_y;

            tbrTree.Maximum  = (int)(total * 0.10);
            tbrGreen.Maximum = (int)((total / 25) * 0.3);
            tbrSP.Maximum    = (int)((total / 5) * 0.1);
            tbrSea.Maximum   = (int)(GDI_Computing_Method.M_x / 2);
            tbrFood.Minimum  = 1;
            tbrFood.Maximum  = (int)(total * 0.025);
            tbrSpeed.Minimum = 20;
            tbrSpeed.Maximum = 3000;
            lb_Update();
            gbDiy.Enabled = false;
            Snake         = new GDI_Computing_Method.Snake_Info(100, 4, 0);
            Food          = new GDI_Computing_Method.Food_Info(1, 100);
            Game_info     = new GDI_Computing_Method.Game_Info(Keys.Right, (int)GDI_Computing_Method.Game_Info.game_state_enum.Ready, 150, 1000 * 60 * 2, 25);
            Oe_info       = new GDI_Computing_Method.Obstacle_Info(1, 2, 5, false, 10, 10, 10, 10, 300, 301, 302, 303);
        }
Пример #4
0
        public static void Board_Draw(Graphics GP, GDI_Computing_Method.Game_Info gameinfo, GDI_Computing_Method.Snake_Info snake)
        {
            Bitmap   Board_Cache = new Bitmap(GDI_Computing_Method.paper_x, GDI_Computing_Method.paper_y);
            Graphics g           = Graphics.FromImage(Board_Cache);

            g.DrawImage(Map_Cache, 0, 0);
            if (Map_Cache_Flag == true)//确认地图是否已经绘制好
            {
                for (int x = 0; x < GDI_Computing_Method.M_x; x++)
                {
                    for (int y = 0; y < GDI_Computing_Method.M_y; y++)
                    {
                        if (GDI_Computing_Method.Coordinate_date[2, x, y] != -1)
                        {
                            g.DrawImage(GetBmp_Map(GDI_Computing_Method.Coordinate_date[2, x, y]), x * GDI_Computing_Method.M_Sense, y * GDI_Computing_Method.M_Sense, GDI_Computing_Method.M_Sense, GDI_Computing_Method.M_Sense);
                        }
                        if (GDI_Computing_Method.Coordinate_date[3, x, y] != -1)
                        {
                            g.DrawImage(GetBmp_Map(GDI_Computing_Method.Coordinate_date[3, x, y]), x * GDI_Computing_Method.M_Sense, y * GDI_Computing_Method.M_Sense, GDI_Computing_Method.M_Sense, GDI_Computing_Method.M_Sense);
                        }
                    }
                }
                g.DrawImage(Properties.Resources.pic_info, GDI_Computing_Method.paper_x - 170, GDI_Computing_Method.paper_y - 90);
                Pen pen = new Pen(Color.FromArgb(255, Color.Red));
                g.DrawRectangle(pen, GDI_Computing_Method.paper_x - 155, GDI_Computing_Method.paper_y - 25, 100, 10);
                pen = new Pen(Color.FromArgb(50 + snake.PH, Color.Red));

                pen.Width = 10;
                Font  newFont   = new Font("宋体", 10);
                Brush foreBrush = Brushes.Black;
                g.DrawString(string.Format("目标分:{0}", gameinfo.Game_way_mark), newFont, foreBrush, GDI_Computing_Method.paper_x - 160, GDI_Computing_Method.paper_y - 85);
                g.DrawString(string.Format("剩余时间:{0} Min", ((float)((float)gameinfo.Game_time) / 1000 / 60).ToString("F2")), newFont, foreBrush, GDI_Computing_Method.paper_x - 160, GDI_Computing_Method.paper_y - 70);
                g.DrawString(string.Format("总得分:{0}", gameinfo.Game_Mark), newFont, foreBrush, GDI_Computing_Method.paper_x - 160, GDI_Computing_Method.paper_y - 55);
                g.DrawString(string.Format("生命值:{0}", snake.PH), newFont, foreBrush, GDI_Computing_Method.paper_x - 160, GDI_Computing_Method.paper_y - 40);

                g.DrawLine(pen, GDI_Computing_Method.paper_x - 155, GDI_Computing_Method.paper_y - 20, GDI_Computing_Method.paper_x - 155 + snake.PH, GDI_Computing_Method.paper_y - 20);
                GP.DrawImage(Board_Cache, 0, 0);
                g.Dispose();
                pen.Dispose();
                Board_Cache.Dispose();
            }
        }