Esempio n. 1
0
 public Button(Vector2 position, string label)
     : base(position,Conf.BUTTON_WIDTH, Conf.BUTTON_HEIGHT)
 {
     state = ButtonState.DEFAULT;
     this.label = label;
     buttonTextures = new List<Texture2D>();
     HitBox = new Rectangle((int)position.X, (int)position.Y, this.width, this.height);
     SpriteBox = new Rectangle();
     SpriteBox.Width = this.width;
     SpriteBox.Height = this.height;
     Vector2 textPostion = new Vector2(position.X + 40, position.Y + 5);
     labelSprite = new SpriteText(textPostion, Color.White, label);
 }
Esempio n. 2
0
        //Définition des éléments nécessaire à la création graphique du menu
        public Menu(Pong game)
        {
            this.game = game;
            buttons = new List<Button>();
            leftChoices = new List<Button>();
            rightChoices = new List<Button>();
            menuSprites = new List<Sprite>();

            // Position des boutons en fonction de la taille de la fenêtre
            int leftButtonsPositionX = (Conf.WINDOW_WIDTH/2 - Conf.BUTTON_WIDTH)/2;
            int rightButtonsPositionX = (Conf.WINDOW_WIDTH / 2) + leftButtonsPositionX;

            Vector2 leftButtonsPosition = new Vector2(leftButtonsPositionX, 200);

            // Création des boutons et ajout dans les listes adaptées
            buttons.Add(new Button(leftButtonsPosition, "1 player", 1, Conf.InteligenceType.HUMAN));
            leftChoices.Add(buttons.Last());
            buttons.Add(new Button(new Vector2(leftButtonsPositionX, 300), "2 players", 2, Conf.InteligenceType.HUMAN));
            leftChoices.Add(buttons.Last());
            buttons.Add(new Button(new Vector2(leftButtonsPositionX, 400), "AI", 1, Conf.InteligenceType.IA));
            leftChoices.Add(buttons.Last());
            buttons.Add(new Button(new Vector2(rightButtonsPositionX, 200), "1 player", 1, Conf.InteligenceType.HUMAN));
            rightChoices.Add(buttons.Last());
            buttons.Add(new Button(new Vector2(rightButtonsPositionX, 300), "2 players", 2, Conf.InteligenceType.HUMAN));
            rightChoices.Add(buttons.Last());
            buttons.Add(new Button(new Vector2(rightButtonsPositionX, 400), "AI", 1, Conf.InteligenceType.IA));
            rightChoices.Add(buttons.Last());

            buttons.Add(new Button(new Vector2(375, 500), "GO !"));

            // Ajout des boutons dans la liste des sprites à dessier
            foreach (Button button in buttons)
            {
                menuSprites.Add(button);
                menuSprites.Add(button.labelSprite);
            }

            title = new SpriteTexture2D(new Vector2(350, 20), 300, 75);
            SpriteText leftTeamLabel = new SpriteText(new Vector2(145, 110), Color.White, "Left Side");
            SpriteText rightTeamLabel = new SpriteText(new Vector2(640, 110), Color.White, "Right Side");
            menuSprites.Add(title);
            menuSprites.Add(leftTeamLabel);
            menuSprites.Add(rightTeamLabel);
        }