[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Free Graphic Tileset / Automatic Use of "Coast" Tiles
Greg Ewing wrote:
Kris Schnee wrote:
What if I assumed that "sand" in slot (1.0,1.0) meant that there was
sand at _that exact point_?
That's an equivalent way of thinking about it. Use
whichever works best for you.
Got it! Still need to do bookkeeping and image transformation to use the
full tileset, but I think the gist of it is working. I'll put the key
part of the code at the bottom for anyone interested.
Another possibility would be not to use tiles at all,
but render the landscape with OpenGL and blend between
different textures. As a bonus, you'd have a head start
on the 3D version of your game. :-)
Uh-huh. 8) Several times I've tried using one 3D engine or another,
including two homebrew OpenGL systems:
http://kschnee.xepher.net/pics/bluecolony01.jpg
http://kschnee.xepher.net/pics/061204scurvy.jpg
And Soya, and Ogre3D... In each case there was some snag or other, and
it became clear that working on my own it would be too complicated to
"do 3D."
Kris
<code>
def SetZoneData(self,data):
"""Accept a set of tile data from a worldsim,
converting it to data on which tiles to draw where.
There are 1000x1000 data points on what terrain is where.
I convert that to a 999x999 set of data points on what _tile_ to
draw where.
"tileset" is a first pass at listing some usable tiles."""
TERRAINS =
["water","coral","sand","rock","dirt","grass","wood","lavarock","lava"]
tileset = {("grass","grass","grass","grass"):self.tiles["grass"],
("water","water","water","water"):self.tiles["water"],
("sand","sand","grass","grass"):self.tiles["sand0grass0s"],
("sand","sand","sand","sand"):self.tiles["sand0sand0c"],
("grass","grass","water","grass"):self.tiles["water0grass0ne"],
("water","grass","grass","grass"):self.tiles["grass0water0ne"]
}
self.tile_data = []
for y in range(0,999):
for x in range(0,999):
terrains_around =
(TERRAINS[data[y*1000+x]],TERRAINS[data[y*1000+x+1]],
TERRAINS[data[(y+1)*1000+x]],TERRAINS[data[(y+1)*1000+x+1]])
## print "Terrains around "+str((x,y))+":
"+str(terrains_around)
tile = tileset.get(terrains_around,self.tiles["void"])
## print "Resulting tile: "+str(tile)
self.tile_data.append(tile)
</code>