Permalink
Browse files

fix some typos and clean whitespace

  • Loading branch information...
Michael Cotterall
Michael Cotterall committed Jul 16, 2012
1 parent 9bb839b commit dca385bac009757d6f0ac2e7c2cb504e7f3ad4ed
Showing with 60 additions and 60 deletions.
  1. +16 −16 pytmx/pytmx.py
  2. +5 −5 pytmx/tmxloader.py
  3. +17 −17 pytmx/tmxloader3.py
  4. +15 −15 pytmx/utils.py
  5. +4 −4 tests/demo.py
  6. +3 −3 tests/test.py
View
@@ -1,6 +1,6 @@
from itertools import chain, product
from xml.etree import ElementTree
-from collections import defaultdict
+from collections import defaultdict
from utils import decode_gid, types, parse_properties, read_points
from constants import *
@@ -21,7 +21,7 @@ def set_properties(self, node):
"""
# set the attributes reserved for tiled
- [ setattr(self, k, types[str(k)](v)) for (k,v) in node.items() ]
+ [ setattr(self, k, types[str(k)](v)) for (k,v) in node.items() ]
# set the attributes that are derived from tiled 'properties'
for k,v in parse_properties(node).items():
@@ -58,7 +58,7 @@ def __init__(self, filename=None):
self.layernames = {}
# only used tiles are actually loaded, so there will be a difference
- # between the GID's in the Tile map data (tmx) and the data in this
+ # between the GIDs in the Tile map data (tmx) and the data in this
# class and the layers. This dictionary keeps track of that difference.
self.gidmap = defaultdict(list)
@@ -199,7 +199,7 @@ def getTileLocation(self, gid):
xrange(self.height),
xrange(len(self.tilelayers)))
- return [ (x,y,l) for (x,y,l) in p
+ return [ (x,y,l) for (x,y,l) in p
if self.tilelayers[l].data[y][x] == gid ]
@@ -243,15 +243,15 @@ def getTilePropertiesByLayer(self, layer):
props.append((gid, self.tile_properties[gid]))
except:
continue
-
+
return props
def registerGID(self, real_gid, flags=0):
"""
used to manage the mapping of GID between the tmx data and the internal
data.
-
+
number returned is gid used internally
"""
@@ -282,7 +282,7 @@ def mapGID(self, real_gid):
except KeyError:
return None
except TypeError:
- msg = "GID's must be an integer"
+ msg = "GIDs must be an integer"
raise TypeError, msg
@@ -356,8 +356,8 @@ def getTileLayerOrder(self):
def visibleTileLayers(self):
"""
Returns a list of TileLayer objects that are set 'visible'.
-
- Layers have their visivility set in Tiled. Optionally, you can over-
+
+ Layers have their visibility set in Tiled. Optionally, you can over-
ride the Tiled visibility by creating a property named 'visible'.
"""
@@ -418,7 +418,7 @@ def parse(self, node):
else:
msg = "Found external tileset, but cannot handle type: {0}"
raise Exception, msg.format(self.source)
-
+
self.set_properties(node)
# since tile objects [probably] don't have a lot of metadata,
@@ -449,7 +449,7 @@ def __init__(self, parent, node):
self.name = None
self.opacity = 1.0
self.visible = True
-
+
self.parse(node)
@@ -502,7 +502,7 @@ def parse(self, node):
elif compression:
msg = "TMX compression type: {0} is not supported."
raise Exception, msg.format(str(attr["compression"]))
-
+
# if data is None, then it was not decoded or decompressed, so
# we assume here that it is going to be a bunch of tile elements
# TODO: this will probably raise an exception if there are no tiles
@@ -514,13 +514,13 @@ def get_children(parent):
next_gid = get_children(data_node)
elif data:
- # data is a list of gid's. cast as 32-bit ints to format properly
+ # data is a list of gids. cast as 32-bit ints to format properly
# create iterator to efficiently parse data
next_gid=imap(lambda i:unpack("<L", "".join(i))[0], group(data, 4))
# using bytes here limits the layer to 256 unique tiles
# may be a limitation for very detailed maps, but most maps are not
- # so detailed.
+ # so detailed.
[ self.data.append(array.array("B")) for i in xrange(self.height) ]
for (y, x) in product(xrange(self.height), xrange(self.width)):
@@ -599,7 +599,7 @@ def parse(self, node):
if x > x2: x2 = x
if y < y1: y1 = y
if y > y2: y2 = y
- self.width = abs(x1) + abs(x2)
+ self.width = abs(x1) + abs(x2)
self.height = abs(y1) + abs(y2)
polyline = node.find('polyline')
@@ -612,7 +612,7 @@ def parse(self, node):
if x > x2: x2 = x
if y < y1: y1 = y
if y > y2: y2 = y
- self.width = abs(x1) + abs(x2)
+ self.width = abs(x1) + abs(x2)
self.height = abs(y1) + abs(y2)
View
@@ -87,9 +87,9 @@
I have been intentionally not including a module rendering utility since
rendering a map will have different requirements for every situation. However,
-I can appreciate that some poeple won't understand how it works unless they see
+I can appreciate that some people won't understand how it works unless they see
it, so I am including a sample map and viewer. It includes a scrolling/zooming
-renderer. They are for demonstation purposes, and may not be suitable for all
+renderer. They are for demonstration purposes, and may not be suitable for all
projects. Use at your own risk.
I've also included a copy of this loader that may work with python 3.x. I
@@ -117,7 +117,7 @@
When you want to draw tiles, you simply call "getTileImage":
- >>> image = tmxdata.getTileImage(x, y, layer)
+ >>> image = tmxdata.getTileImage(x, y, layer)
>>> screen.blit(position, image)
@@ -148,7 +148,7 @@
* The Tiled "properties" have reserved names.
If you use "properties" for any of the following object types, you cannot use
-any of theese words as a name for your property. A ValueError will be raised
+any of these words as a name for your property. A ValueError will be raised
if there are any conflicts.
As of 0.8.1, these values are:
@@ -308,7 +308,7 @@ def handle_transformation(tile, flags):
colorkey = None
if t.trans:
- colorkey = pygame.Color("#{0}".format(t.trans))
+ colorkey = pygame.Color("#{0}".format(t.trans))
# i dont agree with margins and spacing, but i'll support it anyway
# such is life. okay.jpg
View
@@ -27,7 +27,7 @@
Pygame: test colorkey transparency
Optimized for maps that do not make heavy use of tile
- properties. If i find that it is used a lot then i can rework
+ properties. If I find that it is used a lot then I can rework
it for better performance.
======================================================================
@@ -40,7 +40,7 @@
When you want to draw tiles, you simply call "get_tile_image":
- >>> image = tiledmap.get_tile_image(x, y, layer)
+ >>> image = tiledmap.get_tile_image(x, y, layer)
>>> screen.blit(position, image)
@@ -102,7 +102,7 @@ def __init__(self):
self.width = 0
self.height = 0
self.tilewidth = 0
- self.tileheight = 0
+ self.tileheight = 0
def get_tile_image(self, x, y, layer):
"""
@@ -153,8 +153,8 @@ def getTileImages(self, r, layer):
return a group of tiles in an area
expects a pygame rect or rect-like list/tuple
- usefull if you don't want to repeatedly call get_tile_image
- probably not the most effecient way of doing this, but oh well.
+ useful if you don't want to repeatedly call get_tile_image
+ probably not the most efficient way of doing this, but oh well.
"""
raise NotImplementedError
@@ -217,7 +217,7 @@ def __init__(self):
self.name = None
self.opacity = 1.0
self.visible = 1
-
+
class TiledObjectGroup(TiledElement):
def __init__(self):
TiledElement.__init__(self)
@@ -252,7 +252,7 @@ def load_tmx(filename):
from xml.dom.minidom import parse
from itertools import tee, islice, chain
- from collections import defaultdict
+ from collections import defaultdict
from struct import unpack
import array, os
@@ -283,7 +283,7 @@ def load_tmx(filename):
"y": int,
"value": str,
}
-
+
def pairwise(iterable):
# return a list as a sequence of pairs
a, b = tee(iterable)
@@ -324,7 +324,7 @@ def get_properties(node):
# get vlues of the properties element, if any
d.update(parse_properties(node))
-
+
return d
def set_properties(obj, node):
@@ -349,7 +349,7 @@ def get_attributes(node):
return d
def decode_gid(raw_gid):
- # gid's are encoded with extra information
+ # gids are encoded with extra information
# as of 0.7.0 it determines if the tile should be flipped when rendered
flags = 0
@@ -401,7 +401,7 @@ def parse_tileset(node, firstgid=None):
tileset.firstgid = firstgid
# since tile objects probably don't have a lot of metadata,
- # we store it seperately from the class itself
+ # we store it separately from the class itself
for child in node.childNodes:
if child.nodeName == "tile":
p = get_properties(child)
@@ -439,7 +439,7 @@ def parse_tileset(node, firstgid=None):
y, r = divmod(attr["height"], tileset.tileheight)
tileset.lastgid = tileset.firstgid + x + y
-
+
return tileset, tiles
@@ -470,7 +470,7 @@ def parse_layer(tilesets, node):
elif not attr["encoding"] is None:
raise Exception("TMX encoding type: " + str(attr["encoding"]) + " is not supported.")
-
+
if attr["compression"] == "gzip":
from io import BytesIO
import gzip
@@ -479,7 +479,7 @@ def parse_layer(tilesets, node):
elif not attr["compression"] is None:
raise Exception("TMX compression type: " + str(attr["compression"]) + " is not supported.")
-
+
# if data is None, then it was not decoded or decompressed, so
# we assume here that it is going to be a bunch of tile elements
if attr["encoding"] == next_gid is None:
@@ -496,7 +496,7 @@ def u(i): return unpack("<L", bytes(i))[0]
gids = [ i.firstgid for i in tilesets ]
- # fill up our 2D array of gid's.
+ # fill up our 2D array of gids.
for y in range(layer.height):
# store as 16-bit ints, since we will never use enough tiles to fill a 32-bit int
@@ -557,7 +557,7 @@ def load_pygame(filename):
tile_size = (t.tilewidth, t.tileheight)
# some tileset images may be slightly larger than the tiles area
- # ie: may include a banner, copyright, ect. this compensates for that
+ # ie: may include a banner, copyright, etc. this compensates for that
for y in range(0, int(h / t.tileheight) * t.tileheight, t.tileheight):
for x in range(0, int(w / t.tilewidth) * t.tilewidth, t.tilewidth):
@@ -572,7 +572,7 @@ def load_pygame(filename):
# make a unique id for this image, not sure if this is the best way, but it works
key = pygame.image.tostring(tile, "RGBA")
-
+
# make sure we don't have a duplicate tile
try:
tile = cache[key]
Oops, something went wrong.

0 comments on commit dca385b

Please sign in to comment.