To component, or not to component


#1

Hello, 

So I've been thinking about this for quite a while and I just can't make a decision. I'm making a simple Arkanoid game clone and I just can't decide on whether I should use components for the "objects" or not. 

I could just create a class for each type of separate object and give it the properties I need. For instance, I could use a Rectangle for the bounds and just create a paint() function that has a reference to a Graphics (and call that from the parent component's paint()). There are two benefits that I can think of from doing this; I can use a Rectangle<float> for the bounds and I can store objects in a vector without using pointers or anything like that. I need to store the blocks at the top in some sort of array. 

Components obviously have the benefit of having so many properties to choose from, among other things. I haven't gotten to the destructible blocks at the top yet, but I've been able to make the paddle and the bouncing ball with both a component and the other easy I mentioned. 

I wonder about this for other things too, like particle engines or other graphical things. Do y'all tend to make everything a component, or do you do something like I'm thinking about? Are there any benefits of not using a component for this type of thing? I'm curious to know what other people do and I'd love to get any feedback and thoughts. 


#2

Components are really useful for handling the repainting for you. And if you call setPaintingIsUnclipped (true) then there's very little overhead.