Exemplo n.º 1
0
        /// <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);
            
        }
Exemplo n.º 2
0
        public MyGame()
        {
            _graphicsDeviceManager = new GraphicsDeviceManager(this);

            _keyboardManager = new KeyboardManager(this);
            _mouseManager = new MouseManager(this);
        }
Exemplo n.º 3
0
 public Control(Game game)
 {
     Game = game;
     Window = game.Services.GetService<MasterWindow>();
     Keyboard = Window.Keyboard;
     Mouse = Window.Mouse;
 }
Exemplo n.º 4
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");
            }
        }
Exemplo n.º 5
0
 public MyGame()
     : base()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     keyboardManager = new KeyboardManager(this);
     graphics.PreferredBackBufferWidth = 320;
     graphics.PreferredBackBufferHeight = 240;
 }
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DxExempel2" /> class.
        /// </summary>
        public DxExempel2()
        {
            // 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 keyboard system
            keyboard = new KeyboardManager(this);
        }
Exemplo n.º 8
0
        private ViewportF _currentViewport; // the current viewport of the 3D swap chain

        public ForegroundSwapChainGame()
        {
            _graphicsDeviceManager = new GraphicsDeviceManager(this);
            _graphicsDeviceManager.DeviceCreationFlags |= SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;

            // we will create and destroy the foreground swap chain in these event handlers
            _graphicsDeviceManager.DeviceChangeBegin += HandleDeviceChangeBegin;
            _graphicsDeviceManager.DeviceChangeEnd += HandleDeviceChangeEnd;

            // initialize the keyboard manager
            _keyboardManager = new KeyboardManager(this);

            Content.RootDirectory = "Content";
        }
Exemplo n.º 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;
 }
Exemplo n.º 10
0
 /// <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";
 }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SpriteBatchAndFontGame" /> class.
        /// </summary>
        public KeyboardInputGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // Create the keyboard manager
            keyboarManager = new KeyboardManager(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;
        }
Exemplo n.º 12
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");
        }
Exemplo n.º 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RiftGame" /> class.
        /// </summary>
        public RiftGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);
            keyMgr = new KeyboardManager(this);
            //this.graphicsDeviceManager.IsFullScreen = true;

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

            // Initialize OVR Library
            OVR.Initialize();

            // Create our HMD
            hmd = OVR.HmdCreate(0) ?? OVR.HmdCreateDebug(HMDType.DK2);

            // Match back buffer size with HMD resolution
            graphicsDeviceManager.PreferredBackBufferWidth = hmd.Resolution.Width;
            graphicsDeviceManager.PreferredBackBufferHeight = hmd.Resolution.Height;

        }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
        public SampleGame()
        {
            // create the graphics device manager and set desired screen resolution
            _graphicsDeviceManager = new GraphicsDeviceManager(this)
                                     {
                                         PreferredBackBufferWidth = 1440,
                                         PreferredBackBufferHeight = 900
                                     };

            // give a chance to override selected graphics device settings (for example, to use a WARP adapter)
            _graphicsDeviceManager.PreparingDeviceSettings += HandlePreparingDeviceSettings;

            // initialize the camera
            _camera = new OrbitCamera
                      {
                          Radius = 2f,
                          Target = new Vector3()
                      };

            // initialize the keyboard manager
            _keyboardManager = new KeyboardManager(this);

            Content.RootDirectory = "Content";
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LabGame" /> class.
        /// </summary>
        public LabGame(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";

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);
            assets = new Assets(this);
            random = new Random();
            input = new GameInput();

            // Set boundaries.
            boundaryLeft = -4.5f * Camera.MaxModelSize / 5;
            boundaryRight = 4.5f * Camera.MaxModelSize / 5;
            boundaryTop = 4 * Camera.MaxModelSize / 5;
            boundaryBottom = -4.5f;

            // Initialise event handling.
            input.gestureRecognizer.Tapped += Tapped;
            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            this.mainPage = mainPage;

            score = 0;
            difficulty = 1;
        }
