Advertisement
Guest User

Tilesetdef generator

a guest
Oct 20th, 2012
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. print "This script assumes all tiles in your tileset block are the same height, will be centered horizontally, offset up by half a tile, and the tile block is left justified."
  2. tile = int(raw_input("Starting tile number: "))
  3. gridx = int(raw_input("Width a game grid space: "))
  4. gridy = int(raw_input("Height a game grid space: "))
  5. tilex = int(raw_input("Width of a tile in this tileset block: "))
  6. tiley = int(raw_input("Height of a tile in this tileset block: "))
  7. imagex = int(raw_input("Width of the tile block: "))
  8. y = int(raw_input("Top edge of the tile block: "))
  9. imagey = int(raw_input("Bottom edge of the tile block: "))
  10. x=0
  11. tileline=""
  12. imagex = imagex - (imagex % gridx)
  13. while y < imagey:
  14.     while x < imagex:
  15.         tileline = "".join(("tile=",str(tile),",",str(x),",",str(y),",",str(tilex),",",str(tiley),",",str(tilex-(gridx/2)),",",str(tiley-(gridy/2)),"\n"))
  16.         with open("tilesetdef.txt", "a") as tileset:
  17.             tileset.write(tileline)
  18.         x += tilex
  19.         tile +=1
  20.     y += tiley
  21.     x = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement