Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45376
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '16,': 0.03; 'skip:\xa0 30': 0.05; 'column': 0.07; 'list?': 0.07; 'subject:Question': 0.07; 'classes.': 0.09; 'function,': 0.09; 'grid': 0.09; 'try:': 0.09; 'width': 0.09; 'runs': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'assume': 0.14; 'itself.': 0.14; 'language.': 0.14; '(0,': 0.16; '20)': 0.16; '4:35': 0.16; 'arg2,': 0.16; 'be:': 0.16; 'call?': 0.16; 'excellent,': 0.16; 'formula': 0.16; 'function?': 0.16; 'likewise': 0.16; 'non- trivial': 0.16; 'pygame': 0.16; 'thoroughly.': 0.16; '(you': 0.16; 'wrote:': 0.18; 'do.': 0.18; 'wed,': 0.18; 'bit': 0.19; 'seems': 0.21; '8bit%:5': 0.22; 'appears': 0.22; 'programming': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'replace': 0.24; 'skip:\xa0 20': 0.24; '\xa0if': 0.24; "haven't": 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; '15,': 0.26; 'define': 0.26; 'nearly': 0.26; 'header:In-Reply- To:1': 0.27; 'function': 0.29; "doesn't": 0.30; '8bit%:3': 0.30; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'lines': 0.31; 'too.': 0.31; '13,': 0.31; 'alan': 0.31; 'assumes': 0.31; 'cells': 0.31; 'initialized': 0.31; 'parameters.': 0.31; 'class': 0.32; 'lists': 0.32; 'probably': 0.32; 'another': 0.32; 'quite': 0.32; 'worked': 0.33; 'url:python': 0.33; "i'd": 0.34; 'could': 0.34; 'classes': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; '14,': 0.36; 'explains': 0.36; "he's": 0.36; 'height': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'url:org': 0.36; 'should': 0.36; 'example,': 0.37; 'list': 0.37; 'list.': 0.37; 'being': 0.38; 'represent': 0.38; 'thank': 0.38; 'list,': 0.38; 'pm,': 0.38; 'previous': 0.38; 'skip:& 20': 0.39; '12,': 0.39; '\xa0\xa0\xa0': 0.39; 'delete': 0.39; 'url:mail': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'around.': 0.60; 'dave': 0.60; 'utilize': 0.61; 'new': 0.61; 'numbers': 0.61; 'entire': 0.61; 'simply': 0.61; 'simple': 0.61; "you're": 0.61; 'here:': 0.62; "you've": 0.63; 'show': 0.63; 'kind': 0.63; 'such': 0.63; 'decided': 0.64; 'week,': 0.64; 'more': 0.64; 'taking': 0.65; '(that': 0.65; 'afraid': 0.65; 'size.': 0.65; 'reply': 0.66; 'experience.': 0.67; 'between': 0.67; 'details,': 0.68; 'skip:r 30': 0.69; 'url:me': 0.69; 'demonstrates': 0.84; 'gap': 0.84; 'ian,': 0.84; 'started,': 0.84; 'typically,': 0.84; 'well..': 0.84; '\xa0but': 0.84; 'angel': 0.91; 'good,': 0.91; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=SN2+E9vfbCsLaiER0z21H3iYLHuyCaNQwcnqUhai4TM=; b=ZKuHvxu41fT52o4D2iRLQpUV1PhZhODLaUeH6fYsF4nXa5+ROrHd9RejB/2OTsqhyO NSfUYohm3qXm5U1ThJ8vIaHyHtfVkytRmbzhG23iVZdxdzOWH0MM1k4yOIHf5w/LHU3d CE/fUtmQ+BXzJuTrxHTtEx8wtLO/OPwHiabAi+ie/OE/W3DZwxqWAXfPJxAR4db1aTTI beR44MvnNmJZRM7/EFmdGHZIAbIlGlXcQEmuAVwOvDeu0OCwLVUSrdN4WNQdfJaEFLdH JHO2LPM9Nijy4jb3bcOJdZmrtIv7Yt/miRkyD073PNd3xipOghdyW1xTPyKGfJZIcQbW PFeQ== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.70.99 with SMTP id l3mr7009300igu.91.1368658087730; Wed, 15 May 2013 15:48:07 -0700 (PDT) |
| In-Reply-To | <CAPp_YbVBm2444Ea-pUy2Zn2YbB1mKmDoasmNXp7DPAbs8Sra4g@mail.gmail.com> |
| References | <CAPp_YbVwiK1RBk_fLP32Kzv56GjYUf4TL=Ogzo5qsOKtrd8kGg@mail.gmail.com> <5193CC16.80304@davea.name> <5193E8C0.1060004@davea.name> <CAPp_YbVBm2444Ea-pUy2Zn2YbB1mKmDoasmNXp7DPAbs8Sra4g@mail.gmail.com> |
| Date | Wed, 15 May 2013 18:48:07 -0400 |
| Subject | Re: Question re: objects and square grids |
| From | Andrew Bradley <abradley201@gmail.com> |
| To | Dave Angel <davea@davea.name> |
| Content-Type | multipart/alternative; boundary=047d7b3a98ae23658604dcc98b7c |
| Cc | python-list@python.org |
| 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.1722.1368658090.3114.python-list@python.org> (permalink) |
| Lines | 291 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1368658090 news.xs4all.nl 16002 [2001:888:2000:d::a6]:51666 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:45376 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
ok, now I have tested this more thoroughly, and it seems i can only do the grid[x][y] function up to grid[9][9], when i really should be able to be doing up to grid[10][20]. What exactly is the function of this row_squares list? On Wed, May 15, 2013 at 4:35 PM, Andrew Bradley <abradley201@gmail.com>wrote: > Now I want to show you what I have written: > > row = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) > column = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, > 18, 19, 20) > 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). 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 > > > > On Wed, May 15, 2013 at 3:57 PM, Dave Angel <davea@davea.name> wrote: > >> On 05/15/2013 02:14 PM, Andrew Bradley wrote: >> >> Please reply on the list, not privately, unless it's something like a >> simple thank-you. Typically, you'd do a reply-all, then delete the people >> other than the list itself. Or if you're using Thunderbird, you could just >> reply-list. >> >> > Thank you very much for your response: it seems excellent, but I'm >> afraid I >> > do not understand it fully. Your code here: >> >> > >> > maxrows = 10 >> > maxcols = 20 >> > grid = [] >> > for row in range(maxrows): >> > rowdata = [] >> > for column in range(maxcols): >> > arg1 = ... >> > arg2 = ... >> > arg3 = ... >> > arg4 = ... >> > rowdata.append(pygame.Rect(arg >> > 1, arg2, arg3, arg4) >> > grid.append(rowdata) >> > >> > Seems very good, but keep in mind I just started programming last week, >> and >> > this is hard for me to wrap my head around. Do I really just write grid >> = >> > []? or is this like a def grid(): function? >> >> This code was intended to replace the 200 lines you started, A1= >> pygame... A2= A3= etc. I'd have put them inside a function, but this is >> just one of the things I'd have initialized in such a function. grid is a >> list of lists, not a function. >> >> >> > What do you mean by rowdata = []? >> >> [] is the way you define an empty list. Another way might be: >> rowdata = list() >> >> >> > And how exactly would I make the formula for a rect call? >> >> Well, for row==0 and col==0, you say you wanted 10, 12, 43, and 43 for >> the four parameters. But you never said how you were going to (manually) >> calculate those numbers for other cells. Only once you've decided that can >> you fill in "formulas" for arg1 and arg2. I suspect that arg3 and arg4 are >> simply 43 and 43 respectively, since you want all the cells to be the same >> size. >> >> taking my clue from Ian, I might try: >> >> x_offset = 10 >> y_offset = 12 >> width = height = 43 >> arg1 = column * width + x_offset >> arg2 = row * height + y_offset >> arg3 = width >> arg4 = height >> >> That assumes that there is no gap between cells in this grid. If you >> want a gap, then the width value used in the arg1 formula would be more >> than 43 (width). Likewise the height value used in the arg2 formula would >> be more than 43 (height). >> >> > If there's a good website for these kind of details, I would appreciate >> that too. >> >> You cannot begin to write a non-trivial program in Python without >> understanding lists pretty thoroughly. Perhaps you should start with Alan >> Gauld's tutorial, which doesn't assume previous programming experience. >> http://www.alan-g.me.uk/ >> >> I haven't studied it, as Python was about my 35th programming language. >> But he's very active on Python-tutor, and explains things very well. So >> his website is probably very good as well. >> >> Now, as you can see from Ian's message, writing a game using pygame will >> require quite a bit of other understanding. He demonstrates with classes >> to represent cells, which is indeed what I'd do. But I suspect you're not >> nearly ready to consider writing classes. (You use classes all the time. >> For example, 5 is an instance of class int.) >> >> >> -- >> DaveA >> >> >> >> -- >> DaveA >> -- >> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> >> > >
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Question re: objects and square grids Andrew Bradley <abradley201@gmail.com> - 2013-05-15 18:48 -0400
csiph-web