Python object models

This commit is contained in:
John McCardle 2023-03-04 23:18:21 -05:00
parent 257aa3c3d2
commit a53ae29467
3 changed files with 45 additions and 1 deletions

30
src/scripts/Grid.py Normal file
View File

@ -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}))>"

4
src/scripts/TestScene.py Normal file
View File

@ -0,0 +1,4 @@
print("TestScene imported")
def start():
print("TestScene.start called")

View File

@ -4,6 +4,9 @@ class Caption:
self.textsize = textsize
self.color = color
def __repr__(self):
return f"<Caption text={self.text}, textsize={self.textsize}, color={self.color}>"
class Button:
def __init__(self, x, y, w, h, bgcolor, textcolor, text, actioncode):
self.x = x
@ -15,12 +18,19 @@ class Button:
self.text = text
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:
def __init__(self, tex_index, x, y):
def __init__(self, tex_index, sprite_index, x, y):
self.tex_index = tex_index
self.sprite_index = sprite_index
self.x = x
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:
def __init__(self, title, x, y, w, h, bgcolor, visible=False):
self.title = title