Exemple #1
0
        private bool CheckDrumTiming(Drum drum, GameTime gameTime)
        {
            hit = false;
            if (drum.drumSide != previousDrumSide)
            {
                if (gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[0] + currentTolerance ||
                    gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[3] - currentTolerance ||
                    (gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[1] - currentTolerance &&
                     gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[1] + currentTolerance) ||
                    (gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[2] - currentTolerance &&
                     gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[2] + currentTolerance))
                {
                    hit = true;
                }
            }

            return(hit);
        }
Exemple #2
0
        private bool CheckDrumTiming(Drum drum, GameTime gameTime)
        {
            hit = false;
            if (drum.drumSide != previousDrumSide)
            {
                if (gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[0] + currentTolerance ||
                    gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[3] - currentTolerance ||
                    (gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[1] - currentTolerance &&
                    gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[1] + currentTolerance) ||
                    (gameTime.TotalGameTime.TotalMilliseconds >= clickTimes[2] - currentTolerance &&
                    gameTime.TotalGameTime.TotalMilliseconds <= clickTimes[2] + currentTolerance))
                {
                    hit = true;
                }
            }

            return hit;
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            font = Content.Load<SpriteFont>("Fonts/font");
            scaleToReference = (float)GraphicsDevice.Viewport.Width / 800f;
            halfScreen = Content.Load<Texture2D>("Graphics/halfscreen");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            player = new Player();
            player.Initialize(this, Content.Load<Texture2D>("Graphics/caveman"),
                Vector2.Zero, 100, false, Renderer.AnchorPoint.BottomMiddle);
            player.collider.SetSize(player.renderer.Texture.Width / 5, (int)(player.renderer.Texture.Height * 0.8f));
            player.renderer.AddAnimation("running", player.renderer.Texture, 75, 75, 4, startingRunningSpeed * 2, Color.White,
                player.transform.Scale.X, true, true, true);
            player.transform.Position = new Vector2(graphics.GraphicsDevice.Viewport.Width/4 * scaleToReference, 200 * scaleToReference);
            player.renderer.SetAnchorPoint(Renderer.AnchorPoint.BottomMiddle);

            dino = new GameObject();
            dino.Initialize(this, Content.Load<Texture2D>("Graphics/trex"),
                Vector2.UnitX, 1000, false, Renderer.AnchorPoint.BottomMiddle);
            dino.collider.SetSize(dino.renderer.Texture.Width / 4, dino.renderer.Texture.Height);
            dino.renderer.AddAnimation("running", dino.renderer.Texture, 436, 300, 4, startingRunningSpeed * 2, Color.White,
                dino.transform.Scale.X, true, true, true);
            dino.transform.Position = new Vector2(-dino.collider.Bounds.Width / 2, Platform.bottom * GraphicsDevice.Viewport.Height);
            dino.renderer.SetAnchorPoint(Renderer.AnchorPoint.BottomMiddle);

            leftDrum = new Drum();
            leftDrum.Initialize(this, halfScreen, Vector2.Zero, 100, true, Renderer.AnchorPoint.TopLeft);
            leftDrum.transform.Scale = Vector2.One * 2;
            leftDrum.collider.SetSize(leftDrum.renderer.Texture.Width, leftDrum.renderer.Texture.Height);
            leftDrum.drumSide = DrumSide.side.LEFT;
            leftDrum.transform.Position = Vector2.Zero;

            rightDrum = new Drum();
            rightDrum.Initialize(this, halfScreen, Vector2.Zero, 100, true, Renderer.AnchorPoint.TopLeft);
            rightDrum.transform.Scale = Vector2.One * 2;
            rightDrum.collider.SetSize(rightDrum.renderer.Texture.Width * 2, rightDrum.renderer.Texture.Height * 2);
            rightDrum.drumSide = DrumSide.side.RIGHT;
            rightDrum.transform.Position = new Vector2(GraphicsDevice.Viewport.Width / 2, 0f);

            // init pools for platorms, "club" collectibles and obstacles
            platformPool.InitializeObjects(this, Content.Load<Texture2D>("Graphics/grass_fourth"), new Vector2(-1, 0), 1, true, Renderer.AnchorPoint.TopLeft);

            for (int i = 0; i < 10; i++)
            {
                platformPool.ActivateNewObject().transform.Position = new Vector2(platformPool.Objects[0].collider.Bounds.Width * i, GraphicsDevice.Viewport.Height
                    * Platform.bottom);

            }

            healthCollectiblePool.InitializeObjects(this, Content.Load<Texture2D>("Graphics/scoreCollectible"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle);
            obstaclePool.InitializeObjects(this, Content.Load<Texture2D>("Graphics/obstacle"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle, 0.8f);
            //clubEffectPool.InitializeObjects(this, Content.Load<Texture2D>("Graphics/clubEffect"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle);

            // background texture and parallaxers
            background = Content.Load<Texture2D>("Graphics/background");
            treesBack.Initialize(Content, "Graphics/trees_dark", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 10);
            treesFront.Initialize(Content, "Graphics/trees_light", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 20);

            // sound effects
            click = Content.Load<SoundEffect>("Sounds/click");
            bongo1 = Content.Load<SoundEffect>("Sounds/bongo1");
            bongo2 = Content.Load<SoundEffect>("Sounds/bongo2");
        }
Exemple #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            font             = Content.Load <SpriteFont>("Fonts/font");
            scaleToReference = (float)GraphicsDevice.Viewport.Width / 800f;
            halfScreen       = Content.Load <Texture2D>("Graphics/halfscreen");

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            player = new Player();
            player.Initialize(this, Content.Load <Texture2D>("Graphics/caveman"),
                              Vector2.Zero, 100, false, Renderer.AnchorPoint.BottomMiddle);
            player.collider.SetSize(player.renderer.Texture.Width / 5, (int)(player.renderer.Texture.Height * 0.8f));
            player.renderer.AddAnimation("running", player.renderer.Texture, 75, 75, 4, startingRunningSpeed * 2, Color.White,
                                         player.transform.Scale.X, true, true, true);
            player.transform.Position = new Vector2(graphics.GraphicsDevice.Viewport.Width / 4 * scaleToReference, 200 * scaleToReference);
            player.renderer.SetAnchorPoint(Renderer.AnchorPoint.BottomMiddle);

            dino = new GameObject();
            dino.Initialize(this, Content.Load <Texture2D>("Graphics/trex"),
                            Vector2.UnitX, 1000, false, Renderer.AnchorPoint.BottomMiddle);
            dino.collider.SetSize(dino.renderer.Texture.Width / 4, dino.renderer.Texture.Height);
            dino.renderer.AddAnimation("running", dino.renderer.Texture, 436, 300, 4, startingRunningSpeed * 2, Color.White,
                                       dino.transform.Scale.X, true, true, true);
            dino.transform.Position = new Vector2(-dino.collider.Bounds.Width / 2, Platform.bottom * GraphicsDevice.Viewport.Height);
            dino.renderer.SetAnchorPoint(Renderer.AnchorPoint.BottomMiddle);

            leftDrum = new Drum();
            leftDrum.Initialize(this, halfScreen, Vector2.Zero, 100, true, Renderer.AnchorPoint.TopLeft);
            leftDrum.transform.Scale = Vector2.One * 2;
            leftDrum.collider.SetSize(leftDrum.renderer.Texture.Width, leftDrum.renderer.Texture.Height);
            leftDrum.drumSide           = DrumSide.side.LEFT;
            leftDrum.transform.Position = Vector2.Zero;

            rightDrum = new Drum();
            rightDrum.Initialize(this, halfScreen, Vector2.Zero, 100, true, Renderer.AnchorPoint.TopLeft);
            rightDrum.transform.Scale = Vector2.One * 2;
            rightDrum.collider.SetSize(rightDrum.renderer.Texture.Width * 2, rightDrum.renderer.Texture.Height * 2);
            rightDrum.drumSide           = DrumSide.side.RIGHT;
            rightDrum.transform.Position = new Vector2(GraphicsDevice.Viewport.Width / 2, 0f);

            // init pools for platorms, "club" collectibles and obstacles
            platformPool.InitializeObjects(this, Content.Load <Texture2D>("Graphics/grass_fourth"), new Vector2(-1, 0), 1, true, Renderer.AnchorPoint.TopLeft);

            for (int i = 0; i < 10; i++)
            {
                platformPool.ActivateNewObject().transform.Position = new Vector2(platformPool.Objects[0].collider.Bounds.Width * i, GraphicsDevice.Viewport.Height
                                                                                  * Platform.bottom);
            }

            healthCollectiblePool.InitializeObjects(this, Content.Load <Texture2D>("Graphics/scoreCollectible"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle);
            obstaclePool.InitializeObjects(this, Content.Load <Texture2D>("Graphics/obstacle"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle, 0.8f);
            //clubEffectPool.InitializeObjects(this, Content.Load<Texture2D>("Graphics/clubEffect"), Vector2.Zero, 1, true, Renderer.AnchorPoint.BottomMiddle);

            // background texture and parallaxers
            background = Content.Load <Texture2D>("Graphics/background");
            treesBack.Initialize(Content, "Graphics/trees_dark", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 10);
            treesFront.Initialize(Content, "Graphics/trees_light", GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 20);

            // sound effects
            click  = Content.Load <SoundEffect>("Sounds/click");
            bongo1 = Content.Load <SoundEffect>("Sounds/bongo1");
            bongo2 = Content.Load <SoundEffect>("Sounds/bongo2");
        }