Exemplo n.º 17
0
        /// <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;
        }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LabGame" /> class.
        /// </summary>
        public LabGame(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";

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);
            assets = new Assets(this);
            random = new Random(Environment.TickCount);
            input = new GameInput();

            // Set boundaries.
            boundaryLeft = -4.5f;
            boundaryRight = 4.5f;
            boundaryTop = 4;
            boundaryBottom = -4.5f;
            boundaryFront = -4.5f;
            boundaryBack = 4.5f;

            // Initialise event handling.
            input.gestureRecognizer.Tapped += Tapped;
            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            this.mainPage = mainPage;

            score = 0;
            difficulty = 1;
            currentGameTimeSecond = 0;
            //make it safe
            mazeSeed=random.Next(1,Int32.MaxValue-1);
        }
Exemplo n.º 19
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;
    }
Exemplo n.º 20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LabGame" /> class.
        /// </summary>
        public GameController(MainPage mainPage)
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            //Slider Values

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

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);
            random = new Random();
            input = new GameInput();
            size = 10;
            generateGhost = 0.99;
            // Set boundaries.
            boundaryNorth = 2.6f;
            boundaryEast = size * 10 - 2.6f;
            boundarySouth = size * 10 - 2.6f;
            boundaryWest = 2.6f;

            // Initialise event handling.
            input.gestureRecognizer.Tapped += Tapped;
            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            this.mainPage = mainPage;
        }
Exemplo n.º 21
0
        private Stack<GameObject> removedGameObjects; //game objects to be removed from the active list

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="LabGame" /> class.
        /// </summary>
        public LabGame(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";

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);
            //Assets utility class
            assets = new Assets(this);
            //Input parser
            input = new GameInput();

            // Initialise event handling.
            input.gestureRecognizer.Tapped += Tapped;
            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            //Create main XAML interface
            this.mainPage = mainPage;

            //Initialise game state
            score = 0;
            difficulty = 1;
            gameOver = false;
            size = 7;
            edgemax = (int)Assets.WORLD_WIDTH;
        }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MonitorInfoGame" /> class.
        /// </summary>
        public MonitorInfoGame()
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);

            // handling of this event allows to force usage of a specific adapter
            graphicsDeviceManager.PreparingDeviceSettings += HandlePreparingDeviceSettings;

            // initial, windowed resolution
            graphicsDeviceManager.PreferredBackBufferWidth = 1024;
            graphicsDeviceManager.PreferredBackBufferHeight = 768;

            // all initial components should be created in game constructor
            keyboardManager = new KeyboardManager(this);

            // Setup the relative directory to the executable directory
            // for loading contents with the ContentManager
            Content.RootDirectory = "Content";
        }
Exemplo n.º 23
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;
 }
Exemplo n.º 24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project1Game" /> class.
        /// </summary>
        public Project1Game(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";

            assets = new Assets(this);

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);

            //new GameInput
            input = new GameInput();

            //// Initialise event handling.

            input.gestureRecognizer.Tapped += Tapped;

            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;

            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;

            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            // Set boundaries.
            boundaryLeft = -4.5f;
            boundaryRight = 4.5f;
            boundaryTop = 4;
            boundaryBottom = -4.5f;

            this.mainpage = mainpage;
        }
Exemplo n.º 25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectGame" /> class.
        /// </summary>
        public ProjectGame(MainPage mainPage)
        {
            // Creates a graphics manager. This is mandatory.
            graphicsDeviceManager = new GraphicsDeviceManager(this);
            //graphicsDeviceManager.PreferredGraphicsProfile = new FeatureLevel[] { FeatureLevel.Level_10_0, };
            graphicsDeviceManager.PreferredGraphicsProfile = new FeatureLevel[] { FeatureLevel.Level_10_1, };

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

            // Create the keyboard manager
            keyboardManager = new KeyboardManager(this);
            random = new Random();
            input = new GameInput();

            // Initialise event handling.
            input.gestureRecognizer.Tapped += Tapped;
            input.gestureRecognizer.ManipulationStarted += OnManipulationStarted;
            input.gestureRecognizer.ManipulationUpdated += OnManipulationUpdated;
            input.gestureRecognizer.ManipulationCompleted += OnManipulationCompleted;

            this.mainPage = mainPage;
            difficulty = 1;
            score = 0;
        }