Esempio n. 1
0
        private void BuildAnimations()
        {
            //              Counter Stuff
            int    x, y;
            Sprite temp;

            x = HelperUtils.SafeBoundary.X + 578;
            y = HelperUtils.SafeBoundary.Y + 566;

            // Create the ducks for the counter
            for (int i = 0; i < 10; i++)
            {
                temp             = new Sprite();
                temp.Texture     = m_duckcount_txt;
                temp.X_Pos       = x;
                temp.Y_Pos       = y;
                m_ducks[i]       = new Duck();
                m_ducks[i].m_spr = temp;
                x -= (m_duckcount_txt.Width + 2);
            }

            m_counter_spr.Texture = m_countbg_txt;
            m_counter_spr.X_Pos   = HelperUtils.SafeBoundary.X + 512 - (m_countbg_txt.Width / 2);
            m_counter_spr.Y_Pos   = HelperUtils.SafeBoundary.Y + 536;

            //            Intermission Stuff

            m_flyawayduck_anim_1.BuildAnimation(m_flyingaway_txt, 1, 3, true, new int[4] {
                0, 1, 2, 1
            });
            m_flyawayduck_anim_1.SetFrame(0, 4, null);
            m_flyawayduck_anim_1.SetFrame(1, 4, m_flapwing_snd);
            m_flyawayduck_anim_1.SetFrame(2, 4, null);
            m_flyawayduck_anim_1.SetFrame(3, 4, m_flapwing_snd);

            m_flyawayduck_anim_2.BuildAnimation(m_flyingaway_txt, 1, 3, true, new int[4] {
                0, 1, 2, 1
            });
            m_flyawayduck_anim_2.SetFrame(0, 4, null);
            m_flyawayduck_anim_2.SetFrame(1, 4, m_flapwing_snd);
            m_flyawayduck_anim_2.SetFrame(2, 4, null);
            m_flyawayduck_anim_2.SetFrame(3, 4, m_flapwing_snd);

            m_laughdog_anim.BuildAnimation(m_laughingdog_txt, 1, 2, true, new int[2] {
                0, 1
            });
            m_laughdog_anim.SetFrame(0, 6, null);
            m_laughdog_anim.SetFrame(1, 6, null);

            m_dog_laugh_scn_inter.AddAnimation(new DirXYMover(m_laughdog_anim, 0, -47, 1.4f), m_doglaugh_snd);
            m_dog_laugh_scn_inter.AddAnimation(new TimeOutDrawable(m_laughdog_anim, 60, true));
            m_dog_laugh_scn_inter.AddAnimation(new DirXYMover(m_laughdog_anim, 0, 47, 1.6f));
        }
Esempio n. 2
0
        public override void LoadContent()
        {
            if (m_content == null)
            {
                m_content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            m_duck_txt = m_content.Load <Texture2D>("DuckHunt\\Textures\\duck");
            m_menu_fnt = m_content.Load <SpriteFont>("Fonts\\bigfont");

            m_selector_snd = m_content.Load <SoundEffect>("DuckHunt\\Sounds\\select");

            m_resume  = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X / 2, 150, "RESUME", m_menu_fnt);
            m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt);
            m_quit    = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 160 + 2 * m_resume.Height, "QUIT", m_menu_fnt);

            m_selector = new AnimatedSprite();
            m_selector.BuildAnimation(m_duck_txt, 1, 9, true, new int[4] {
                3, 4, 5, 4
            });
            m_selector.SetFrame(0, 9, null);
            m_selector.SetFrame(1, 9, null);
            m_selector.SetFrame(2, 9, null);
            m_selector.SetFrame(3, 9, null);
            m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width * 1.5);
            m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height / 2;

            // Hook up menu event handlers.
            m_resume.m_selected_events  += OnCancel;
            m_restart.m_selected_events += RestartGameMenuEntrySelected;
            m_quit.m_selected_events    += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(m_resume);
            MenuEntries.Add(m_restart);
            MenuEntries.Add(m_quit);

            m_selected = m_resume;
        }
