🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

adding objects to a hashset

Started by
3 comments, last by pbivens67 3 years, 3 months ago

I have done a lot of research on this topic. I am trying to add objects to a hashset.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HashSet
{
    class Program
    {
        class Brick
        {
            public int x1;
            public int y1;
            public int width1;
            public int height1;
            public int x2;
            public int y2;
            public int width2;
            public int height2;
            public bool Colliding()
            {
                if (x1 <= x2 + width2 && x1 + width1 >= x2 && y1 <= y2 + height2 && y1 + height1 >= y2)
                {
                    return true;
                }
                return false;
            }
        }
        static void Main(string[] args)
        {
            HashSet<Brick> bricks = new HashSet<Brick>();

            for (int i=0; i<=640; i+=80)
            {
                bricks.Add(new Brick());
            }
        }
    }
}
Advertisement

pbivens67 said:
I have done a lot of research on this topic. I am trying to add objects to a hashset.

You can do it!

If not, feel free to ask a question. “Am I on the right track?" isn't a good question.

🙂🙂🙂🙂🙂<←The tone posse, ready for action.

Are you still working on Breakout, Phil, or have you moved on to something else?

-- Tom Sloper -- sloperama.com

@fleabay well I have figured out how to add objects to a hashset

                bricks.Add(new Brick { x1 = i, y1 = 0, width1 = 80, height1 = 40 });

This topic is closed to new replies.

Advertisement