Exemple #1
0
        private void btn_play_Click(object sender, EventArgs e)
        {
            LevelsForm levelsForm = new LevelsForm();

            levelsForm.Show();
            this.Hide();
        }
Exemple #2
0
        private void GameForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                DialogResult result = MessageBox.Show(
                    "Вы действительно хотите вернуться?",
                    "Предупреждение",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Yes)
                {
                    LevelsForm levelsForm = new LevelsForm();
                    levelsForm.Show();
                    this.Hide();
                }
            }
            if (e.KeyCode == Keys.W)
            {
                if (Math.Ceiling(player.distance_to_wall) > Settings.PLAYER_SPEED)
                {
                    player.x += (float)(Settings.PLAYER_SPEED * Math.Cos((double)(player.angle * Math.PI / 180.0)));
                    player.y += (float)(Settings.PLAYER_SPEED * Math.Sin((double)(player.angle * Math.PI / 180.0)));
                    maps_refresh(map_2D_panel_graphics, map_3D_panel_graphics);
                }
                else
                {
                    //если игрок оказался в стене, вернуть его на назад
                    player.x -= (float)(Settings.PLAYER_SPEED * Math.Cos((double)(player.angle * Math.PI / 180.0)));
                    player.y -= (float)(Settings.PLAYER_SPEED * Math.Sin((double)(player.angle * Math.PI / 180.0)));
                    maps_refresh(map_2D_panel_graphics, map_3D_panel_graphics);
                }
            }
            if (e.KeyCode == Keys.Left)
            {
                player.angle -= Settings.ROTATE_ANGLE;
                maps_refresh(map_2D_panel_graphics, map_3D_panel_graphics);
            }
            if (e.KeyCode == Keys.Right)
            {
                player.angle += Settings.ROTATE_ANGLE;
                maps_refresh(map_2D_panel_graphics, map_3D_panel_graphics);
            }
            playerPos.X = (int)player.x;
            playerPos.Y = (int)player.y;

            double cur_angle = player.angle - Settings.HALF_FOV;

            //проверка выхода из лабиринта
            if (playerPos.X > Settings.MAP_3D_WIDTH ||
                playerPos.X < 0 ||
                playerPos.Y > Settings.MAP_3D_HEIGHT ||
                playerPos.Y < 0)
            {
                Settings.passed_levels[Settings.current_level - 1] = true;
                DialogResult result = MessageBox.Show(
                    "Вы прошли " + Settings.current_level.ToString() + " уровень!",
                    "Поздравляем!",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk,
                    MessageBoxDefaultButton.Button1);

                LevelsForm levelsForm = new LevelsForm();
                levelsForm.Show();
                this.Hide();
            }
        }