めぃびぃもなど

同人活動とかプログラミングとか。

Python3.6.4でPygameを動かす

Pygameを使ってゲームを作ろうとしてたら、ウィンドウにフォーカスされなくてキー入力を受け付けてくれない状態になってしまった。 python3.6を使ってて、pip install pygameって感じでpygameを入れたけどダメだった。

うーんってなってPygame公式GettingStartedを見に行ったら、

# create a virtualenv called 'anenv' and use it.
python3 -m virtualenv anenv
. ./anenv/bin/activate
# venvdotapp helps the python be a mac 'app'. So the pygame window can get focus.
python -m pip install venvdotapp
venvdotapp
python -m pip install pygame

# See if pygame works with the oo module, and the aliens example.
python -m pygame.examples.aliens

って感じで入れるといいらしい。

There are problems with virtualenv and pygame on mac, where it loses focus. It does work if you create a venv with python -m venv however.

macだとvirtualenvとpygameに問題があってフォーカスが外れるらしい。 python -m venvを使うと動くんだって。

ちゃんと動きました。 公式ページは確認しようね。。。(自戒)