/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. texture = Content.Load<Texture2D>("Cell"); spriteBatch = new SpriteBatch(GraphicsDevice); grid = Grille.Parse(Content.Load<Texture2D>("map1")); cam = new Camera(grid); mouse = new MouseHandler(); changed = new List<Cell>(); // TODO: use this.Content to load your game content here }
public void Update(Camera cam) { MouseState currentMouseState = Mouse.GetState(); if (currentMouseState.X >= GraphicsDeviceManager.DefaultBackBufferWidth) { Mouse.SetPosition(GraphicsDeviceManager.DefaultBackBufferWidth, currentMouseState.Y); } else if (currentMouseState.X <= 0) { Mouse.SetPosition(0, currentMouseState.Y); } else if (currentMouseState.Y >= GraphicsDeviceManager.DefaultBackBufferHeight) { Mouse.SetPosition(currentMouseState.X, GraphicsDeviceManager.DefaultBackBufferHeight); } else if (currentMouseState.Y <= 0) { Mouse.SetPosition(currentMouseState.X, 0); } fakePos = new Point((int)cam.position.X + currentMouseState.X, (int)cam.position.Y + currentMouseState.Y); position = new Point(currentMouseState.X, currentMouseState.Y); if (currentMouseState.LeftButton == ButtonState.Pressed) { if (oldMouseState.LeftButton == ButtonState.Released) { LeftClickState = ClickState.Clicked; } else { LeftClickState = ClickState.Held; } } else { if (oldMouseState.LeftButton == ButtonState.Released) { LeftClickState = ClickState.Released; } else { LeftClickState = ClickState.Releasing; } } if (currentMouseState.RightButton == ButtonState.Pressed) { if (oldMouseState.RightButton == ButtonState.Released) { RightClickState = ClickState.Clicked; } else { RightClickState = ClickState.Held; } } else { if (oldMouseState.RightButton == ButtonState.Released) { RightClickState = ClickState.Released; } else { RightClickState = ClickState.Releasing; } } oldMouseState = currentMouseState; }