So I'm trying to make a picture out of squares and I need 238 squares and I'm wondering how to put them all on the screen using the same object, Is there a better way to do this? I've been trying this for a few days now and don't know what to do.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void InitBottle(Bottle bottles[])
{
for(int j = 0; j <= 11;j++)
{
int bx = 165;
int by = 50;
for(int i = 0; i <= 5;i++)
{
bottles[i].ID = BOTTLE;
bottles[i].x = bx;
bottles[i].y = by;
bx += 15;
}
by += 15;
}
}
I know the problem is that the by keeps resetting, so I guess I'm really wondering how to set by and then have it not reset, and if I put the declarations outside the for loop, then both bx and by just keep going up don't even show up on the window. I know this doesn't draw all 238 squares but I'm working up to it starting here. So if anyone's got a better idea or how to fix this I'd appreciate the help. Also if it's not to much to ask please don't just give me the code, just a starting point, I'm trying to learn.
to get the handle for the console, use this line: HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
here's a sample program that uses these functions, you probably want to skip till the function BounceProc(), it uses these functions and shows how to use them: http://msdn.microsoft.com/en-us/library/esszf9hw.aspx
DTSCode: I'm trying to, I need 238 squares in total, Bottle is a square that what I hope to accomplish with this bit of code is to create 238 squares and have Allegro paint them to the screen in the shape of a bottle
Rechard3: I'm not talking about the console at all, I'm using Allegro to drive the graphics. I guess I should have stated that. sorry.
JLBorges: I tried that, but then it still only paints one line just really far down the screen, the idea here is to paint 11 lines of 6 squares.
FredBill30: no offense, but, did you even read my original post? I clearly stated in it that I had tried moving both of them out of the for loop, and I also stated that when I did that, the i and j kept going up and never rendered outside the widow.
JLBorges: Some of that code is above my head, so I'm going to look up constexpr, operator, and const, and auto, and I'll get back to you on this