Je suis en train de développer un rubik's cube en python.
Mais j'ai un gros problème à l'affichage d'une face du cube...
Voici mon code:
from random import shuffle
import graphics
graphics.init()
FACES=["red", "yellow", "blue", "orange", "white", "green"]
FACESNB=6
SIZE=3, 3
def makeCube():
cube=[]
for x in range(FACESNB):
large=[FACES[x]]*SIZE[0]
face=[large]*SIZE[1]
cube.append(face)
return cube
def showRepr(cube):
for x in cube:
for y in x:
for z in y:
print(z, end=" ")
print()
print("---------------------------")
def shuffleCube(cube):
shuffle(cube[0][0])
return cube
cube=makeCube()
showRepr(cube)
#print("SHUFFLINNG...")
#cube=shuffleCube(cube)
#showRepr(cube)
graphics.blits()
graphics.show(cube[0])
while not graphics.exit:
#graphics.show(cube[0])
graphics.update()
Ici, graphics.py :
import pygame
import colors
from time import sleep
SIZE=500, 500
CASEX=50
CASEY=50
BACK=colors.WHITE
exit=False
def init():
global screen
pygame.init()
screen=pygame.display.set_mode(SIZE)
pygame.display.set_caption("Voukii")
def show(cube):
row=1
column=1
for y in cube:
for z in y:
case(z, column, row)
column+=1
row+=1
column=1
def blits():
screen.fill(BACK)
def case(color, x, y):
print(color, x, y)
#print((((x-1)*CASEX, (y-1)*CASEY), (x*CASEX, y*CASEY)))
pygame.draw.rect(screen, eval("colors."+color.upper()), ((x*CASEX, y*CASEY), ((x*CASEX)+CASEX, (y*CASEY)+CASEY)))
pygame.display.flip()
sleep(0.5)
def update():
global exit
for event in pygame.event.get():
if event.type==pygame.QUIT:
exit=True
pygame.quit()
pygame.display.flip()
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
Linaki, l'excellence garantie !
My website
Linaki, l'excellence garantie !
My website