Hey,
Well I have been learning Directx and I am trying to make a simple Breakout Clone. It is going pretty good and I am almost done. The only thing is this: I have a class called "Block." My question is, how should I create multipule blocks?
Should I do it like: Block block[255];
or is there another way to do this that is more effecient. In essence, I am trying to create 255 block objects and I am not sure what the best way of doing this is. Also, I am trying to figure out a good way of inistializing all the blocks. Should I create a function in the class block? Should I create a global function and then make it a friend of the class block? Or what? If anyone has any suggestions I would appreciate it.
Thanks.
Well I tried the thing you told me. Since I am new to programming I have not used the new command before. I think I basically figured it out now but I am having some troubles. Here is my Init() and GameLoop() Functions:
PPaddle = new Paddle; PBlock = new Block[240]; PBall = new Ball;
return 0; }
Ok, well I don''t know how to call all of the PBlock Objects. How am I supposed to do this? I tried doing this:
PBlock[20]->DrawBlock(lpDDSBack);
To draw the 20th Block Object, but I get this error saying it needs a class/union/struct so obviously that is not how you do it. Well if you could help me out I would like that. Thanks.
You may want to try using linked list though the array would work. Or make an array of just int and make it 1''s and 0''s for every 1 make a block there etc.
You said that you are learning DX. So I think that you should go with your array. It will work fine. Its more important to get it work than trying to make fine code.
There is nothing wrong with an array. Although you can make it more dynamic with other ways but that is not neccesary if you are doing it to learn dx. You can always update your game later.