Exemple #1
0
        public MenuScene(Scene.Context context, SceneManager scnManager) 
            : base (context, scnManager)
        {
            _logger.Log(LogLevel.Info, " >>> Configurando escena del Menú");

            _optionIndex = (int)MenuOptions.PLAY; ;
            _options = new List<SFML.Graphics.Text>();

            // opcion jugar
            SFML.Graphics.Text textPlay = new SFML.Graphics.Text();
            textPlay.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"];
            textPlay.DisplayedString = "Jugar";
            textPlay.Position = new SFML.System.Vector2f((context.Window.Size.X - textPlay.GetLocalBounds().Width) * 0.5f,
                (context.Window.Size.Y - 2 * textPlay.CharacterSize - OPTION_SEPARATION) *0.5f);
            _options.Add(textPlay);

            // opción salir
            SFML.Graphics.Text textExit = new SFML.Graphics.Text();
            textExit.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"];
            textExit.DisplayedString = "Salir";
            textExit.Position = new SFML.System.Vector2f((context.Window.Size.X - textExit.GetLocalBounds().Width) * 0.5f,
                textPlay.Position.Y + textPlay.CharacterSize + OPTION_SEPARATION);
            _options.Add(textExit);

            UpdateOptionText();
        }
Exemple #2
0
        // Constructor
        public GameScene(Scene.Context context, SceneManager scnManager) 
            : base (context, scnManager)
        {
            _logger.Log(LogLevel.Info, " >>> Configurando escena juego.");

            _player = new Player();

            _world = new World(context);

        }
Exemple #3
0
        public PauseScene(Scene.Context context, SceneManager scnManager) 
            : base (context, scnManager)
        {
            _logger.Log(LogLevel.Info, " >>> Configurando escena de Pausa");

            _mainText = new SFML.Graphics.Text();
            _infoText = new SFML.Graphics.Text();

            // opcion jugar
            _mainText.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"];
            _mainText.DisplayedString = "Pausa";
            _mainText.Position = new SFML.System.Vector2f((context.Window.Size.X - _mainText.GetLocalBounds().Width) * 0.5f,
                (context.Window.Size.Y - 2 * _mainText.CharacterSize - OPTION_SEPARATION) * 0.5f);

            // opción salir
            _infoText.Font = (SFML.Graphics.Font)context.ResourcesManager["Fuentes:Titulo"];
            _infoText.DisplayedString = "Pulsa espacio para ir al menú principal";
            _infoText.CharacterSize = (UInt32)(_infoText.CharacterSize * 0.8f);
            _infoText.Position = new SFML.System.Vector2f((context.Window.Size.X - _infoText.GetLocalBounds().Width) * 0.5f,
                _mainText.Position.Y + _mainText.CharacterSize + OPTION_SEPARATION);

        }
        ////////////////////////
        // Métodos
        ////////////////////////

        public void Init() 
        {
            _logger.Log(LogLevel.Info, " > Configurando aplicación.");

            // buffer 32 bits de colors
            ContextSettings contextSettings = new ContextSettings();
            contextSettings.DepthBits = 32;

            // Creamos la ventana principal
            _logger.Log(LogLevel.Info, " >> Creando ventana principal.");
            // ventana no redimensionable
            _window = new RenderWindow(new VideoMode(800, 600), "Galaga ", Styles.Close, contextSettings);

            // gestor de escenas
            _logger.Log(LogLevel.Info, " >> Creando gestor de escenas.");
            _scnManager = new SceneManager();

            // Se crea el gestor de recursos y se leen los elementos
            _logger.Log(LogLevel.Info, " >> Creando gestor de recursos.");
            _resManager = new ResourcesManager(
                this.GetType().Assembly.GetManifestResourceStream("Galaga.main.resxml"));
            _resManager.RegisterLoadFunction("texture", SFMLResourcesManager.LoadTexture);
            _resManager.RegisterLoadFunction("font", SFMLResourcesManager.LoadFont);

            // creación del contexto
            _context = new Scene.Context(_window, _resManager);

            _timePerFrame = SFML.System.Time.FromSeconds(1f / 40f);           // como mínimo 40 frames por segundo
            _isPaused = false;

            RegisterDelegates();
            RegisterScenes();

            // pongo la primera escena en la pila
            _logger.Log(LogLevel.Info, " >> Push escena principal.");
            _scnManager.Push((int)SceneID.TITLE);
        
        }