I am designing a Tetris game and am having trouble adding in the array for the bucket, I have it commented out in the code below (the nested for loop) but it seems to drag the game so I know there is something wrong with the for loop. When I comment it out, the piece moves at a normal speed.

Also I cannot figure out the collision detection for the borders of the array and the pieces. If anyone can steer me in the right direction, I am extremely lost, I have searched the internet like crazy but nothing really shows exactly what I am looking for. Thanks for any help, it is greatly appreciated!

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Block_Movements
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        public float TimeToInput = 5;
        public float FrameCounter = 0;
   


        public class Block
        {
            Texture2D boxTexture;
            public Vector2 Position;

            public Block(ContentManager content, Vector2 position)
            {
                Position = position;
                boxTexture = content.Load<Texture2D>("box");
            }

            public void Update(GameTime gameTime)
            {
            }

            public void Draw(SpriteBatch spritebatch)
            {
                spritebatch.Draw(boxTexture, Position, Color.White);
            }
        }
    

        public class Bucket
        {
            Texture2D bucketTexture;


            public Vector2 BucketPosition;
            public int width = 10;
            public int height = 20;            


            public Bucket(ContentManager content, Vector2 bucketPosition, int width, int height)
            {            

                int Width = width;
                int Height = height;
                int[,] bucketArray = new int[width, height];                
                BucketPosition = bucketPosition;
                bucketTexture = content.Load<Texture2D>("bucket");
            }

            public void Draw(SpriteBatch spritebatch)
            {
                spritebatch.Draw(bucketTexture, BucketPosition, Color.White);
            }
        }
    

        Block newBlock;
        Bucket newBucket;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.IsFullScreen = true;
            graphics.PreferredBackBufferWidth = 1366;
            graphics.PreferredBackBufferHeight = 768;

            Window.Title = "Cory's Block Movement Extravaganza!";
        }


        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            newBlock = new Block(this.Content, new Vector2(110, 100));
            newBucket = new Bucket(this.Content, new Vector2( 80, 100), 10, 20);
        }


        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

     /*     for (int i = 0; i < newBucket.height; i++)
            {
                for (int j = 0; j < newBucket.width; j++)
                {
                    Console.WriteLine(newBucket.height);
                    Console.WriteLine(newBucket.width);                 
                }

                
            }
 
                FrameCounter += 1;
                if (FrameCounter == TimeToInput)
                {*/
                    KeyboardState keystate = Keyboard.GetState();
                    if (keystate.IsKeyDown(Keys.Left))
                        newBlock.Position.X -= 5;

                    if (keystate.IsKeyDown(Keys.Right))
                        newBlock.Position.X += 5;

                    if (keystate.IsKeyDown(Keys.Down))
                        newBlock.Position.Y += 5;

                    if (keystate.IsKeyDown(Keys.Up))
                        newBlock.Position.Y -= 5;

                    FrameCounter = 0;
                    if (FrameCounter == 0)
                        newBlock.Position.Y += 1;

               // }

                 
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin();
            newBucket.Draw(spriteBatch);
            newBlock.Draw(spriteBatch);
            
            spriteBatch.End();


            base.Draw(gameTime);
        }
    }
}

Anyone have any clue? Or should I try posting this in the game development section? I am still having trouble trying to allocate the bucket into the memory and set collisions

I know it has been a little bit but I am still looking for help on this issue. I just recently found a site that may help me and I am looking over it now but I still need help regardless so any help is greatly appreciated. It is just cutting it close to the due date and I am still stuck, don't worry I did email my teacher about this issue, just not sure when he will get back to me so I want to cover all my resources for help, any little bit helps. Thanks

This article has been dead for over six months. Start a new discussion instead.