とにかく画面に何か描いてみよう。
成果物
コード
import pyxel def update(): pass def draw(): pyxel.cls(0) pyxel.rect(0, 0, 64, 64, 8) # x, y, w, h, col pyxel.init(256, 256, border_width=0) pyxel.run(update, draw)
クラス化
#!/usr/bin/env python3 # coding: utf8 import pyxel class App: def __init__(self): pyxel.init(256, 256, border_width=0) pyxel.run(self.update, self.draw) def update(self): pass def draw(self): pyxel.cls(0) pyxel.rect(0, 0, 64, 64, 8) # x, y, w, h, col App()
要点
pyxel.rect(x, y, w, h, col)
要素 | 値 |
---|---|
x |
矩形の左端X軸座標 |
y |
矩形の左端Y軸座標 |
w |
矩形の幅 |
h |
矩形の高さ |
col |
パレットの色番号0 〜15 |
所感
描けた。でもこれだけじゃ、つまんない。せめて動いて欲しい。次回はアニメーション。
前回まで
- ラズパイ4Bにpyenvをインストールする(python 3.8.2)
- pyxelをインストールする(pyenv python3.8.2)
- pyxeleditorにおけるImageエディタの使い方
- pyxeleditorにおけるTileMapエディタの使い方
- pyxeleditorにおけるSoundエディタの使い方
- pyxeleditorにおけるMusicエディタの使い方
- pyxelのリソースにおける概念・制限まとめ
- pyxeleditorにおけるpyxresファイル形式まとめ
- pyxelのAPI調査
- pyxelで最小コード 窓を出す
- Pyxelで窓の境界線を消す
- 携帯ゲーム機の解像度
対象環境
- Raspbierry pi 4 Model B
- Raspbian buster 10.0 2019-09-26 ※
- bash 5.0.3(1)-release
- pyxel 1.3.1
$ uname -a Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux