Example #1
0
 public Control(Game game)
 {
     Game = game;
     Window = game.Services.GetService<MasterWindow>();
     Keyboard = Window.Keyboard;
     Mouse = Window.Mouse;
 }
Example #2
0
 public MouseHelper(LogicGraph game)
     : base(game)
 {
     MouseManager = new MouseManager(game);
     CurrentHelper = this;
     this.UpdateOrder = -1;
 }
        /// <summary>
        /// Initialise the input system. Note that accelerometer input defaults to off.
        /// </summary>
        /// <param name="game"></param>
        public InputManager(Project2Game game) : base(game)
        {

            // initialisation
            useMouseDelta = false;
            accelerometerEnabled = false;
            mouseDelta = new Vector2();

            keyboardManager = new KeyboardManager(game);
            mouseManager = new MouseManager(game);
            pointerManager = new PointerManager(game);
            keyMapping = new KeyMapping();

            // get the accelerometer. Returns null if no accelerometer found
            accelerometer = Accelerometer.GetDefault();
            window = Window.Current.CoreWindow;

            // Set up the gesture recognizer.  In this game, it only responds to TranslateX, TranslateY and Tap events
            gestureRecognizer = new Windows.UI.Input.GestureRecognizer();
            gestureRecognizer.GestureSettings = GestureSettings.ManipulationTranslateX | 
                GestureSettings.ManipulationTranslateY | GestureSettings.Tap;
            
            // Register event handlers for pointer events
            window.PointerPressed += OnPointerPressed;
            window.PointerMoved += OnPointerMoved;
            window.PointerReleased += OnPointerReleased;
            
            // automatically enable accelerometer if we have one
            this.AccelerometerEnabled(true);
            this.MouseDeltaEnabled(true);
            
        }
Example #4
0
        public MyGame()
        {
            _graphicsDeviceManager = new GraphicsDeviceManager(this);

            _keyboardManager = new KeyboardManager(this);
            _mouseManager = new MouseManager(this);
        }
Example #5
0
        public Main()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            audioManager = new AudioManager(this);
            mouseManager = new MouseManager(this);
            keyboardManager = new KeyboardManager(this);
            IsMouseVisible = true;
            graphics.PreferredBackBufferHeight = 600;
            graphics.PreferredBackBufferWidth = 800;
            WindowCreated += WindowShown;
            GameStateChanged += NewGameState;

            content = Content;
            try
            {
                XmlDocument read = new XmlDocument();
                read.Load("Settings.xml");
                try
                {
                    muted = bool.Parse(read.SelectSingleNode("/Settings/Muted").InnerText);
                    vol = (muted) ? 0 : .025f;
                }
                catch
                {
                    Console.WriteLine("Muted value is invalid; setting to false.");
                    read.SelectSingleNode("/Settings/Muted").InnerText = "false";
                    vol = .25f;
                }
                try
                {
                    fullscreen = bool.Parse(read.SelectSingleNode("/Settings/Fullscreen").InnerText);
                    graphics.IsFullScreen = fullscreen;
                }
                catch
                {
                    Console.WriteLine("Fullscreen value is invalid; setting to false.");
                    read.SelectSingleNode("/Settings/Fullscreen").InnerText = "false";
                    graphics.IsFullScreen = false;
                }
                read.Save("Settings.xml");
            }
            catch
            {
                Console.WriteLine("Could not load settings file; most likely the file doesn't exist.");
                Console.WriteLine("Generating settings file and setting all options to default.");
                XmlDocument settings = new XmlDocument();
                XmlNode rootNode = settings.CreateElement("Settings");
                settings.AppendChild(rootNode);
                XmlNode userNode = settings.CreateElement("Muted");
                userNode.InnerText = "false";
                rootNode.AppendChild(userNode);
                userNode = settings.CreateElement("Fullscreen");
                userNode.InnerText = "false";
                rootNode.AppendChild(userNode);
                settings.Save("Settings.xml");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Project1Game" /> class.
        /// </summary>
        public Project1Game()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";
            keyboardManager = new KeyboardManager(this);
            mouseManager = new MouseManager(this);
        }
Example #7
0
        public InputManager(GameApp game)
        {
            _Mouse = new MouseManager(game);
            _MouseState = new MouseState();

            mouseX = 0;
            mouseY = 0;

            game.SetInputUpdater(Update);
            MouseClickEvent += game.onMouseClick;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OcclusionQueryGame" /> class.
        /// </summary>
        public OcclusionQueryGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";

            // Initialize input mouse system
            mouse = new MouseManager(this);
        }
