Exemplo n.º 1
0
        public World(SpriteBatch spriteBatch, Chars player, Backgrounds background, Backgrounds background_sky, Platforms ground, List<Obstacles> obstacles)
        {
            this.spriteBatch = spriteBatch;

            this.player = player;
            this.background = background;
            this.background_sky = background_sky;
            this.ground = ground;
            this.obstacles = obstacles;
        }
Exemplo n.º 2
0
        /*
        // int rnd = random.Next(0, obstacles.Count);
        public void pop(List<Obstacles> obstacles, int rnd) // Fait apparaitre des obstacles randomly à l'écran
        {
            if(allTrue(obstacles, 1)) // Si tout est launché
            {
                for (int i = 0; i < obstacles.Count; i++)
                    obstacles[i].launched = false;
            }
            while (obstacles[rnd].launched == false)
            {

            }
        }

        public bool allTrue(List<Obstacles> obstacles, int i) // Fonction qui indique si tous les obstacles sont activés
        {
            if (i < obstacles.Count )
            {
                if (obstacles[i].launched)
                    allTrue(obstacles, i + 1);

                else
                    return false;
            }
            return true;
        }*/
        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("SpriteFont1");
            mouse = new Mouse_Skin();

            screenWidth = GraphicsDevice.Viewport.Width;
            screenHeight = GraphicsDevice.Viewport.Height;

            // Etats
            gameState = State.Menu;
            languageState = Languages.French;
            languageLibray = new LanguageLibrary(languageState);
            languageLibray.Initialize();

            // Menu Principal
            menu_Background = new Menu_Background(0, 0, screenWidth, screenHeight);
            button_newGame = new Buttons_Access(screenWidth / 2 - 167 / 2, 200, 167, 62, State.NewGame, languageLibray.text_newGame);
            button_Quit = new Buttons_Access(screenWidth / 2 - 167 / 2, 400, 167, 62, State.QuitGame, languageLibray.text_Quit);
            button_french = new Button_Language(10, 0, 42, 24, Languages.French);
            button_english = new Button_Language(10 + 42 + 10, 0, 42, 24, Languages.English);
            buttons = new List<Buttons> { button_newGame, button_Quit, button_french, button_english };
            menu = new Menu(spriteBatch, font, languageLibray, menu_Background, buttons);
            menu.Initialize();

            // World
            background = new Backgrounds(0, 0, screenWidth, screenHeight, 5);
            background_sky = new Backgrounds(0, 0, screenWidth, 197, 3);
            ground = new Platforms(0, screenHeight - 10, screenWidth, 10, 0);
            fish = new Chars(50, ground.y - 97, 97, 75);
            platform = new Platforms(screenWidth + 15, 400, 350, 10, 12);
            box = new Boxes(screenWidth, ground.y - 124 / 4, 88 / 2, 124 / 2, 4);
            obstacles = new List<Obstacles> { platform, box };
            world = new World(spriteBatch, fish, background, background_sky, ground, obstacles);
            world.Initialize();

            // Lost Game
            lost_Background = new Menu_Background(0, 0, screenWidth, screenHeight);
            lost_button_newGame = new Buttons_Access(screenWidth / 2 - 167 / 2, 200, 167, 62, State.NewGame, languageLibray.text_newGame);
            lost_button_Menu = new Buttons_Access(screenWidth / 2 - 167 / 2, 300, 167, 62, State.Menu, languageLibray.text_Menu);
            lost_button_Quit = new Buttons_Access(screenWidth / 2 - 167 / 2, 400, 167, 62, State.QuitGame, languageLibray.text_Quit);
            lost_buttons = new List<Buttons> { lost_button_newGame, lost_button_Menu, lost_button_Quit };
            lost = new Menu(spriteBatch, font, languageLibray, lost_Background, lost_buttons);
            lost.Initialize();

            base.Initialize();
        }