[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] bidimensional arrays or the quick way to maps
- To: pygame-users@xxxxxxxx
- Subject: [pygame] bidimensional arrays or the quick way to maps
- From: pistacchio <pistacchio@xxxxxxxxx>
- Date: Tue, 04 Sep 2007 21:42:43 +0200
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 04 Sep 2007 15:43:14 -0400
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=dA8Kflg8XAP+FfcQFnK9WAIXZPCzFKJfy1rF8V2eBTHB1xLi8PrEnc/GG6BDqz8TeLRfFNTcG1GovanLDqGQ0tw+rptoxgFr6/byNa0KlxxVofYFY5fR/C6OB1Xo2oAc4ZVqD7aXYIth8u77dDOVSLAH7nF998TdgDLJiYnHwcA=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:content-type:content-transfer-encoding; b=Tztiz5HiKqLxPrqzJiNnnlmnB9YvcS65tJonVcxDGWQQDdANQAAkPD7E4dd9cJlbMUyN2C2ly6DhXx/1KScFXjFbPQDjhcun0ufaHKKjKSNOWCKRapvtu3MbO1r4GYSIzSTD1OSiQvoKd+vZ/O5WFDExwbcwyBkbYVf/NDC+Z3E=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Thunderbird 2.0.0.6 (Windows/20070728)
maps are certainly a very common feature in game development. the
easiest way to trace maps (and the one that i've used in other languages
in tha past) is to use multidimensional arrays. so, a tile-map, can be
stored and worked on as a simple array (or list) that goes like this:
tile_map[x][y] = tile_number
now, probably i'm missing a basic feature of python, but it seems to
lack of a native support for multidimensional arrays. i've seen that
NumPy as an advanced array class, but probably so advanced that i got
lost in the documentation and i could't find a way to get the simple
things i need:
-declare a multidimensional array specifiying the lenght of each
dimension (like, to obtain a 10x20 grid a sort of "a = array(10,20)" or
(9,19) if 0-based)
-easily access the cells for reading / appending / writing data, like in
"a[7][4] = 8" to alter or set the content of a given cell.
how did you solve the problem?
thanks in advance
gustavo