/* Keyboard control while user on menu*/ bool Menu_Control_For_Keyboard(Keys e) { //Menu-1 - START GAME if (mygame.game_status == "menu_1") { if (e == Keys.Enter) { mygame.sound_menu.Stop(); mygame.game_status = "playing"; mygame.snake_route = 2; MyGame_timer.Enabled = true; return(true); } else if (e == Keys.Down) { mygame.Main_Menu(2); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_2"; return(true); } } //Menu-2 - INSTRUCTİONS else if (mygame.game_status == "menu_2") { if (e == Keys.Enter) { mygame.Instructions(); mygame.game_status = "instructions"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Down) { mygame.Main_Menu(3); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_3"; return(true); } else if (e == Keys.Up) { mygame.Main_Menu(1); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_1"; return(true); } } //Menu-3 - SETTINGS else if (mygame.game_status == "menu_3") { if (e == Keys.Enter) { mygame.Settings(1); mygame.game_status = "settings_1"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Down) { mygame.Main_Menu(4); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_4"; return(true); } else if (e == Keys.Up) { mygame.Main_Menu(2); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_2"; return(true); } } //Menu-4 - ABOUT else if (mygame.game_status == "menu_4") { if (e == Keys.Enter) { mygame.About(); mygame.game_status = "about"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Down) { mygame.Main_Menu(5); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_5"; return(true); } else if (e == Keys.Up) { mygame.Main_Menu(3); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_3"; return(true); } } //Menu-5 - EXIT else if (mygame.game_status == "menu_5") { if (e == Keys.Enter) { Application.Exit(); } else if (e == Keys.Up) { mygame.Main_Menu(4); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); mygame.game_status = "menu_4"; return(true); } } else if (mygame.game_status == "instructions") { if (e == Keys.Back) { mygame.Main_Menu(2); mygame.game_status = "menu_2"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } else if (mygame.game_status == "settings_1") { if (e == Keys.Back) { mygame.Main_Menu(3); mygame.game_status = "menu_3"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Down) { mygame.game_status = "settings_2"; mygame.Settings(2); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Enter) { if (mygame.sound_control == "on") { mygame.sound_control = "off"; mygame.sound_menu.Stop(); } else { mygame.sound_control = "on"; mygame.sound_menu.PlayLooping(); } mygame.Settings(1); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } else if (mygame.game_status == "settings_2") { if (e == Keys.Back) { mygame.Main_Menu(3); mygame.game_status = "menu_3"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Up) { mygame.game_status = "settings_1"; mygame.Settings(1); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Down) { mygame.game_status = "settings_3"; mygame.Settings(3); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Enter) { if (this.Size.Width < 791) { this.Size = new Size(950, 740); } else if (this.Size.Width < 951) { this.Size = new Size(1250, 740); } else if (this.Size.Width > 1249) { this.Size = new Size(790, 740); } mygame.game_height = (this.Size.Height - 50) - ((this.Size.Height - 50) % mygame.node_length); mygame.game_width = (this.Size.Width - 50) - ((this.Size.Width - 50) % mygame.node_length); Game_Create_Again(); mygame.game_status = "settings_2"; mygame.Settings(2); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } else if (mygame.game_status == "settings_3") { if (e == Keys.Back) { mygame.Main_Menu(3); mygame.game_status = "menu_3"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Up) { mygame.game_status = "settings_2"; mygame.Settings(2); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } else if (e == Keys.Enter) { if (mygame.speed_control == "easy") { mygame.speed_control = "hard"; Set_Game_Speed(1); } else if (mygame.speed_control == "hard") { mygame.speed_control = "hardest"; Set_Game_Speed(2); } else if (mygame.speed_control == "hardest") { mygame.speed_control = "easy"; Set_Game_Speed(0); } mygame.game_status = "settings_3"; mygame.Settings(3); pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } else if (mygame.game_status == "about") { if (e == Keys.Back) { mygame.Main_Menu(4); mygame.game_status = "menu_4"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } // CLEAR LEVEL else if (mygame.game_status == "clear") { if (e == Keys.Enter) { Level_Design(); Get_Ready(); mygame.game_status = "playing"; MyGame_timer.Enabled = true; } } // GAME OVER else if (mygame.game_status == "game_over") { if (e == Keys.Enter) { Game_Create_Again(); lb_point.Text = ""; lb_level.Text = "MENU"; pictureBox1.Image = mygame.menu_bmp; pictureBox1.Refresh(); return(true); } } Thread.Sleep(100); return(true); }