Pages

Thursday, May 1, 2014

RECTANGLES

Been trying to figure out a formula that would allow me to make a loop which creates a screen filled with individual rectangles.


Here's what I come up with so far,  still have to write a program to fit it.

  x  axis,    width   of rectangles = w
  y axis,   hieght of rectangles = h
change in x = 1 =cx

 cx = cx + 1




   ---------------------------------------------------------------------------------------------------------------------------
  | (x, y)               |    (x +cx*w,  y)  |   ( x + cx*w, y)  |   (x + cx*w, y)   |   ( x + cx *w, y) |
  |______________ |________cx = 1__|______cx = 2_____|_______cx = 3____|______cx = 4____|
  |                                                                                                                                                       |
  | (x , y + h)  |   (x + cx*w, y +h) | (x + cx * w, y + h) |(x + cx*w, y + h) ......                  |
  |______________________________________________________________________________________|
  |                                                                                                                                                       |
  | (x, y + 2h)|  (x + cx*w, y + 2h) | ( x + cx *w, y + 2h)  ...........................................|
  |______________________________________________________________________________________|
  |                                                                                                                                                      |
  | (x, y + 3h) |  (x +cx*w, y + 3h) |( x + cx*w, y + 3h) .............................................|
  |______________________________________________________________________________________|

so for the rectangles within the rectangle.....  the origin, for pygame rect coordinates
would be (0, 0)  or (x, y),  
then every rect in the first column would be  (x, y + (i)*h)  where i would increase by one for each additional rect in the column.  
the next column would be (x +w, y+(i)*h)   and next (x + 2w,  y + (i)h)
and next (x + 3w, y +(i)*h)   the width would in crease by one multiple per column for x.

Or if we did rows,   the x would be the ( + (i)*w) and (y + h) only increasing once per row

Determined to get it to work.  Then have it make a list to keep track of each rectangle so it can be altered and changed. 
Maybe a "append.list[]"  for each rectangle created by the change in (i)



No comments:

Post a Comment