Robert955 0 Newbie Poster

o/

Im working on a game in XNA 4.0 and ive started on making an actionbar.
What I have is a tileEngine and if I remove a block I want it to appear in my actionbar. but after I got it in the first column of my bar and I pick up another block I want it to appear in the column next to the one thats already filled. So I made 10 rectangles for each column in my actionbar. and I made another Rectangles which states the availeble column. if I fill the first column with something, the availeble column rect will move to the next column however if I draw the block on the rect: availeble column it will (of course) move with it which is not what I want, I want it to stay in the spot where rect availeble column was before it was moved to the next column.

heres some code I got, I know it wont work like this I just dont know how to fix it:

public static int x, y;
        Rectangle AB1 = new Rectangle(710, 980, 50, 50);
        Rectangle AB2 = new Rectangle(760, 980, 50, 50);
        Rectangle AB3 = new Rectangle(810, 980, 50, 50);
        Rectangle AB4 = new Rectangle(860, 980, 50, 50);
        Rectangle AB5 = new Rectangle(910, 980, 50, 50);
        Rectangle AB6 = new Rectangle(960, 980, 50, 50);
        Rectangle AB7 = new Rectangle(1010, 980, 50, 50);
        Rectangle AB8 = new Rectangle(1060, 980, 50, 50);
        Rectangle AB9 = new Rectangle(1110, 980, 50, 50);
        Rectangle AB10 = new Rectangle(1160, 980, 50, 50);
        Rectangle AvailebleSpot;



 public override void Update(GameTime gameTime)
        {
            AvailebleSpot = new Rectangle(x, y, 50, 50);
            if (columnCount == 0)
            {
                x = 710;
                y = 980;
            }
            if (columnCount == 1)
            {
                x = 760;
                y = 980;
            }
            if (columnCount == 2)
            {
                x = 810;
                y = 980;
            }
            if (sand < 0)
            {
                sand = 0;
            }
            if (stone < 0)
            {
                stone = 0;
            }
      
            base.Update(gameTime);
        }

      
 
        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(actionBar, new Rectangle((GraphicsDevice.Viewport.Width / 2) - (actionBar.Width / 2), GraphicsDevice.Viewport.Height - 100, 500, 50), Color.White);
            if (sand > 0)
            {
                spriteBatch.Draw(sandBlock, AvailebleSpot, Color.White);
                columnCount = 1;
                
            }
            if (stone > 0)
            {
                spriteBatch.Draw(stoneBlock, AB2, Color.White);
                columnCount = 2;

            }

            spriteBatch.Draw(avaSpot, AvailebleSpot, Color.White); /* <-- just helps me to see the availeble spot*/
            spriteBatch.End();
        }

thanks in advance o/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.