コード例 #1
0
ファイル: Main.cs プロジェクト: nagyist/drumkit-wp
        /// <summary>
        /// Constructor
        /// </summary>
        public Main()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            inputState = new InputState();
            recorder = new Recorder();
            Pad.Played += new EventHandler(Pad_Played);

            // Frame rate is 30 fps (=333333 ticks) by default for Windows Phone 7. However later
            // Windows Phone releases should support 60 fps, so we'll try that
            TargetElapsedTime = TimeSpan.FromTicks(166666);
            System.Diagnostics.Debug.WriteLine("Target elapsed time " + TargetElapsedTime.ToString());
        }
コード例 #2
0
ファイル: PadView.cs プロジェクト: nagyist/drumkit-wp
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="content">Access to resources</param>
        /// <param name="percussions">List of percussion samples</param>
        /// <param name="recorder">Records drum strokes</param>        
        /// <param name="width">Width of the screen</param>
        /// <param name="height">Height of the screen</param>
        public PadView(ContentManager content, Dictionary<Percussion, SoundEffect> percussions, Recorder recorder, int width, int height)
            : base(content, recorder, content.Load<Texture2D>("Images/bg_pads"), width, height)
        {
            this.percussions = percussions;
            splash = content.Load<Texture2D>("Images/splash");

            #region Initialize percussion menu and pads

            palette = new PercussionMenu(content.Load<Texture2D>("Images/Menu/close"));
            palette.Destination = new Point(400, 240);
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/splash"), content.Load<Texture2D>("Images/Menu/splash_highlight"), Percussion.SPLASH));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/ride1"), content.Load<Texture2D>("Images/Menu/ride1_highlight"), Percussion.RIDE));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/ride2"), content.Load<Texture2D>("Images/Menu/ride2_highlight"), Percussion.RIDE_BELL));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/tom1"), content.Load<Texture2D>("Images/Menu/tom1_highlight"), Percussion.TOM1));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/tom2"), content.Load<Texture2D>("Images/Menu/tom2_highlight"), Percussion.TOM2));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/tom3"), content.Load<Texture2D>("Images/Menu/tom3_highlight"), Percussion.TOM3));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/kick"), content.Load<Texture2D>("Images/Menu/kick_highlight"), Percussion.KICK));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/snare"), content.Load<Texture2D>("Images/Menu/snare_highlight"), Percussion.SNARE));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/cowbell"), content.Load<Texture2D>("Images/Menu/cowbell_highlight"), Percussion.COWBELL));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/hihat2"), content.Load<Texture2D>("Images/Menu/hihat2_highlight"), Percussion.HIHAT_CLOSED));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/hihat1"), content.Load<Texture2D>("Images/Menu/hihat1_highlight"), Percussion.HIHAT_OPEN));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/crash"), content.Load<Texture2D>("Images/Menu/crash_highlight"), Percussion.CRASH));
            palette.Add(new PercussionItem(content.Load<Texture2D>("Images/Menu/china"), content.Load<Texture2D>("Images/Menu/china_highlight"), Percussion.CHINA));

            pads = new List<Pad>();
            pads.Add(new Pad(Percussion.CRASH, percussions[Percussion.CRASH], new Rectangle(130, 76, 173, 172)));
            pads.Add(new Pad(Percussion.RIDE, percussions[Percussion.RIDE], new Rectangle(515, 71, 180, 170)));
            pads.Add(new Pad(Percussion.SNARE, percussions[Percussion.SNARE], new Rectangle(254, 322, 148, 148)));
            pads.Add(new Pad(Percussion.KICK, percussions[Percussion.KICK], new Rectangle(13, 252, 219, 211)));
            pads.Add(new Pad(Percussion.HIHAT_CLOSED, percussions[Percussion.HIHAT_CLOSED], new Rectangle(589, 247, 205, 192)));
            pads.Add(new Pad(Percussion.TOM1, percussions[Percussion.TOM1], new Rectangle(317, 132, 188, 188)));
            pads.Add(new Pad(Percussion.TOM3, percussions[Percussion.TOM3], new Rectangle(435, 325, 146, 145)));

            #endregion

            PercussionItem.Selected += new EventHandler(PercussionItem_Selected);

            infoButton.Location = new Point(0, 0);
            viewButton.Location = new Point(0, 103);
            recordButton.Location = new Point(297, 16);
            playButton.Location = new Point(400, 16);
            stopButton.Location = new Point(400, 16);
            exitButton.Location = new Point(697, 0);

            info.Message = "Thanks for using Drumkit!\n\n" + "Let your fills fly by tapping the pads.\n" +
                "You may also record your beats and play them afterwards.\n" +
                "Long tap on a pad lets you select different instruments.\n\n" +
                "Tap the screen to continue!";
        }
