init python:
import math,os
os.environ['SDL_VIDEO_CENTERED'] = '1'
cellx = 61
celly = 52
xdisp = int(0.75 * float(cellx))
ydisp = int((math.sqrt(3)*float(celly)*math.tan(math.pi/6))/2)
class Cell():
def __init__(self,l,c,r):
x = 0
y = 0
x += l*xdisp
y += l*ydisp
y += celly*c
x += r*xdisp
y -= r*ydisp
self.abs = x,y
self.rel = l,c,r
self.index = "%s%s%s"%(l,c,r)
self.text = "_%s%s%s_"%(l,c,r)
def show(self):
renpy.show(self.index,what=Image("mov_idle.png"),at_list=[Position(xpos=self.abs[0],ypos=self.abs[1],xanchor=0.5,yanchor=0.5)])
renpy.show(self.text,what=Text("%s %s %s"%(self.rel[0],self.rel[1],self.rel[2])),at_list=[Position(xpos=self.abs[0],ypos=self.abs[1],xanchor=0.5,yanchor=0.5)])
class Grid():
def __init__(self,x,y):
self.db = dict()
for j in range(y):
l,c,r = 0,j,0
for i in range(x):
#show(l,c,r)
self.db["%s%s%s"%(l,c,r)] = Cell(l,c,r)
if i%2 == 0:
r+=1
else:
l+=1
def show(self):
for key in self.db:
self.db[key].show()
def overlay(self):
for key in self.db:
cell = self.db[key]
ui.at(Position(xpos=cell.abs[0],ypos=cell.abs[1],xanchor=0.5,yanchor=0.5))
ui.imagebutton("mov_idle.png",im.MatrixColor("mov_idle.png",im.matrix.invert()),clicked=ui.returns(cell.rel))
ui.at(Position(xpos=cell.abs[0],ypos=cell.abs[1],xanchor=0.5,yanchor=0.5))
ui.text("%s %s %s"%(cell.rel[0],cell.rel[1],cell.rel[2]))
def exit_button():
ui.at(Position(xpos=0.0,ypos=1.0,xanchor=0.0,yanchor=1.0))
ui.textbutton("X",clicked=ui.returns('exit'))
label start:
python:
grid = Grid(19,13)
#grid.show()
config.overlay_functions.append(grid.overlay)
config.overlay_functions.append(exit_button)
ui.interact()
renpy.quit()
0 Комментариев
Рекомендуемые комментарии
Комментариев нет