So I need help, I dont have any errors with my code, it just dosent move Item in-game
here is my class code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace First
{
class Sprite
{
public Texture2D texturee;
public Rectangle rectan;
public virtual void Update()
{
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texturee, rectan, Color.White);
}
}
// ---------------------------------------------------------------------Background
class Background : Sprite
{
public Background(Texture2D newTexture, Rectangle newRectangle)
{
texturee = newTexture;
rectan = newRectangle;
}
}
// ----------------------------------------------------------------------Item
class Item : Sprite
{
public Item(Texture2D newTexture, Rectangle newRectangle)
{
texturee = newTexture;
rectan = newRectangle;
}
public override void Update()
{
if (Keyboard.GetState().IsKeyDown(Keys.Right))
{
rectan.X += 2;
}
if(Keyboard.GetState().IsKeyDown(Keys.Right))
{
rectan.X -= 2;
}
}
}
}
So if I create more than 1 Item I want it to move also, I don't feel like typing this movement code for every item, so I did it in a Item class, but when running, the Item doesnt move :/
EDITEDITEDIT:
Also, the Item is drawn if bollean == true, but I don't think that has impact on item movement