Question re: objects and square grids

Andrew Bradley abradley201 at gmail.com
Wed May 15 20:53:05 EDT 2013


>
>
>  SQUARESIZE = 43
>>>
>>> grid = []
>>> for row in range(10):
>>>      row_squares = []
>>>      for column in range(20):
>>>          rect = Rect(12 + column * SQUARESIZE, 10 + row * SQUARESIZE,
>>> SQUARESIZE, SQUARESIZE)
>>>          row_squares.append(rect)
>>>      grid.append(row_squares)
>>>
>>> It appears to be working (that is, the program still runs without
>>> crashing).
>>>
>>
> Sorry, but that's no criteria.  Question is whether it's doing what you
> want.  Are the rows 20 across and are there 10 of them?  Do the values of
> each individual rect look right?  print is your friend.


Yes, I have gotten rid of that part with the 1, 2, 3, 4, etc., and now the
code appears to be working up to [9][19]. Thank you very much. The
coordinates all do look correct, and there are 200 rectangles when I do
list(grid).

>
>
>  So now, how can I utilize this new grid list? Thank you for the
>>> help so far, I feel like the entire grid is now being worked out.
>>> -Andrew
>>>
>>>
> That's a Pygame question, and I told you at the beginning, I can't really
> help with that.  I'd like to learn, but not this week.
>
> Others - can you show some minimal code to use these grid parameters to
> color selected squares of the pygame window?
>
>
Yes, I would very much like some help or general advice now about utilizing
this grid thing. How can I refer to these square's new numerical values to
do things with them? Will I be using things like "grid[0][1]" in specific
functions and methods to refer to squares now? That is what I would like to
do, somehow.

>
> --
> DaveA
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>

I apologize if these questions are too rudimentary--I am trying to wrap my
head around how this language works in a more general sense so I can start
applying it to things.
-Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130515/953c6877/attachment.html>


More information about the Python-list mailing list