Python object models
This commit is contained in:
parent
257aa3c3d2
commit
a53ae29467
|
@ -0,0 +1,30 @@
|
||||||
|
class GridPoint:
|
||||||
|
def __init__(self, color, walkable, tilesprite, transparent, visible, discovered, color_overlay, tile_overlay, uisprite):
|
||||||
|
self.color = color
|
||||||
|
self.walkable = walkable
|
||||||
|
self.tilesprite = tilesprite
|
||||||
|
self.transparent = transparent
|
||||||
|
self.visible = visible
|
||||||
|
self.discovered = discovered
|
||||||
|
self.color_overlay = color_overlay
|
||||||
|
self.tile_overlay = tile_overlay
|
||||||
|
self.uisprite = uisprite
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<GridPoint {self.color}, {self.tilesprite}/{self.uisprite} {'W' if self.walkable else '-'}{'T' if self.transparent else '-'}{'V' if self.visible else '-'}{'D' if self.discovered else '-'} {self.color_overlay}/{self.tile_overlay}>"
|
||||||
|
|
||||||
|
class Grid:
|
||||||
|
def __init__(self, title, gx, gy, gs, x, y, w, h):
|
||||||
|
self.title = title
|
||||||
|
self.grid_x = gx
|
||||||
|
self.grid_y = gy
|
||||||
|
self.grid_size = gs
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
self.w = w
|
||||||
|
self.h = h
|
||||||
|
|
||||||
|
self.points = []
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<Grid {self.grid_x}x{self.grid_y}, grid_size={self.grid_size}, (({self.x},{self.y}), ({self.w}, {self.h}))>"
|
|
@ -0,0 +1,4 @@
|
||||||
|
print("TestScene imported")
|
||||||
|
|
||||||
|
def start():
|
||||||
|
print("TestScene.start called")
|
|
@ -4,6 +4,9 @@ class Caption:
|
||||||
self.textsize = textsize
|
self.textsize = textsize
|
||||||
self.color = color
|
self.color = color
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<Caption text={self.text}, textsize={self.textsize}, color={self.color}>"
|
||||||
|
|
||||||
class Button:
|
class Button:
|
||||||
def __init__(self, x, y, w, h, bgcolor, textcolor, text, actioncode):
|
def __init__(self, x, y, w, h, bgcolor, textcolor, text, actioncode):
|
||||||
self.x = x
|
self.x = x
|
||||||
|
@ -15,12 +18,19 @@ class Button:
|
||||||
self.text = text
|
self.text = text
|
||||||
self.actioncode = actioncode
|
self.actioncode = actioncode
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<Button ({self.x}, {self.y}, {self.w}, {self.h}), bgcolor={self.bgcolor}, textcolor={self.textcolor}, actioncode={self.actioncode}>"
|
||||||
|
|
||||||
class Sprite:
|
class Sprite:
|
||||||
def __init__(self, tex_index, x, y):
|
def __init__(self, tex_index, sprite_index, x, y):
|
||||||
self.tex_index = tex_index
|
self.tex_index = tex_index
|
||||||
|
self.sprite_index = sprite_index
|
||||||
self.x = x
|
self.x = x
|
||||||
self.y = y
|
self.y = y
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<Sprite tex_index={self.tex_index}, self.sprite_index={self.sprite_index}, x={self.x}, y={self.y}>"
|
||||||
|
|
||||||
class UIMenu:
|
class UIMenu:
|
||||||
def __init__(self, title, x, y, w, h, bgcolor, visible=False):
|
def __init__(self, title, x, y, w, h, bgcolor, visible=False):
|
||||||
self.title = title
|
self.title = title
|
||||||
|
|
Loading…
Reference in New Issue