Ich werde ein Python-Spiel mit einem Modul namens Grafik erstellen. Ich habe ein Board mit Eis erstellt und ich bin verwirrt, wie man die Position für den Spieler am Anfang erstellt. Link zu der Grafikmodule: http://mcsp.wartburg.edu/zelle/python/graphics.py Hier ist mein Code:Icebreaker Spiel python
from graphics import *
from random import *
column, row = 7, 10
WIN_W, WIN_H = 450, 315
WIN_SZ, GAP = 40, 5
COLORS = [ 'blue', 'white']
player = 'X'
win = None
ices = []
def draw_ice(x, y):
global ices
left = GAP + x* (WIN_SZ+GAP)
top = GAP + y* (WIN_SZ+GAP)
r = Rectangle(Point(left, top), Point(left+WIN_SZ, top+WIN_SZ))
ices[x][y].append(r)
bit = randint(1,1)
ices[x][y].append(bool(bit))
ices[x][y][0].setFill(COLORS[bit])
ices[x][y][0].draw(win)
def draw_ices():
for i in range(row):
ices.append([])
for j in range(column):
ices[i].append([])
draw_ice(i, j)
def MS1():
global win
win = GraphWin("Icebreaker", WIN_W, WIN_H)
draw_ices()
while True:
pt = win.getMouse()
x = int((pt.x - GAP)/(WIN_SZ + GAP))
y = int((pt.y - GAP)/(WIN_SZ + GAP))
print(str((pt.x, pt.y)) + ' --> ' + str((x, y)))
ices[x][y][1] = not ices[x][y][0]
ices[x][y][0].setFill(COLORS[ices[x][y][1]])
position in the beginning MS1()
sagen sich 'X' ist der rote Kreis und 'O' ist der blaue Kreis.
Können Sie klären, was die tatsächliche die Frage ist? –
Ich möchte wissen, wie man eine Funktion erstellt, die für die anfängliche Spielerposition –
Willkommen bei StackOverflow. Bitte lesen und befolgen Sie die Buchungsrichtlinien in der Hilfe. [zum Thema] (http://stackoverflow.com/help/on-topic) und [how to ask] (http://stackoverflow.com/help/how-to-ask) gilt hier. StackOverflow ist kein Design-, Codierungs-, Recherche- oder Lernprogramm. – Prune