Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45356

Question re: objects and square grids

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <abradley201@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.062
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'squares': 0.07; 'subject:Question': 0.07; 'grid': 0.09; 'integers': 0.09; 'python': 0.11; 'names?': 0.16; 'pygame': 0.16; 'pygame.': 0.16; 'appropriate': 0.16; 'variable': 0.18; 'trying': 0.19; 'basically': 0.19; 'pieces': 0.19; 'seems': 0.21; 'programming': 0.22; 'color,': 0.24; 'precise': 0.24; 'tend': 0.24; 'this:': 0.26; 'certain': 0.27; 'appreciated.': 0.29; 'related': 0.29; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'code': 0.31; 'crash': 0.31; 'running': 0.33; 'guess': 0.33; 'could': 0.34; 'problem': 0.35; 'advice': 0.35; 'possible.': 0.35; 'something': 0.35; 'objects': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'everyone.': 0.36; 'done': 0.36; 'example,': 0.37; 'turn': 0.37; 'easily': 0.37; 'being': 0.38; 'thank': 0.38; 'actions': 0.38; 'filled': 0.38; 'work?': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; '12,': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'easy': 0.60; 'most': 0.60; 'utilize': 0.61; 'numbers': 0.61; 'entire': 0.61; 'simple': 0.61; 'kind': 0.63; 'such': 0.63; 'different': 0.65; 'love': 0.65; 'side': 0.67; 'useful.': 0.68; 'square': 0.74; 'confirming': 0.84; 'endless.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=f686t9S1qSgvrhEuCmH55lEPU3Xg35AyjKgepfxdR1U=; b=JBwJiGD1RGPA9hsqtltUHxvOgC6Lu5+fXlKGgSkprT+t7nSnqebH8VpD3BoLY/8mJs uL0NKiTHdpG1gVnUeZn8tx3vFEcC1oKxN/pI2ZPcyCBN42mfEraDU2ztU37Dt7Iaft2D sPbN8Ud8Y8SpF0N/TTVrreZ940/oWhj2M9Shr5ZQd3O3aZg2scMYaiPOeOc4oSsCFbOQ xtOH10QfkTWkKKWzD8B/Q4tlCl9b/jzOlBRM2JSdhffxaTrH3Km3p3qRpOTa0u90hmwx SDixTHeLyxsqCMIU5Rvv3R2cU5LvApZt09+YorhH6ZSF9+VXh7slYxhuccuwNlU322ap SnMg==
MIME-Version 1.0
X-Received by 10.50.51.167 with SMTP id l7mr6154278igo.11.1368637020054; Wed, 15 May 2013 09:57:00 -0700 (PDT)
Date Wed, 15 May 2013 12:56:59 -0400
Subject Question re: objects and square grids
From Andrew Bradley <abradley201@gmail.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=14dae9340b5f68296204dcc4a352
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1707.1368637030.3114.python-list@python.org> (permalink)
Lines 83
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368637030 news.xs4all.nl 15954 [2001:888:2000:d::a6]:40911
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45356

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Hello everyone.

I am having a good time programming with Python 3.3 and Pygame. Pygame
seems like the perfect platform for the kind of simple games that I want to
make.

What I have currently programmed is basically a drawn rectangle filled with
200 squares, each side of the squares being 43 pixels. The rectangle is 20
squares by 10 squares.

This grid is what I want to have the entire game on. There will be pieces
that move certain numbers of squares, perform actions that effect pieces on
certain squares, etc. The possibilities are endless.

So what I am now trying to do is organize these squares into objects that I
can easily reference when programming things related to the squares.

So far, I have done this:

A1 = pygame.Rect(10, 12, 43, 43)
A2
A3
A4
B1
B2
etc.

where said integers are the precise location of the top left-most square
for A1, and onward down the line. I would guess that I could continue on in
such a fashion, with appropriate box names for each square. But I'm running
into the problem of confirming that the code above actually does something
useful. For example, I would love to be able to turn A1 a different color,
but how does this work? How do I actually utilize these object variable
names? Are there methods that I am not aware of, because most things I try
tend to do nothing or crash the game. For example, A1.fill(BLUE) does not
work.

Any general advice about how to organize my squares into something that is
easy to program for would be VERY appreciated. Basically all the games I
want to make involve square grids like this, so I want to know as much
about them as possible.

Thank you very much for reading this,
Andrew

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Question re: objects and square grids Andrew Bradley <abradley201@gmail.com> - 2013-05-15 12:56 -0400

csiph-web