import pyxel import math pyxel.init(200, 200) pyxel.cls(14) lineCounter = 0 distance = 20 for i in range(distance, 210 + distance, distance * 2): for j in range(distance, 210, int(distance * math.sqrt(3))): for k in range(0, 360, 60): kRadian = math.radians(k) shortLineLength = int(distance * 2 / 3 * math.sqrt(3)) if (lineCounter % 2 == 0): pyxel.line(i, j, i + shortLineLength * math.sin(kRadian), j + shortLineLength * math.cos(kRadian), 0) pyxel.line(i, j, i + distance * math.cos(kRadian), j + distance * math.sin(kRadian), 0) else: pyxel.line(i - distance, j, i - distance + shortLineLength * math.sin(kRadian), j + shortLineLength * math.cos(kRadian), 0) pyxel.line(i - distance, j, i - distance + distance * math.cos(kRadian), j + distance * math.sin(kRadian), 0) lineCounter += 1 pyxel.show()
def game_over(self): H = pyxel.height pyxel.text(5, H - 20, "YOU Lose...", pyxel.COLOR_YELLOW) pyxel.show()
from pyxel import init, line, rect, show A = [4, 7, 5, 2, 10, 5, 4, 2] # グラフデータ init(64, 64, scale=2) # 128x128画面 line(0, 60, 63, 60, 8) # グラフ下直線 for i, h in enumerate(A): rect(i * 7 + 6, 60 - h * 5, 5, h * 5, 8 + i) # 色を変え矩形描画 show()
def game_clear(self): H = pyxel.height pyxel.text(5, H - 20, "YOU WIN!!", pyxel.COLOR_YELLOW) pyxel.show()