コード例 #3
0
ファイル: DrummingView.cs プロジェクト: nagyist/drumkit-wp
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="content">Access to resources</param>
        /// <param name="recorder">Records drum strokes</param>
        /// <param name="background">Background image</param>
        /// <param name="width">Width of the screen</param>
        /// <param name="height">Height of the screen</param>
        public DrummingView(ContentManager content, Recorder recorder, Texture2D background, int width, int height)
            : base(width, height)
        {
            this.background = background;
            this.recorder = recorder;

            recorder.TapeEnded += new EventHandler(Recorder_TapeEnded);

            // Create buttons
            buttons = new List<Button>();
            infoButton = new Button(content.Load<Texture2D>("Images/Buttons/info"), content.Load<Texture2D>("Images/Buttons/info_pressed"));
            viewButton = new Button(content.Load<Texture2D>("Images/Buttons/pads"), content.Load<Texture2D>("Images/Buttons/pads_pressed"));
            recordButton = new AnimatedToggleButton(content.Load<Texture2D>("Images/Buttons/record"), content.Load<Texture2D>("Images/Buttons/record_pressed"),
                content.Load<Texture2D>("Images/Buttons/recording"), 18, 18);
            playButton = new Button(content.Load<Texture2D>("Images/Buttons/play"), content.Load<Texture2D>("Images/Buttons/play_pressed"));
            stopButton = new Button(content.Load<Texture2D>("Images/Buttons/stop"), content.Load<Texture2D>("Images/Buttons/stop_pressed"));
            exitButton = new Button(content.Load<Texture2D>("Images/Buttons/exit"), content.Load<Texture2D>("Images/Buttons/exit_pressed"));

            // Attach event handlers
            infoButton.Clicked += new EventHandler(InfoButton_Clicked);
            viewButton.Clicked += new EventHandler(viewButton_Clicked);
            recordButton.Clicked += new EventHandler(RecordButton_Clicked);
            playButton.Clicked += new EventHandler(PlayButton_Clicked);
            stopButton.Clicked += new EventHandler(StopButton_Clicked);
            exitButton.Clicked += new EventHandler(ExitButton_Clicked);

            playButton.Disable();
            stopButton.Visible = false;

            // Add buttons to a list for easy looping
            buttons.Add(infoButton);
            buttons.Add(viewButton);
            buttons.Add(recordButton);
            buttons.Add(playButton);
            buttons.Add(stopButton);
            buttons.Add(exitButton);

            info = new InfoOverlay(new Rectangle(0, 0, width, height));
        }