Esempio n. 3
0
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
            {
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            }

            /*  LOAD TEXTURES, SOUNDS AND FONTS */

            tree   = content.Load <Texture2D>("DuckHunt\\Textures\\tree");
            ground = content.Load <Texture2D>("DuckHunt\\Textures\\ground");
            bush   = content.Load <Texture2D>("DuckHunt\\Textures\\bush");
            m_player_textures[0] = content.Load <Texture2D>("DuckHunt\\Textures\\panel");
            walkingdog           = content.Load <Texture2D>("DuckHunt\\Textures\\walkdog");
            flyawaysign          = content.Load <Texture2D>("DuckHunt\\Textures\\flyawaysign");
            m_player_textures[1] = content.Load <Texture2D>("DuckHunt\\Textures\\score");
            m_player_textures[2] = content.Load <Texture2D>("DuckHunt\\Textures\\clouds");
            m_player_textures[3] = content.Load <Texture2D>("DuckHunt\\Textures\\duckcall");
            m_player_textures[4] = content.Load <Texture2D>("DuckHunt\\Textures\\shot");
            clouds[0]            = content.Load <Texture2D>("DuckHunt\\Textures\\smallcloud");
            clouds[1]            = content.Load <Texture2D>("DuckHunt\\Textures\\medcloud");
            clouds[2]            = content.Load <Texture2D>("DuckHunt\\Textures\\bigcloud");

            dogbark    = content.Load <SoundEffect>("DuckHunt\\Sounds\\dogbark");
            m_shot     = content.Load <SoundEffect>("DuckHunt\\Sounds\\shot");
            startround = content.Load <SoundEffect>("DuckHunt\\Sounds\\startround");
            endround   = content.Load <SoundEffect>("DuckHunt\\Sounds\\roundend");
            pause      = content.Load <SoundEffect>("DuckHunt\\Sounds\\pause");

            m_num       = content.Load <SpriteFont>("Fonts\\bignesfont");
            m_score_fnt = content.Load <SpriteFont>("Fonts\\hugenesfont");

            debug = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            debug.SetData(new Color[] { new Color(255, 255, 255) });

            m_clouds_p1 = new Clouds(0, clouds); //, debug);
            m_clouds_p2 = new Clouds(1, clouds); //, debug);
            m_clouds    = new Cloud[m_clouds_p1.CloudsA.Length * 2];

            m_clouds[0]  = m_clouds_p1.CloudsA[0];
            m_clouds[1]  = m_clouds_p1.CloudsA[1];
            m_clouds[2]  = m_clouds_p1.CloudsA[2];
            m_clouds[3]  = m_clouds_p1.CloudsA[0];
            m_clouds[4]  = m_clouds_p1.CloudsA[1];
            m_clouds[5]  = m_clouds_p1.CloudsA[2];
            m_clouds[6]  = m_clouds_p2.CloudsA[0];
            m_clouds[7]  = m_clouds_p2.CloudsA[1];
            m_clouds[8]  = m_clouds_p2.CloudsA[2];
            m_clouds[9]  = m_clouds_p2.CloudsA[0];
            m_clouds[10] = m_clouds_p2.CloudsA[1];
            m_clouds[11] = m_clouds_p2.CloudsA[2];

            /* SETUP ALL ANIMATIONSPRITES */
            wdog.BuildAnimation(walkingdog, 1, 8, true, new int[4] {
                1, 2, 3, 4
            });
            wdog.SetFrame(0, 8, null);
            wdog.SetFrame(1, 8, null);
            wdog.SetFrame(2, 8, null);
            wdog.SetFrame(3, 8, null);
            wdog.X_Pos = HelperUtils.SafeBoundary.X + 22;
            wdog.Y_Pos = HelperUtils.SafeBoundary.Y + 471;

            sdog.BuildAnimation(walkingdog, 1, 8, true, new int[6] {
                1, 0, 1, 0, 1, 0
            });
            sdog.SetFrame(0, 8, null);
            sdog.SetFrame(1, 8, null);
            sdog.SetFrame(2, 8, null);
            sdog.SetFrame(3, 8, null);
            sdog.SetFrame(4, 8, null);
            sdog.SetFrame(5, 8, null);

            sprdog.BuildAnimation(walkingdog, 1, 8, true, new int[1] {
                5
            });
            sprdog.SetFrame(0, 100, null);

            jdog1.BuildAnimation(walkingdog, 1, 8, true, new int[1] {
                6
            });
            jdog1.SetFrame(0, 1000, dogbark);

            jdog2.BuildAnimation(walkingdog, 1, 8, true, new int[1] {
                6
            });
            jdog2.SetFrame(0, 50, dogbark);

            jdog3.BuildAnimation(walkingdog, 1, 8, true, new int[1] {
                7
            });
            jdog3.SetFrame(0, 50, dogbark);

            /*   MAKE INTRO ANIMATION   */
            m_intro.AddAnimation(new DirXYMover(wdog, 180, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(wdog, 180, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(wdog, 10, 0, 1.7f));
            m_intro.AddAnimation(new TimeOutDrawable(sprdog, 49, true));
            m_intro.AddAnimation(new DirXYMover(jdog1, 5, -50, 3.5f));
            m_intro.AddAnimation(new DirXYMover(jdog1, 15, -25, 3.0f));
            m_intro.AddAnimation(new DirXYMover(jdog2, 15, -25, 3.0f));
            m_intro.AddAnimation(new DirXYMover(jdog3, 40, 40, 3.0f));
            m_intro.BuildScene(new int[10] {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            });
            m_intro.Scene_State = DrawableState.Active;

            /* Make a texture for bg. NOT gonna be needed when I change the dimension of screen */
            ScreenTexture = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            ScreenTexture.SetData(new Color[] { Color.White });

            /* Build the SHOT animations */
            flash = new Texture2D(ScreenManager.GraphicsDevice, 1, 1);
            flash.SetData(new Color[] { new Color(255, 255, 255, 128) });

            m_flash            = new TimeOutDrawable(new Image(HelperUtils.SafeBoundary.X, HelperUtils.SafeBoundary.Y, 1024, 612, flash), 3, false);
            m_flash.Draw_State = DrawableState.Finished;

            /* Create Players */
            m_player1 = new DuckHuntPlayer(0);
            m_player1.LoadContent(m_player_textures, m_num, m_score_fnt, boxrec);
            m_player2 = new DuckHuntPlayer(1);
            m_player2.LoadContent(m_player_textures, m_num, m_score_fnt, boxrec);

            newbound  = Boundary.CreateBoundRects(boxrec);
            bounddata = new CollisionData[newbound.Length];

            bounddata[0] = new CollisionData(newbound[0]);
            bounddata[1] = new CollisionData(newbound[1]);
            bounddata[2] = new CollisionData(newbound[2]);
            bounddata[3] = new CollisionData(newbound[3]);
            bounddata[4] = new CollisionData(newbound[4]);
            bounddata[5] = new CollisionData(newbound[5]);
            bounddata[6] = new CollisionData(newbound[6]);
            bounddata[7] = new CollisionData(newbound[7]);
            bounddata[8] = new CollisionData(newbound[8]);
            bounddata[9] = new CollisionData(newbound[9]);

            m_ducks = new DuckPopulation(content, bounddata);

            // FLY AWAY SIGN
            m_fly_sign.Texture = flyawaysign;
            m_fly_sign.X_Pos   = ScreenManager.GraphicsDevice.Viewport.Width / 2 - m_fly_sign.Texture.Width / 2;
            m_fly_sign.Y_Pos   = HelperUtils.SafeBoundary.Y + 256;

            // A real game would probably have more content than this sample, so
            // it would take longer to load. We simulate that by delaying for a
            // while, giving you a chance to admire the beautiful loading screen.
            Thread.Sleep(1000);

            // once the load has finished, we use ResetElapsedTime to tell the game's
            // timing mechanism that we have just finished a very long frame, and that
            // it should not try to catch up.
            ScreenManager.Game.ResetElapsedTime();
        }
Esempio n. 4
0
        private DuckHuntBall BuildDuck(CollisionData[] boundary)
        {
            DuckHuntBall duckball;
            AnimatedSprite dscduck = new AnimatedSprite();
            AnimatedSprite ascduck = new AnimatedSprite();

            int flapspeed = 4;

            dscduck.BuildAnimation(m_duck_txt, 1, 9, true, new int[20] { 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4 });
            dscduck.SetFrame(0, flapspeed, null);
            dscduck.SetFrame(1, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(2, flapspeed, null);
            dscduck.SetFrame(3, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(4, flapspeed, null);
            dscduck.SetFrame(5, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(6, flapspeed, null);
            dscduck.SetFrame(7, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(8, flapspeed, m_duckquack_snd);
            dscduck.SetFrame(9, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(10, flapspeed, null);
            dscduck.SetFrame(11, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(12, flapspeed, null);
            dscduck.SetFrame(13, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(14, flapspeed, null);
            dscduck.SetFrame(15, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(16, flapspeed, null);
            dscduck.SetFrame(17, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(18, flapspeed, null);
            dscduck.SetFrame(19, flapspeed, m_flapwing_snd);

            ascduck.BuildAnimation(m_duck_txt, 1, 9, true, new int[20] { 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1 });
            ascduck.SetFrame(0, flapspeed, null);
            ascduck.SetFrame(1, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(2, flapspeed, null);
            ascduck.SetFrame(3, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(4, flapspeed, null);
            ascduck.SetFrame(5, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(6, flapspeed, null);
            ascduck.SetFrame(7, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(8, flapspeed, m_duckquack_snd);
            ascduck.SetFrame(9, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(10, flapspeed, null);
            ascduck.SetFrame(11, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(12, flapspeed, null);
            ascduck.SetFrame(13, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(14, flapspeed, null);
            ascduck.SetFrame(15, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(16, flapspeed, null);
            ascduck.SetFrame(17, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(18, flapspeed, null);
            ascduck.SetFrame(19, flapspeed, m_flapwing_snd);

            duckball = new DuckHuntBall(HelperUtils.SafeBoundary.X + 512, HelperUtils.SafeBoundary.Y + 476, boundary);
            duckball.AddAnimation(dscduck);
            duckball.AddAnimation(ascduck);
            duckball.Ball_State = BallState.Limbo;

            return duckball;
        }
        public override void LoadContent()
        {
            if (m_content == null)
                m_content = new ContentManager(ScreenManager.Game.Services, "Content");

            m_duck_txt = m_content.Load<Texture2D>("DuckHunt\\Textures\\duck");
            m_menu_fnt = m_content.Load<SpriteFont>("Fonts\\bigfont");

            m_selector_snd = m_content.Load<SoundEffect>("DuckHunt\\Sounds\\select");

            m_resume = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESUME").X/2, 150, "RESUME", m_menu_fnt);
            m_restart = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("RESTART").X / 2, 155 + m_resume.Height, "RESTART", m_menu_fnt);
            m_quit = new MenuFontItem(ScreenManager.GraphicsDevice.Viewport.Width / 2 - (int)m_menu_fnt.MeasureString("QUIT").X / 2, 160 + 2*m_resume.Height, "QUIT",m_menu_fnt);

            m_selector = new AnimatedSprite();
            m_selector.BuildAnimation(m_duck_txt, 1, 9, true, new int[4] { 3, 4, 5, 4 });
            m_selector.SetFrame(0, 9, null);
            m_selector.SetFrame(1, 9, null);
            m_selector.SetFrame(2, 9, null);
            m_selector.SetFrame(3, 9, null);
            m_selector.X_Pos = m_resume.X_Pos - (int)(m_selector.Width*1.5);
            m_selector.Y_Pos = m_resume.Y_Pos + m_resume.Height / 2 - m_selector.Height / 2;

            // Hook up menu event handlers.
            m_resume.m_selected_events += OnCancel;
            m_restart.m_selected_events += RestartGameMenuEntrySelected;
            m_quit.m_selected_events += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(m_resume);
            MenuEntries.Add(m_restart);
            MenuEntries.Add(m_quit);

            m_selected = m_resume;
        }
Esempio n. 6
0
        private DuckHuntBall BuildDuck(CollisionData[] boundary)
        {
            DuckHuntBall   duckball;
            AnimatedSprite dscduck = new AnimatedSprite();
            AnimatedSprite ascduck = new AnimatedSprite();

            int flapspeed = 4;

            dscduck.BuildAnimation(m_duck_txt, 1, 9, true, new int[20] {
                3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4
            });
            dscduck.SetFrame(0, flapspeed, null);
            dscduck.SetFrame(1, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(2, flapspeed, null);
            dscduck.SetFrame(3, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(4, flapspeed, null);
            dscduck.SetFrame(5, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(6, flapspeed, null);
            dscduck.SetFrame(7, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(8, flapspeed, m_duckquack_snd);
            dscduck.SetFrame(9, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(10, flapspeed, null);
            dscduck.SetFrame(11, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(12, flapspeed, null);
            dscduck.SetFrame(13, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(14, flapspeed, null);
            dscduck.SetFrame(15, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(16, flapspeed, null);
            dscduck.SetFrame(17, flapspeed, m_flapwing_snd);
            dscduck.SetFrame(18, flapspeed, null);
            dscduck.SetFrame(19, flapspeed, m_flapwing_snd);

            ascduck.BuildAnimation(m_duck_txt, 1, 9, true, new int[20] {
                0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1, 0, 1, 2, 1
            });
            ascduck.SetFrame(0, flapspeed, null);
            ascduck.SetFrame(1, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(2, flapspeed, null);
            ascduck.SetFrame(3, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(4, flapspeed, null);
            ascduck.SetFrame(5, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(6, flapspeed, null);
            ascduck.SetFrame(7, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(8, flapspeed, m_duckquack_snd);
            ascduck.SetFrame(9, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(10, flapspeed, null);
            ascduck.SetFrame(11, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(12, flapspeed, null);
            ascduck.SetFrame(13, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(14, flapspeed, null);
            ascduck.SetFrame(15, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(16, flapspeed, null);
            ascduck.SetFrame(17, flapspeed, m_flapwing_snd);
            ascduck.SetFrame(18, flapspeed, null);
            ascduck.SetFrame(19, flapspeed, m_flapwing_snd);

            duckball = new DuckHuntBall(HelperUtils.SafeBoundary.X + 512, HelperUtils.SafeBoundary.Y + 476, boundary);
            duckball.AddAnimation(dscduck);
            duckball.AddAnimation(ascduck);
            duckball.Ball_State = BallState.Limbo;

            return(duckball);
        }