Exemplo n.º 1
0
        /// <summary>
        /// Initializes the game internally.
        /// </summary>
        void InternalInitialize()
        {
            // Initialize graphics mode to default
            graphicsMode = GraphicsMode.Default;

            // Start with default window flags
            var flags = GameWindowFlags.Default;

            // Set Fullscreen flag if requested
            if (Configuration.Fullscreen && !flags.HasFlag(GameWindowFlags.Fullscreen))
            {
                flags |= GameWindowFlags.Fullscreen;
            }

            // Set FixedWindow flag if requested
            if (Configuration.FixedWindow && !flags.HasFlag(GameWindowFlags.FixedWindow))
            {
                flags |= GameWindowFlags.FixedWindow;
            }

            // Create window
            this.Log("Creating native window");
            window = new NativeWindow(
                width: Configuration.Width,
                height: Configuration.Height,
                title: Configuration.WindowTitle,
                options: flags,
                mode: GraphicsMode.Default,
                device: DisplayDevice.Default
                );

            // Update the resolution
            UpdateResolution();

            // Register events
            window.KeyDown  += Keyboard.RegisterKeyDown;
            window.KeyUp    += Keyboard.RegisterKeyUp;
            window.KeyPress += delegate { };

            // Initialize startTime and lastTime
            startTime = DateTime.UtcNow;
            lastTime  = startTime;

            // Initialize the mouse buffer
            Mouse = new MouseBuffer(window, this);

            // Start the sound manager
            SoundManager = new SoundManager();

            // Initialize the context manager
            Content             = new ContentManager(AppDomain.CurrentDomain.BaseDirectory);
            Content.ContentRoot = this.Configuration.ContentRoot;
            ContentManager      = Content;
            RegisterProviders();

            Instance = this;
        }
Exemplo n.º 2
0
 public void Action(GameTime time, KeyboardBuffer keyboard, MouseBuffer mouse)
 {
     if (keyboard.IsKeyDown (Key.W))
         Position.Y -= 1;
     if (keyboard.IsKeyDown (Key.S))
         Position.Y += 1;
     if (keyboard.IsKeyDown (Key.A))
         Position.X -= 1;
     if (keyboard.IsKeyDown (Key.D))
         Position.X += 1;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="nginz.FPSCamera"/> class.
        /// </summary>
        /// <param name="fieldOfView">Field of view.</param>
        /// <param name="resolution">Resolution.</param>
        /// <param name="mouse">Mouse.</param>
        /// <param name="keyboard">Keyboard.</param>
        public FPSCamera(float fieldOfView, Resolution resolution, MouseBuffer mouse, KeyboardBuffer keyboard)
        {
            // Create the base camera
            Camera = new Camera(fieldOfView, resolution, 0.01f, 256f);

            // Set the mouse and the keyboard
            Mouse    = mouse;
            Keyboard = keyboard;

            // Initialize the mouse sensitivity
            MouseXSensitivity = .1f;
            MouseYSensitivity = .1f;

            // Initialize the actor speed
            Speed = 5f;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="nginz.FPSCamera"/> class.
        /// </summary>
        /// <param name="fieldOfView">Field of view.</param>
        /// <param name="resolution">Resolution.</param>
        /// <param name="mouse">Mouse.</param>
        /// <param name="keyboard">Keyboard.</param>
        public FPSCamera(float fieldOfView, Resolution resolution, MouseBuffer mouse, KeyboardBuffer keyboard)
        {
            // Create the base camera
            Camera = new Camera (fieldOfView, resolution, 0.01f, 256f);

            // Set the mouse and the keyboard
            Mouse = mouse;
            Keyboard = keyboard;

            // Initialize the mouse sensitivity
            MouseXSensitivity = .1f;
            MouseYSensitivity = .1f;

            // Initialize the actor speed
            Speed = 5f;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes the game internally.
        /// </summary>
        void InternalInitialize()
        {
            // Initialize graphics mode to default
            graphicsMode = GraphicsMode.Default;

            // Start with default window flags
            var flags = GameWindowFlags.Default;

            // Set Fullscreen flag if requested
            if (Configuration.Fullscreen && !flags.HasFlag (GameWindowFlags.Fullscreen))
                flags |= GameWindowFlags.Fullscreen;

            // Set FixedWindow flag if requested
            if (Configuration.FixedWindow && !flags.HasFlag (GameWindowFlags.FixedWindow))
                flags |= GameWindowFlags.FixedWindow;

            // Create window
            this.Log ("Creating native window");
            window = new NativeWindow (
                width: Configuration.Width,
                height: Configuration.Height,
                title: Configuration.WindowTitle,
                options: flags,
                mode: GraphicsMode.Default,
                device: DisplayDevice.Default
            );

            // Update the resolution
            UpdateResolution ();

            // Register events
            window.KeyDown += Keyboard.RegisterKeyDown;
            window.KeyUp += Keyboard.RegisterKeyUp;
            window.KeyPress += delegate { };

            // Initialize startTime and lastTime
            startTime = DateTime.UtcNow;
            lastTime = startTime;

            // Initialize the mouse buffer
            Mouse = new MouseBuffer (window, this);

            // Start the sound manager
            SoundManager = new SoundManager();

            // Initialize the context manager
            Content = new ContentManager (AppDomain.CurrentDomain.BaseDirectory);
            Content.ContentRoot = this.Configuration.ContentRoot;
            ContentManager = Content;
            RegisterProviders ();

            Instance = this;
        }