Example #9
0
 public Camera(
     Vector2 clientSize,
     KeyboardManager keyboardManager,
     MouseManager mouseManager,
     PointerManager pointerManager,
     Vector3 position,
     Vector3 target,
     float nearPlane = 1,
     float farPlane = 20000)
     : this(clientSize, position, target, nearPlane, farPlane)
 {
     KeyboardManager = keyboardManager;
     MouseManager = mouseManager;
     PointerManager = pointerManager;
 }
Example #10
0
        public Camera(Project2Game game, MainPage main)
        {
            distance = new Vector3(0, 0, -15);
            position = new Vector3(0, 0, 0);
            View = Matrix.LookAtLH(distance, Vector3.Zero, Vector3.UnitY);
            Projection = Matrix.PerspectiveFovLH((float)Math.PI / 4.0f,
                (float)game.GraphicsDevice.BackBuffer.Width / game.GraphicsDevice.BackBuffer.Height, 0.1f, 500.0f);

            AngleH = 0;
            AngleV = -0.7f;
            this.main = main;
            this.game = game;

            mouseManager = new MouseManager(game);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Project1Game" /> class.
 /// </summary>
 public Project1Game()
 {
     // Creates a graphics manager. This is mandatory.
     graphicsDeviceManager = new GraphicsDeviceManager(this);
     keyboardManager = new KeyboardManager(this);
     mouseManager = new MouseManager(this);
     worldSize = 257;
     pitch = -0.3f;
     yaw = 0.8f;
     roll = 0f;
     mouseVelocity = 0.05f;
     moveVelocity = 0.1f;
     eye = new Vector3(0f, 50f, 0f);
     // Setup the relative directory to the executable directory
     // for loading contents with the ContentManager
     Content.RootDirectory = "Content";
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SpriteBatchAndFontGame" /> class.
        /// </summary>
        public MouseInputGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Create the mouse manager
            mouseManager = new MouseManager(this);

            // Force no vsync and use real timestep to print actual FPS
            graphicsDeviceManager.SynchronizeWithVerticalRetrace = false;
            IsFixedTimeStep = false;

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";
            IsMouseVisible = true;
        }
Example #13
0
        public MyGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            //graphicsDeviceManager.IsFullScreen = true;

            graphicsDeviceManager.PreferredBackBufferHeight = _windowHeight;
            graphicsDeviceManager.PreferredBackBufferWidth = _windowWidth;

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";

            // Initialize input keyboard system
            keyboard = new KeyboardManager(this);

            // Initialize input mouse system
            mouse = new MouseManager(this);

            audiop = new AudioPlayer("rocket");
        }
Example #14
0
        public PokeSiGame()
        {
            instance = this;

            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = PreferredWidth;
            graphics.PreferredBackBufferHeight = PreferredHeight;
            graphics.IsFullScreen = IsFullScreen;

            Keyboard = new KeyboardManager(this);
            Mouse = new MouseManager(this);
            Input.Initilize(this);

            this.IsMouseVisible = true;

            Content.RootDirectory = "Content";

            // Framerate differs between platforms.
            TargetElapsedTime = TimeSpan.FromTicks(TimeSpan.TicksPerSecond / TargetFrameRate);

            screenManager = new ScreenManager(this);
        }
Example #15
0
    /// <summary>
    /// Initializes the user input-related variables
    /// </summary>
    /// <param id="gc"></param>
    public void Initialize(GameWindow gc)
    {
      this.gc = gc;

      mKeyb = new KeyboardManager(gc);
      mKeyb.Initialize();
      mMouse = new MouseManager(gc);
      mMouse.Initialize();

      pKeyb = mKeyb.GetState();
      pMouse = mMouse.GetState();

      nativeWindow = gc.Window.NativeWindow as System.Windows.Forms.Form;

      MouseVector = GetMouseVector();
      prevMouseVector = MouseVector;

      gc.Deactivated += win_Deactivated_handler;
      gc.Activated += win_Activated_handler;
      gc.Window.ClientSizeChanged += win_SizeChanged_handler;
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="Project2Game" /> class.
        /// </summary>
        public Project2Game(MainPage mainPage)
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";

            input = new GameInput();
            input.gestureRecognizer.Tapped += Tapped;
            // Create the keyboard and mouse manager
            keyboardManager = new KeyboardManager(this);
            mouseManager = new MouseManager(this);
            this.mainPage = mainPage;
        }
Example #17
0
 public static void Initialize(Game game, bool keyboardEnabled = true, bool mouseEnabled = true, bool touchEnabled = false)
 {
     InputManager.game = game;
     InputManager.graphicsDevice = game.GraphicsDevice;
     keyboard = new KeyboardManager(game);
     mouse = new MouseManager(game);
     InputManager.keyboardEnabled = keyboardEnabled;
     InputManager.mouseEnabled = mouseEnabled;
     InputManager.touchEnabled = touchEnabled;
     ClipWhileDragging = false;
 }