private bool Player_Hits(int x, int y) { if (m_Visit[x, y]) { m_Timer.Stop(); FX_Sounds_GameOver_or_WörmHits(); m_MusicPlayer.controls.stop(); //MessageBox.Show("Snake hit his Body"); this.Close(); Game_Over_Wörm game_Over_Wörm = new Game_Over_Wörm(); game_Over_Wörm.Show(); //return true; // THIS IS FROM OLD CODE } return(false); }
private void Player_Move(object sender, EventArgs e) { int x = m_Snake[m_Front].Location.X, y = m_Snake[m_Front].Location.Y; if (m_Dx == 0 && m_Dy == 0) { return; } //push any arrow key to start, dispose controls image and other Controls_picturebox.Dispose(); Ball1_gif.Dispose(); Ball_gif.Dispose(); Esc_pictureBox.Dispose(); Warning_label.Dispose(); if (GameOver(x + m_Dx, y + m_Dy)) { m_Timer.Stop(); FX_Sounds_GameOver_or_WörmHits(); //MessageBox.Show("Game Over"); m_MusicPlayer.controls.stop(); this.Close(); Game_Over_Wörm game_Over_Wörm = new Game_Over_Wörm(); game_Over_Wörm.Show(); return; } // if player hits Hollowman, this don`t work //if ((CollisionHollowman(x + m_Dx, y + m_Dy)) || (CollisionHollowman2(x + m_Dx, y + m_Dy)) || (CollisionHollowman3(x + m_Dx, y + m_Dy)) || (CollisionHollowman4(x + m_Dx, y + m_Dy)) || (CollisionHollowman5(x + m_Dx, y + m_Dy)) || (CollisionHollowman6(x + m_Dx, y + m_Dy))) //{ // if (true) // { // m_Timer.Stop(); // FX_Sounds_GameOver_or_WörmHits(); // //MessageBox.Show("Game Over"); // m_MusicPlayer.controls.stop(); // this.Close(); // Game_Over_Wörm game_Over_Wörm = new Game_Over_Wörm(); // game_Over_Wörm.Show(); // return; // } //} if (CollisionFood(x + m_Dx, y + m_Dy)) { m_Score += 1; //Old scores!!! Not in use!!! //lblScore.Text = "Apples: " + m_Score.ToString(); // Converts int to string in textbox m_WörmApplesAndSpeedForm.Apples_textBox.Text = "" + m_Score.ToString(); // Hollowman apairs if u get certain amount of apples if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "20") { DontHitHolloman_gif.Visible = true; DontHitHolloman_gif.Enabled = true; DontHitHolloman_gif.BringToFront(); FX_Sounds_Hollowman(); } else if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "40") { DontHitHolloman2_gif.Visible = true; DontHitHolloman2_gif.Enabled = true; DontHitHolloman2_gif.BringToFront(); FX_Sounds_Hollowman(); } else if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "60") { DontHitHolloman3_gif.Visible = true; DontHitHolloman3_gif.Enabled = true; DontHitHolloman3_gif.BringToFront(); FX_Sounds_Hollowman(); } else if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "80") { DontHitHolloman4_gif.Visible = true; DontHitHolloman4_gif.Enabled = true; DontHitHolloman4_gif.BringToFront(); FX_Sounds_Hollowman(); } else if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "100") { DontHitHolloman5_gif.Visible = true; DontHitHolloman5_gif.Enabled = true; DontHitHolloman5_gif.BringToFront(); FX_Sounds_Hollowman(); } else if (m_WörmApplesAndSpeedForm.Apples_textBox.Text == "120") { DontHitHolloman6_gif.Visible = true; DontHitHolloman6_gif.Enabled = true; DontHitHolloman6_gif.BringToFront(); FX_Sounds_Hollowman(); } if (Player_Hits((y + m_Dy) / 20, (x + m_Dx) / 20)) { return; } //Piece m_Head = new Piece(x + m_Dx, y + m_Dy); //PieceBody m_Body = new PieceBody(x + m_Dx, y + m_Dy); //m_Front = (m_Front - 1 + 1250) % 1250; //m_Snake[m_Front] = m_Head; //m_Visit[m_Head.Location.Y / 20, m_Head.Location.X / 20] = true; //Controls.Add(m_Body); //m_Body.BringToFront(); // when new head spawns, it spawns front of the background.gif //FX_Sounds_ApplePick(); //RandomFood(); //Old style, only 1 bodypart Piece m_Head = new Piece(x + m_Dx, y + m_Dy); m_Front = (m_Front - 1 + 1250) % 1250; m_Snake[m_Front] = m_Head; m_Visit[m_Head.Location.Y / 20, m_Head.Location.X / 20] = true; Controls.Add(m_Head); m_Head.BringToFront(); // when new head spawns, it spawns front of the background.gif FX_Sounds_ApplePick(); RandomFood(); // When wörm eats apple wörm become faster if (true) { m_Timer.Interval -= 2; // adds time interval readings to other form also coverts int to string(Text) // m_WörmApplesAndSpeedForm.WörmSpeed_textBox.Text = "" + m_Timer.Interval.ToString(); } } else { if (Player_Hits((y + m_Dy) / 20, (x + m_Dx) / 20)) { return; } { m_Visit[m_Snake[m_Back].Location.Y / 20, m_Snake[m_Back].Location.X / 20] = false; m_Front = (m_Front - 1 + 1250) % 1250; m_Snake[m_Front] = m_Snake[m_Back]; m_Snake[m_Front].Location = new Point(x + m_Dx, y + m_Dy); m_Back = (m_Back - 1 + 1250) % 1250; m_Visit[(y + m_Dy) / 20, (x + m_Dx) / 20] = true; } } }