Skip to content

Instantly share code, notes, and snippets.

@timbledum
Last active November 4, 2018 02:10
Show Gist options
  • Save timbledum/4a4160f3f3329e13131a590edc28c565 to your computer and use it in GitHub Desktop.
Save timbledum/4a4160f3f3329e13131a590edc28c565 to your computer and use it in GitHub Desktop.
Sample of using new pyxel file format
import pyxel
pyxel.init(128, 128)
resources = pyxel.load("sample.pyxel")
data = {}
data["x"] = 0
data["y"] = 0
def update():
global data
if pyxel.btn(pyxel.KEY_UP):
data['y'] -= 1
if pyxel.btn(pyxel.KEY_DOWN):
data['y'] += 1
if pyxel.btn(pyxel.KEY_LEFT):
data['x'] -= 1
if pyxel.btn(pyxel.KEY_RIGHT):
data['x'] += 1
if pyxel.btnp(pyxel.KEY_Q):
pyxel.quit()
def draw():
global data
pyxel.cls(1)
pyxel.blt(
x=data['x'],
y=data['y'],
img=0,
u=0,
v=0,
w=16,
h=16,
colkey=0,
)
pyxel.bltm(
x=0,
y=64,
img=0,
tm=0,
tu=0,
tv=1,
tw=16,
th=1,
colkey=0,
)
pyxel.run(update, draw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment