//Methods public void NoteFucntion(MouseState CurrentButton, MouseState PriorButton, Sound.TOctaveIndex Octave) { int CurrentOctave; CurrentButton = Mouse.GetState(); CurrentOctave = (int)Octave; bool PlayNoteC = CurrentButton.LeftButton == ButtonState.Pressed && PriorButton.LeftButton == ButtonState.Released; bool StopNoteC = CurrentButton.LeftButton == ButtonState.Released && PriorButton.LeftButton == ButtonState.Pressed; if (PlayNoteC && _AreaOfClick.Contains(CurrentButton.X, CurrentButton.Y)) { _Pressed = true; _Instance[CurrentOctave].Play(); } if (StopNoteC) { _Instance[CurrentOctave].Stop(); } } // Works the click function
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here this.IsMouseVisible = true; Restart = false; base.Initialize(); _KeyList = new List <PlayNote>(); CurrentKeyImage = new PlayNote[9]; string DictionaryIndex = ""; string SoundFile = ""; _MyGameForm = (Form)Form.FromHandle(this.Window.Handle); Sound.TVariation Variation = (Sound.TVariation) 5; for (Sound.TNote Note = Sound.TNote.A; Note < (Sound.TNote) 8; Note++) { for (Sound.TOctaveIndex Octave = Sound.TOctaveIndex.Octave_1; Octave < (Sound.TOctaveIndex) 6; Octave++) { DictionaryIndex = string.Concat((int)Note, (int)Octave, (int)Variation); SoundFile = string.Concat(Note, (int)Octave, Variation); try { SoundEffect Temp = Content.Load <SoundEffect>(SoundFile); Sound.Sound_Library.Add(DictionaryIndex, Temp); } catch { Sound.Sound_Library.Add(DictionaryIndex, null);//Not every octave can be filled. Not appropriate to abort the process } } } Image = Content.Load <Texture2D>("Quaver - Copy"); Note.NoteImages.Add(Image); Image = Content.Load <Texture2D>("Quaver"); Note.NoteImages.Add(Image); Image = Content.Load <Texture2D>("Crotchet"); Note.NoteImages.Add(Image); Image = Content.Load <Texture2D>("Minim"); Note.NoteImages.Add(Image); Image = Content.Load <Texture2D>("Semibreve"); Note.NoteImages.Add(Image); Image = Content.Load <Texture2D>("A note"); PlayNote.KeyImages.Add("A", Image); Image = Content.Load <Texture2D>("B note"); PlayNote.KeyImages.Add("B", Image); Image = Content.Load <Texture2D>("C note"); PlayNote.KeyImages.Add("C", Image); Image = Content.Load <Texture2D>("D note"); PlayNote.KeyImages.Add("D", Image); Image = Content.Load <Texture2D>("E note"); PlayNote.KeyImages.Add("E", Image); Image = Content.Load <Texture2D>("F note"); PlayNote.KeyImages.Add("F", Image); Image = Content.Load <Texture2D>("G note"); PlayNote.KeyImages.Add("G", Image); C = new PlayNote("335", 1); D = new PlayNote("435", 2); E = new PlayNote("535", 3); F = new PlayNote("635", 4); G = new PlayNote("735", 5); A = new PlayNote("145", 6); B = new PlayNote("245", 7); C1 = new PlayNote("345", 8); _KeyList.Add(C); _KeyList.Add(D); _KeyList.Add(E); _KeyList.Add(F); _KeyList.Add(G); _KeyList.Add(A); _KeyList.Add(B); _KeyList.Add(C1); PauseButton = Content.Load <Texture2D>("PauseButton"); Ticker = Content.Load <Texture2D>("Ticker"); CurrentNoteBox = Content.Load <Texture2D>("CurrentNoteBox"); spriteFont = Content.Load <SpriteFont>("SpriteFont1"); Image = Content.Load <Texture2D>("staves"); DifficultyBar = Content.Load <Texture2D>("DifficultyBar"); DifficultySlider = Content.Load <Texture2D>("DifficultyBarSlider"); Bar = Content.Load <Texture2D>("Bar"); UpArrow = Content.Load <Texture2D>("Up Arrow"); DownArrow = Content.Load <Texture2D>("Down Arrow"); }
} // Works the click function public void NoteFunction(KeyboardState Current, KeyboardState Prior, char Key, Sound.TOctaveIndex Octave) { int CurrentOctave = (int)Octave; Keys AsKey = (Keys)Key; bool PlayNoteK = Current.IsKeyDown(AsKey) && Prior.IsKeyUp(AsKey); bool StopNoteK = Current.IsKeyUp(AsKey) && Prior.IsKeyDown(AsKey); if (PlayNoteK) { _Pressed = true; try { _Instance[CurrentOctave].Play(); } catch { } } if (StopNoteK) { try { _Instance[CurrentOctave].Stop(); } catch { } } } // Works the key function