コード例 #4
0
ファイル: DrumsetView.cs プロジェクト: nagyist/drumkit-wp
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="content">Access to resources</param>
        /// <param name="percussions">List of percussion samples</param>
        /// <param name="recorder">Records drum strokes</param>        
        /// <param name="width">Width of the screen</param>
        /// <param name="height">Height of the screen</param>                
        public DrumsetView(ContentManager content, Dictionary<Percussion, SoundEffect> percussions, Recorder recorder, int width, int height)
            : base(content, recorder, content.Load<Texture2D>("Images/Drumset/background"), width, height)
        {
            locks = content.Load<Texture2D>("Images/Drumset/locks");

            pads = new List<Pad>();
            List<Rectangle> touchAreas = new List<Rectangle>();

            #region Initialize pads and their touch areas
            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(318, 60, 154, 69));
            Cymbal splash = new Cymbal(Percussion.SPLASH, percussions[Percussion.SPLASH], new Rectangle(309, 57, 168, 71), touchAreas, content.Load<Texture2D>("Images/Drumset/splash"));
            splash.Origin = new Vector2(84f, 8f);
            splash.MaxAngle = 0.2f;
            pads.Add(splash);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(221, 159, 132, 134));
            pads.Add(new Drum(Percussion.TOM1, percussions[Percussion.TOM1], new Rectangle(217, 155, 135, 168), touchAreas, content.Load<Texture2D>("Images/Drumset/tom1")));

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(355, 149, 141, 132));
            pads.Add(new Drum(Percussion.TOM2, percussions[Percussion.TOM2], new Rectangle(356, 149, 150, 185), touchAreas, content.Load<Texture2D>("Images/Drumset/tom2")));

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(475, 244, 169, 110));
            touchAreas.Add(new Rectangle(496, 358, 102, 35));
            pads.Add(new Drum(Percussion.TOM3, percussions[Percussion.TOM3], new Rectangle(471, 240, 179, 251), touchAreas, content.Load<Texture2D>("Images/Drumset/tom3")));

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(0, 110, 144, 66));
            touchAreas.Add(new Rectangle(16, 154, 206, 85));
            Cymbal crash = new Cymbal(Percussion.CRASH, percussions[Percussion.CRASH], new Rectangle(-20, 92, 248, 145), touchAreas, content.Load<Texture2D>("Images/Drumset/crash"));
            crash.Origin = new Vector2(140f, 35f);
            crash.MaxAngle = 0.16f;
            pads.Add(crash);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(130, 40, 181, 76));
            touchAreas.Add(new Rectangle(185, 116, 136, 37));
            Cymbal china = new Cymbal(Percussion.CHINA, percussions[Percussion.CHINA], new Rectangle(114, 36, 213, 125), touchAreas, content.Load<Texture2D>("Images/Drumset/china"));
            china.Origin = new Vector2(110f, 46f);
            china.MaxAngle = 0.17f;
            pads.Add(china);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(467, 45, 274, 66));
            touchAreas.Add(new Rectangle(467, 112, 206, 32));
            Cymbal rideBell = new Cymbal(Percussion.RIDE_BELL, percussions[Percussion.RIDE_BELL], new Rectangle(464, 45, 279, 101), touchAreas, content.Load<Texture2D>("Images/Drumset/ride2"));
            rideBell.Origin = new Vector2(135f, 15f);
            rideBell.MaxAngle = -0.04f;
            pads.Add(rideBell);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(544, 144, 257, 92));
            touchAreas.Add(new Rectangle(678, 112, 122, 45));
            Cymbal ride = new Cymbal(Percussion.RIDE, percussions[Percussion.RIDE], new Rectangle(542, 108, 270, 125), touchAreas, content.Load<Texture2D>("Images/Drumset/ride1"));
            ride.Origin = new Vector2(125f, 27f);
            ride.MaxAngle = -0.08f;
            pads.Add(ride);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(642, 296, 0, 0));
            Cymbal hihatOpenL = new Cymbal(Percussion.HIHAT_OPEN, percussions[Percussion.HIHAT_OPEN], new Rectangle(634, 266, 207, 83), touchAreas, content.Load<Texture2D>("Images/Drumset/hihat_open_lower"));
            hihatOpenL.Origin = new Vector2(103f, 37f);
            hihatOpenL.MaxAngle = -0.06f;
            pads.Add(hihatOpenL); // lower cymbal

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(641, 232, 159, 115));
            Cymbal hihatOpenU = new Cymbal(Percussion.HIHAT_OPEN, percussions[Percussion.HIHAT_OPEN], new Rectangle(634, 232, 216, 92), touchAreas, content.Load<Texture2D>("Images/Drumset/hihat_open_upper"));
            hihatOpenU.Origin = new Vector2(108f, 12f);
            hihatOpenU.MaxAngle = -0.14f;
            pads.Add(hihatOpenU); // upper cymbal

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(643, 352, 157, 100));
            touchAreas.Add(new Rectangle(602, 364, 57, 69));
            Cymbal hihatClosed = new Cymbal(Percussion.HIHAT_CLOSED, percussions[Percussion.HIHAT_CLOSED], new Rectangle(591, 344, 229, 102), touchAreas, content.Load<Texture2D>("Images/Drumset/hihat_closed"));
            hihatClosed.Origin = new Vector2(115f, 13f);
            hihatClosed.MaxAngle = -0.01f;
            pads.Add(hihatClosed);

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(16, 239, 196, 229));
            pads.Add(new Drum(Percussion.KICK, percussions[Percussion.KICK], new Rectangle(-10, 238, 250, 235), touchAreas, content.Load<Texture2D>("Images/Drumset/kick")));

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(212, 292, 193, 122));
            pads.Add(new Drum(Percussion.SNARE, percussions[Percussion.SNARE], new Rectangle(212, 288, 197, 178), touchAreas, content.Load<Texture2D>("Images/Drumset/snare")));

            touchAreas = new List<Rectangle>();
            touchAreas.Add(new Rectangle(405, 354, 82, 108));
            touchAreas.Add(new Rectangle(463, 375, 50, 87));
            pads.Add(new Drum(Percussion.COWBELL, percussions[Percussion.COWBELL], new Rectangle(402, 353, 106, 107), touchAreas, content.Load<Texture2D>("Images/Drumset/cowbell")));
            #endregion

            infoButton.Location = new Point(-10, -10);
            viewButton.Location = new Point(66, -10);
            recordButton.Location = new Point(257, -10);
            playButton.Location = new Point(430, -10);
            stopButton.Location = new Point(430, -10);
            exitButton.Location = new Point(707, -10);

            playButton.Disable();
            stopButton.Visible = false;

            info.Message = "In this view you have actual drumset to play with.\n" +
                "Again, you may record your beats and play them afterwards.\n" +
                "All the percussions are available at your finger tips,\n" +
                "so there is no separate percussion palette in this view.\n\n" +
                "Tap the screen to continue!";
        }
