カタン、Pythonでは?―― トークンの位置がうまく行かない
さて、トークンの位置を19個計算したので、これでいいのかどうか、とりあえず〇でもおいてみるか、と実験。
import numpy as np
import pygame
tile12 = np.load('tileA.npy')
tt24 = np.array([0,60])
tt25 = tile12[:,0,:]
tt26 = tt25+tt24
gray = (237, 237, 237)
white = (255, 255, 255)
pygame.init()
screen = pygame.display.set_mode ( ( 1280, 720 ) )
myclock = pygame.time.Clock()
screen.fill(gray)
for tok2 in tt26:
pygame.draw.circle(screen, white, tok2, 20)
pygame.display.flip()
endflag = 0
while endflag ==0:
for event in pygame.event.get():
if event.type == pygame.QUIT: endflag = 1
myclock.tick(60)
pygame.quit()
これで、うまく行くはずだったが、なぜかエラーが出る。
TypeError: integer argument expected, got float
問題は、pygame.draw.circle(screen, white, tok2, 20) のところで起きてるらしい。
整数じゃなきゃいけないのに、小数だからダメ、ということらしい。
screen と white は整数だ。tok2はたしかに小数が混じってる。でも、位置だよ。なんで整数じゃなきゃいけないの?
ためしに、整数でやってみよう。
import numpy as np
import pygame
tt25 = np.array([[534, 260], [603, 260], [673, 260]])
tt24 = np.array([0,60])
tt26 = tt25+tt24
(後は同じ)
あれ、一応、できた。
うーん、polygonでは小数があってもできたのに、circleだと整数しか受け付けない?
どうしよう。