#!python # -*- mode: python; Encoding: utf-8; coding: utf-8 -*- # Last updated: <2019/02/06 08:55:21 +0900> """ Pyxel Hello world. Windows10 x64 + Python 3.7.1 32bit """ import pyxel class App: def __init__(self): w, h = 160, 120 pyxel.init(w, h, caption="Hello World", fps=60) pyxel.load("assets/helloworld.pyxel") self.x = pyxel.width / 2 self.y = pyxel.width / 2 self.counter = 0 pyxel.run(self.update, self.draw) def update(self): if pyxel.btnp(pyxel.KEY_Q): pyxel.quit() if pyxel.btn(pyxel.KEY_LEFT): self.x -= 1 if pyxel.btn(pyxel.KEY_RIGHT): self.x += 1 if pyxel.btn(pyxel.KEY_UP): self.y -= 1 if pyxel.btn(pyxel.KEY_DOWN): self.y += 1 self.counter += 1 def draw(self): # clear screen pyxel.cls(0) # draw image x, y = self.x - 8, self.y - 8 u, v, w, h = 0, 0, 16, 16 img = 0 colkey = 10 pyxel.blt(x, y, img, u, v, w, h, colkey) # draw text col = self.counter % 16 pyxel.text(56, 16, "Hello World!", col) App()