Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45385 > unrolled thread
| Started by | Andrew Bradley <abradley201@gmail.com> |
|---|---|
| First post | 2013-05-15 20:53 -0400 |
| Last post | 2013-05-15 23:54 -0700 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Question re: objects and square grids Andrew Bradley <abradley201@gmail.com> - 2013-05-15 20:53 -0400
Re: Question re: objects and square grids Larry Hudson <orgnut@yahoo.com> - 2013-05-15 23:54 -0700
| From | Andrew Bradley <abradley201@gmail.com> |
|---|---|
| Date | 2013-05-15 20:53 -0400 |
| Subject | Re: Question re: objects and square grids |
| Message-ID | <mailman.1727.1368665595.3114.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
> > > 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
[toc] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2013-05-15 23:54 -0700 |
| Message-ID | <TaqdnfITWvAzHwnMnZ2dnUVZ_uOdnZ2d@giganews.com> |
| In reply to | #45385 |
On 05/15/2013 05:53 PM, Andrew Bradley wrote:
<snip>
> 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
Check out the book "Making Games with Python & Pygame" at http://inventwithpython.com/pygame/
It's a book you can buy or you can download the pdf or e-reader versions for free.
Also on the same site, "Invent Your Own Computer Games with Python"
Both are pretty good introductions to Python programming, "Invent..." is for non-graphic games,
and may be the better to start with. Don't try to get too advanced too fast -- you'll only get
frustrated and discouraged. But definitely do keep at it -- it's well worth the effort.
-=- Larry -=-
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web