-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path07_colorkey_images.py
48 lines (35 loc) · 1.11 KB
/
07_colorkey_images.py
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
45
46
47
48
"""
Load an image and make the colorkey transparent.
Useful for loading sprite sheets/textures.
Kris Pritchard / @krp
"""
import pyxel
# This means that pixels of color '2' from the image
# will be made transparent, and will be the same as
# the background color.
COLORKEY_COLOR = 2
class App:
def __init__(self):
pyxel.init(256, 256)
pyxel.image(0).load(0, 0, "assets/07_colorkey.png")
pyxel.run(self.update, self.draw)
def update(self):
pass
def draw(self):
pyxel.cls(0)
# Draw some circles first
pyxel.circ(20, 20, 80, 11)
pyxel.circ(170, 70, 30, 10)
# blt arguments:
# x position = 10
# y position = 10
# img bank (0-2) = 0
# u img/texture coordinate = 0
# v img/texture coordinate = 0
# w img/texture width = 100
# v img/texture/height = 100
pyxel.blt(10, 10, 0, 0, 0, 240, 240, COLORKEY_COLOR)
pyxel.text(40, 220, 'This image demonstrates color keying.', 7)
pyxel.text(40, 230, 'Check out assets/07_colorkey.png', 7)
if __name__ == "__main__":
App()