import arcade
import json

cards = list()
screen = (1280,768)

class Tile(arcade.Sprite):
  ls = arcade.SpriteList()
  def __init__(self,c):
    super().__init__('./assets/blank.png', scale=1.0)
    self.title = c['title']
    self.text = arcade.Text(self.title,screen[0]//2,screen[1]//2,(0,0,0))
    self.position = (screen[0]//2,screen[1]//2)
    Tile.ls.append(self)
    

class MainView(arcade.View):
  def __init__(self):
    super().__init__()
    #self.background = arcade.load_texture("./assets/pole.png")
    with open('cards.json','r',encoding='utf-8') as f:
      cards = json.loads(f.read())
    for c in cards:
      Tile(c)

  def on_draw(self):
    self.clear((100,100,200))
    Tile.ls.draw()

if __name__ == '__main__':
  window = arcade.Window(fullscreen=True)
  screen = (window.width,window.height)
  window.show_view(MainView())
  arcade.run()
