Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public override void HandleSdlKeyDownEvent(KeyboardEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            System.Diagnostics.Debug.WriteLine(args.Key.ToString());

            try
            {
                switch (args.Key)
                {
                case Key.Space:
                    if (triad != null)
                    {
                        triad.Permute();
                        permuteSound.Play();
                    }

                    break;

                case Key.LeftArrow:
                    if (triad != null)
                    {
                        moveTriadLeft = true;
                        triad.MoveLeft();
                        this.moveSound.Play();
                        this.lastTriadLeftRight = Timer.TicksElapsed;
                    }

                    break;

                case Key.RightArrow:
                    if (triad != null)
                    {
                        moveTriadRight = true;
                        triad.MoveRight();
                        this.moveSound.Play();
                        this.lastTriadLeftRight = Timer.TicksElapsed;
                    }
                    break;

                case Key.DownArrow:
                    this.rapidDropTriad = true;
                    break;

                case Key.P:
                    gameIsPaused = !gameIsPaused;
                    break;

                default:
                    System.Diagnostics.Debug.WriteLine("Key not handled: " +
                                                       args.Key.ToString());
                    break;
                }
            }
            catch (SdlException)
            {
            }
        }