All map files converted to new YAML standard.
This commit is contained in:
parent
c5029ac0fc
commit
adfb6b83f4
17 changed files with 3123 additions and 2691 deletions
88
tile.py
88
tile.py
|
@ -1,44 +1,44 @@
|
|||
from tkinter import *
|
||||
|
||||
class Tile:
|
||||
"""A representation of a tile on the display"""
|
||||
|
||||
shapes = {'circle' : 'o', 'cross' : 'x', 'triangle' : '^', 'none' : ' ',
|
||||
'square' : '#', 'vertical' : '|', 'horizontal' : '-'}
|
||||
|
||||
def __init__(self, bgroundColor, fgroundColor = 'white', fgroundShape = ' '):
|
||||
self.bgc = bgroundColor
|
||||
self.fgc = fgroundColor
|
||||
self.fgs = fgroundShape
|
||||
|
||||
def paint(self, display, x, y): #display being a canvas
|
||||
if type(display) != Canvas:
|
||||
raise TypeError('Display must be a tkinter.Canvas.')
|
||||
else:
|
||||
tag = '(' + str(int(x)) + ', ' + str(int(y)) + ')'
|
||||
display.delete(tag) #delete the old tile before creating a new one.
|
||||
if self.bgc != 'clear':
|
||||
display.create_rectangle((x*32, y*32, x*32+32, y*32+32),
|
||||
fill = self.bgc, width = 0, tags = (tag))
|
||||
if self.fgs == Tile.shapes['triangle']:
|
||||
display.create_polygon((x*32+15, y*32+2, x*32+2, y*32+30,
|
||||
x*32+30, y*32+30, x*32+16, y*32+2),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['circle']:
|
||||
display.create_oval((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['cross']:
|
||||
display.create_line((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
display.create_line((x*32+30, y*32+2, x*32+2, y*32+30),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['square']:
|
||||
display.create_rectangle((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['vertical']:
|
||||
display.create_line((x*32+16, y*32, x*32+16, y*32+32),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['horizontal']:
|
||||
display.create_line((x*32, y*32+16, x*32+32, y*32+16),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
else: pass
|
||||
from tkinter import *
|
||||
|
||||
class Tile:
|
||||
"""A representation of a tile on the display"""
|
||||
|
||||
shapes = {'circle' : 'o', 'cross' : 'x', 'triangle' : '^', 'none' : ' ',
|
||||
'square' : '#', 'vertical' : '|', 'horizontal' : '-'}
|
||||
|
||||
def __init__(self, bgroundColor, fgroundColor = 'white', fgroundShape = ' '):
|
||||
self.bgc = bgroundColor
|
||||
self.fgc = fgroundColor
|
||||
self.fgs = fgroundShape
|
||||
|
||||
def paint(self, display, x, y): #display being a canvas
|
||||
if type(display) != Canvas:
|
||||
raise TypeError('Display must be a tkinter.Canvas.')
|
||||
else:
|
||||
tag = '(' + str(int(x)) + ', ' + str(int(y)) + ')'
|
||||
display.delete(tag) #delete the old tile before creating a new one.
|
||||
if self.bgc != 'clear':
|
||||
display.create_rectangle((x*32, y*32, x*32+32, y*32+32),
|
||||
fill = self.bgc, width = 0, tags = (tag))
|
||||
if self.fgs == Tile.shapes['triangle']:
|
||||
display.create_polygon((x*32+15, y*32+2, x*32+2, y*32+30,
|
||||
x*32+30, y*32+30, x*32+16, y*32+2),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['circle']:
|
||||
display.create_oval((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['cross']:
|
||||
display.create_line((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
display.create_line((x*32+30, y*32+2, x*32+2, y*32+30),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['square']:
|
||||
display.create_rectangle((x*32+2, y*32+2, x*32+30, y*32+30),
|
||||
fill = self.fgc, width = 0, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['vertical']:
|
||||
display.create_line((x*32+16, y*32, x*32+16, y*32+32),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
elif self.fgs == Tile.shapes['horizontal']:
|
||||
display.create_line((x*32, y*32+16, x*32+32, y*32+16),
|
||||
fill = self.fgc, width = 3, tags = (tag))
|
||||
else: pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue