Forum
>>
Principianti
>>
Aiuto
Pagina: 1
Esegui il login per scrivere una risposta.
Pagina: 1
|
Scritto da Tal |
2019-05-11 18:55:05 - Aiuto
|
|
Sto creando di creare 'Schacchi' in Python, usando la librearie 'Pyglet'.
Ho un problema in una di questo 2 funzioni, o almeno credo perche le pedine vengono disegnate in posizioni sbagliate -(es. self.cell1 in questo sito appare come self.cell1?) def grid_to_pos(self):
# position = [x, y]
# 'x' axis
if self.cell0 == 1:
self.position0 = 50
elif self.cell0 == 2:
self.position0 = 100
elif self.cell0 == 3:
self.position0 = 150
elif self.cell0 == 4:
self.position0 = 200
elif self.cell0 == 5:
self.position0 = 250
elif self.cell0 == 6:
self.position0 = 300
elif self.cell0 == 7:
self.position0 = 350
elif self.cell0 == 8:
self.position0 = 400
# 'y' axis
if self.cell1 == 1:
self.position1 = 400
elif self.cell1 == 2:
self.position1 = 350
elif self.cell1 == 3:
self.position1 = 300
elif self.cell1 == 4:
self.position1 = 250
elif self.cell1 == 5:
self.position1 = 200
elif self.cell1 == 6:
self.position1 = 150
elif self.cell1 == 7:
self.position1 = 100
elif self.cell1 == 8:
self.position1 = 50
return self.position # Return a position [cell_x, cell_y] = es[5, 8]
def pos_to_grid(self):
debug = False
cell = []
if debug is True:
print('-Initial value' + str(self.position))
# x axis
if self.position0 == 400:
self.cell0 = 8
elif self.position0 == 350:
self.cell0 = 7
elif self.position0 == 300:
self.cell0 = 6
elif self.position0 == 250:
self.cell0 = 5
elif self.position0 == 200:
self.cell0 = 4
elif self.position0 == 150:
self.cell0 = 3
elif self.position0 == 100:
self.cell0 = 2
elif self.position0 == 50:
self.cell0 = 1
# y axis
if self.position1 == 400:
self.cell1 = 8
elif self.position1 == 350:
self.cell1 = 7
elif self.position1 == 300:
self.cell1 = 6
elif self.position0 == 250:
self.cell1 = 5
elif self.position1 == 200:
self.cell1 = 4
elif self.position1 == 150:
self.cell1 = 3
elif self.position1 == 100:
self.cell1 = 2
elif self.position1 == 50:
self.cell1 = 1
if debug is True:
print('-Final value:' + str(self.cell))
return self.cell
Ho anche caricato i file .py completi in caso vi servano. Per far funzionare il gioco vi serviranno pure le varie immagini e saro' piu che felici di mandarvele. Grazie a tutti --- Ultima modifica di Tal in data 2019-05-11 19:00:02 --- --- Ultima modifica di Tal in data 2019-05-11 19:00:43 --- |
Pagina: 1
Esegui il login per scrivere una risposta.
