예제 #1
0
        /// <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()
        {
            Input.Initialize();
            collisionResolver = new CollisionResolver();

            base.Initialize();
        }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            audioPlayer = new AudioPlayer();

            background = new Background(Content.Load <Texture2D>("BGTile.png"), new Vector2(worldBounds.Width, worldBounds.Height), new Vector2(0, 0));

            Texture2D playerNormalSprite = Content.Load <Texture2D>("PLAYER.png");
            Texture2D playerUpSprite     = Content.Load <Texture2D>("PLAYER_UP.png");
            Texture2D playerDownSprite   = Content.Load <Texture2D>("PLAYER_DOWN.png");

            spBoostSprite = Content.Load <Texture2D>("SPEEDBOOSTS.png");
            wallSprite    = Content.Load <Texture2D>("WALL2.png");
            columnSprite  = Content.Load <Texture2D>("LASER.png");
            fontTexture   = Content.Load <Texture2D>("Font.png");
            font          = Content.Load <SpriteFont>("HellaFont");

            worldLowerBound = 650;
            worldUpperBound = 50;

            columnSeperation         = 500;
            firstColumnStartPosition = 1000;

            player = new Player(playerNormalSprite, playerUpSprite, playerDownSprite, new Vector2(0, 360), new Vector2(1, 0.4f), new Vector2(10, 10), columnSeperation, 3);

            level = new Level(wallSprite, columnSprite);
            level.GenerateWorldBounds(worldLowerBound, worldUpperBound, 80);//generate the worlds lower and upper walls which the pipes are attached to
            level.GenerateColumns(columnSeperation, player.Dimensions, 3, firstColumnStartPosition);

            playerScore   = new UI(font, new Vector2(30, 60), 0, "Score: ", true);
            playerHiScore = new UI(font, new Vector2(600, 60), 0, "Hi Score: ", true);

            collisionResolver = new CollisionResolver();

            collisionResolver.Add(player);
            foreach (Wall wall in level.UpperWalls)
            {
                collisionResolver.Add(wall);
            }
            foreach (Wall wall in level.LowerWalls)
            {
                collisionResolver.Add(wall);
            }
            foreach (Column column in level.Columns)
            {
                List <Wall> columnComponents = column.ColumnComponents;
                foreach (Wall wall in columnComponents)
                {
                    collisionResolver.Add(wall);
                }
            }
        }
예제 #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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            audioPlayer = new AudioPlayer();

            background = new Background(Content.Load<Texture2D>("BGTile.png"), new Vector2(worldBounds.Width, worldBounds.Height),new Vector2(0,0));

            Texture2D playerNormalSprite = Content.Load<Texture2D>("PLAYER.png");
            Texture2D playerUpSprite = Content.Load<Texture2D>("PLAYER_UP.png");
            Texture2D playerDownSprite = Content.Load<Texture2D>("PLAYER_DOWN.png");

            spBoostSprite = Content.Load<Texture2D>("SPEEDBOOSTS.png");
            wallSprite = Content.Load<Texture2D>("WALL2.png");
            columnSprite = Content.Load<Texture2D>("LASER.png");
            fontTexture = Content.Load<Texture2D>("Font.png");
            font = Content.Load<SpriteFont>("HellaFont");

            worldLowerBound = 650;
            worldUpperBound = 50;

            columnSeperation = 500;
            firstColumnStartPosition = 1000;

            player = new Player(playerNormalSprite,playerUpSprite,playerDownSprite, new Vector2(0, 360), new Vector2(1, 0.4f), new Vector2(10, 10), columnSeperation, 3);

            level = new Level(wallSprite,columnSprite);
            level.GenerateWorldBounds(worldLowerBound, worldUpperBound, 80);//generate the worlds lower and upper walls which the pipes are attached to
            level.GenerateColumns(columnSeperation, player.Dimensions, 3, firstColumnStartPosition);

            playerScore = new UI(font, new Vector2(30, 60), 0, "Score: ", true);
            playerHiScore = new UI(font, new Vector2(600, 60), 0, "Hi Score: ", true);

            collisionResolver = new CollisionResolver();

            collisionResolver.Add(player);
            foreach (Wall wall in level.UpperWalls) { collisionResolver.Add(wall); }
            foreach (Wall wall in level.LowerWalls) { collisionResolver.Add(wall); }
            foreach (Column column in level.Columns)
            {
                List<Wall> columnComponents = column.ColumnComponents;
                foreach (Wall wall in columnComponents) { collisionResolver.Add(wall); }
            }
        }
예제 #4
0
        /// <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()
        {
            Input.Initialize();
            collisionResolver = new CollisionResolver();

            base.Initialize();
        }