예제 #1
0
        public static void LoadContent(ContentManager content, GameWindow window)
        {
            menu = new Menu((int)State.Menu);
            menu.AddItem(content.Load <Texture2D>("start"), (int)State.Run);
            menu.AddItem(content.Load <Texture2D>("highscore"), (int)State.HighScore);
            menu.AddItem(content.Load <Texture2D>("quit"), (int)State.Quit);
            // Background
            background = new Background(content.Load <Texture2D>("background"), window);

            // Player
            player = new Player(content.Load <Texture2D>("frogg"), 380, 420, 3f, 4.5f);

            // Collectable point and printed score
            flySprite = content.Load <Texture2D>("ladybugg");
            printText = new PrintText(content.Load <SpriteFont>("myFont"));

            // Enemies
            enemies = new List <Enemy>();
            Random    random    = new Random();
            Texture2D tmpSprite = content.Load <Texture2D>("carL");

            for (int i = 0; i < 1; i++)
            {
                int  rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int  rndY = random.Next(0, window.ClientBounds.Height / 2);
                carL temp = new carL(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carL");
            for (int i = 0; i < 1; i++)
            {
                int   rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int   rndY = random.Next(0, window.ClientBounds.Height / 2);
                carL2 temp = new carL2(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carR");
            for (int i = 0; i < 1; i++)
            {
                int  rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int  rndY = random.Next(0, window.ClientBounds.Height / 2);
                carR temp = new carR(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carR");
            for (int i = 0; i < 1; i++)
            {
                int   rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int   rndY = random.Next(0, window.ClientBounds.Height / 2);
                carR2 temp = new carR2(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            SpriteFont tmpFont = content.Load <SpriteFont>("myFont");

            printText = new PrintText(tmpFont);
            highScore = new HighScore(5, tmpFont);
            highScore.LoadFromFile("hs.txt");
        }
예제 #2
0
        private static void Reset(GameWindow window, ContentManager content)
        {
            player.Reset(380, 420, 3f, 4.5f);

            enemies.Clear();
            Random    random    = new Random();
            Texture2D tmpSprite = content.Load <Texture2D>("carL");

            for (int i = 0; i < 1; i++)
            {
                int  rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int  rndY = random.Next(0, window.ClientBounds.Height / 2);
                carL temp = new carL(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carL");
            for (int i = 0; i < 1; i++)
            {
                int   rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int   rndY = random.Next(0, window.ClientBounds.Height / 2);
                carL2 temp = new carL2(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carR");
            for (int i = 0; i < 1; i++)
            {
                int  rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int  rndY = random.Next(0, window.ClientBounds.Height / 2);
                carR temp = new carR(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            tmpSprite = content.Load <Texture2D>("carR");
            for (int i = 0; i < 1; i++)
            {
                int   rndX = random.Next(0, window.ClientBounds.Width - tmpSprite.Width);
                int   rndY = random.Next(0, window.ClientBounds.Height / 2);
                carR2 temp = new carR2(tmpSprite, rndX, rndY);
                enemies.Add(temp);
            }
            fly.Clear();
            flySprite = content.Load <Texture2D>("ladybugg");
            printText = new PrintText(content.Load <SpriteFont>("myFont"));
        }