コード例 #1
0
ファイル: Snake_classes.cs プロジェクト: ilia-aili/New_Snake
        public S_Game(S_Main_Wnd a_Window)
        {
            m_Main_Window = a_Window;

            m_Main_Window.chkb_Check_speed_mode.Enabled = false;
            Graphics graph_comp = m_Main_Window.P_Game_board.CreateGraphics();

            graph_comp.Clear(m_Main_Window.P_Game_board.BackColor);
            S_Drawning.Set_graph_comp(graph_comp);
            m_Timer_for_One_Iteration          = new Timer();
            m_Timer_for_One_Iteration.Tick    += m_Timer_for_One_Iteration_Tick;
            m_Timer_for_One_Iteration.Interval = S_Constants.S_Constants.c_n_interval_of_game_timer;
            m_Timer_for_Delay          = new Timer();
            m_Timer_for_Delay.Interval = S_Constants.S_Constants.c_n_iterval_of_delay;
            m_Timer_for_Delay.Tick    += m_Timer_for_Delay_Tick;

            m_f_is_Delay_Over = m_f_is_Replace_over = true;

            Speed_Mode_Delegate SMD;

            if (m_Main_Window.chkb_Check_speed_mode.Checked)
            {
                SMD = Increase_Speed;
            }
            else
            {
                SMD = Do_Nothing;
            }
            Speed_Mode += SMD;


            m_random_for_food = new Random();
            // Пока что делаем так, начальные значения в константы не выносятся
            S_Location S1 = new S_Location(12, 0);
            S_Location S2 = new S_Location(13, 0);
            S_Location S3 = new S_Location(14, 0);
            S_Location S4 = new S_Location(15, 0);

            m_Snake = new S_Snake(E_Direction.Right, S4, S3, S2, S1);

            m_Board = new S_Game_Board(a_Window.P_Game_board, S_Drawning.Size_of_obj);
            m_Board.Set_Points_Value(false, new S_Location[] { S1, S2, S3, S4 });

            Add_new_Food();

            m_n_number_of_points = 0;
            Display_the_Score();
            m_Timer_for_One_Iteration.Start();
        }
コード例 #2
0
ファイル: Snake_classes.cs プロジェクト: ilia-aili/New_Snake
        public S_Game(S_Main_Wnd a_Window)
        {
            m_Main_Window = a_Window;

                m_Main_Window.chkb_Check_speed_mode.Enabled = false;
                Graphics graph_comp = m_Main_Window.P_Game_board.CreateGraphics();
                graph_comp.Clear(m_Main_Window.P_Game_board.BackColor);
                S_Drawning.Set_graph_comp(graph_comp);
                m_Timer_for_One_Iteration = new Timer();
                m_Timer_for_One_Iteration.Tick += m_Timer_for_One_Iteration_Tick;
                m_Timer_for_One_Iteration.Interval = S_Constants.S_Constants.c_n_interval_of_game_timer;
                m_Timer_for_Delay = new Timer();
                m_Timer_for_Delay.Interval = S_Constants.S_Constants.c_n_iterval_of_delay;
                m_Timer_for_Delay.Tick += m_Timer_for_Delay_Tick;

                m_f_is_Delay_Over = m_f_is_Replace_over = true;

                Speed_Mode_Delegate SMD;
                if (m_Main_Window.chkb_Check_speed_mode.Checked)
                    SMD = Increase_Speed;
                else
                    SMD = Do_Nothing;
                Speed_Mode += SMD;

                m_random_for_food = new Random();
                // Пока что делаем так, начальные значения в константы не выносятся
                S_Location S1 = new S_Location(12, 0);
                S_Location S2 = new S_Location(13, 0);
                S_Location S3 = new S_Location(14, 0);
                S_Location S4 = new S_Location(15, 0);
                m_Snake = new S_Snake(E_Direction.Right, S4, S3, S2, S1);

                m_Board = new S_Game_Board(a_Window.P_Game_board, S_Drawning.Size_of_obj);
                m_Board.Set_Points_Value(false, new S_Location[] { S1, S2, S3, S4 });

                Add_new_Food();

                m_n_number_of_points = 0;
                Display_the_Score();
                m_Timer_for_One_Iteration.Start();
        }