-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpyxel_sample.py
More file actions
44 lines (34 loc) · 1.08 KB
/
pyxel_sample.py
File metadata and controls
44 lines (34 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pyxel
class TextApp:
def __init__(self):
pyxel.init(160, 120, title="Mouse Checker")
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(7)
pyxel_table = [hex(x) for x in pyxel.colors.to_list()]
y = 3
for idx, color in enumerate(pyxel_table):
pyxel.text(55, y, color, idx)
y += 7
class ImageApp:
def __init__(self):
pyxel.init(160, 120, title="Hello Pyxel")
pyxel.load("./hamada.pyxres")
pyxel.run(self.update, self.draw)
def update(self):
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw(self):
pyxel.cls(0)
old_colors = pyxel.colors.to_list()
# pyxel.colors[8] = old_colors[5]
pyxel.colors[8] = old_colors[pyxel.frame_count % 16]
x = (pyxel.frame_count * 2) % 160
y = (int(pyxel.frame_count / 80) * 10) % 120
pyxel.blt(x, y, 0, 0, 0, 16, 16)
# pyxel.text(150, 100, f"{y}", 7)
# ImageApp()
TextApp()