コード例 #5
0
ファイル: PadView.cs プロジェクト: nagyist/drumkit-wp
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="content">Access to resources</param>
        /// <param name="percussions">List of percussion samples</param>
        /// <param name="recorder">Records drum strokes</param>
        /// <param name="width">Width of the screen</param>
        /// <param name="height">Height of the screen</param>
        public PadView(ContentManager content, Dictionary <Percussion, SoundEffect> percussions, Recorder recorder, int width, int height)
            : base(content, recorder, content.Load <Texture2D>("Images/bg_pads"), width, height)
        {
            this.percussions = percussions;
            splash           = content.Load <Texture2D>("Images/splash");

            #region Initialize percussion menu and pads

            palette             = new PercussionMenu(content.Load <Texture2D>("Images/Menu/close"));
            palette.Destination = new Point(400, 240);
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/splash"), content.Load <Texture2D>("Images/Menu/splash_highlight"), Percussion.SPLASH));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/ride1"), content.Load <Texture2D>("Images/Menu/ride1_highlight"), Percussion.RIDE));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/ride2"), content.Load <Texture2D>("Images/Menu/ride2_highlight"), Percussion.RIDE_BELL));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/tom1"), content.Load <Texture2D>("Images/Menu/tom1_highlight"), Percussion.TOM1));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/tom2"), content.Load <Texture2D>("Images/Menu/tom2_highlight"), Percussion.TOM2));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/tom3"), content.Load <Texture2D>("Images/Menu/tom3_highlight"), Percussion.TOM3));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/kick"), content.Load <Texture2D>("Images/Menu/kick_highlight"), Percussion.KICK));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/snare"), content.Load <Texture2D>("Images/Menu/snare_highlight"), Percussion.SNARE));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/cowbell"), content.Load <Texture2D>("Images/Menu/cowbell_highlight"), Percussion.COWBELL));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/hihat2"), content.Load <Texture2D>("Images/Menu/hihat2_highlight"), Percussion.HIHAT_CLOSED));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/hihat1"), content.Load <Texture2D>("Images/Menu/hihat1_highlight"), Percussion.HIHAT_OPEN));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/crash"), content.Load <Texture2D>("Images/Menu/crash_highlight"), Percussion.CRASH));
            palette.Add(new PercussionItem(content.Load <Texture2D>("Images/Menu/china"), content.Load <Texture2D>("Images/Menu/china_highlight"), Percussion.CHINA));

            pads = new List <Pad>();
            pads.Add(new Pad(Percussion.CRASH, percussions[Percussion.CRASH], new Rectangle(130, 76, 173, 172)));
            pads.Add(new Pad(Percussion.RIDE, percussions[Percussion.RIDE], new Rectangle(515, 71, 180, 170)));
            pads.Add(new Pad(Percussion.SNARE, percussions[Percussion.SNARE], new Rectangle(254, 322, 148, 148)));
            pads.Add(new Pad(Percussion.KICK, percussions[Percussion.KICK], new Rectangle(13, 252, 219, 211)));
            pads.Add(new Pad(Percussion.HIHAT_CLOSED, percussions[Percussion.HIHAT_CLOSED], new Rectangle(589, 247, 205, 192)));
            pads.Add(new Pad(Percussion.TOM1, percussions[Percussion.TOM1], new Rectangle(317, 132, 188, 188)));
            pads.Add(new Pad(Percussion.TOM3, percussions[Percussion.TOM3], new Rectangle(435, 325, 146, 145)));

            #endregion

            PercussionItem.Selected += new EventHandler(PercussionItem_Selected);

            infoButton.Location   = new Point(0, 0);
            viewButton.Location   = new Point(0, 103);
            recordButton.Location = new Point(297, 16);
            playButton.Location   = new Point(400, 16);
            stopButton.Location   = new Point(400, 16);
            exitButton.Location   = new Point(697, 0);

            info.Message = "Thanks for using Drumkit!\n\n" + "Let your fills fly by tapping the pads.\n" +
                           "You may also record your beats and play them afterwards.\n" +
                           "Long tap on a pad lets you select different instruments.\n\n" +
                           "Tap the screen to continue!";
        }