protected override void Initialize()
{
graphics.PreferredBackBufferWidth = 720;
graphics.PreferredBackBufferHeight = 1080;
graphics.IsFullScreen = true;
graphics.ApplyChanges();
Window.Title = "Game";
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
Texture = Content.Load<Texture2D>("Sprite");
position.X = 1;
position.Y = 520;
}
protected override void Update(GameTime gameTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.Down))
position.Y += 2;
if (Keyboard.GetState().IsKeyDown(Keys.Up))
position.Y -= 2;
if (Keyboard.GetState().IsKeyDown(Keys.Right))
position.X+= 2;
if (Keyboard.GetState().IsKeyDown(Keys.Left))
position.X -= 2;
if (position.Y > 520)
position.Y = 520;
base.Update(gameTime);
}
and when I add
if (position.Y < 1080)
position.Y = 1080;
the sprite disappears (sorry for posting such a long code I did not know what I did wrong.) (to save space I removed most of the white space)
image link:https://i.stack.imgur.com/3MVPv.png
Your comparator is flipped.
You're checking if the y position is SMALLER than 1080, then putting it at 1080 (the edge of the screen).
should do what you were expecting