Ghoulash
https://simplegametutorials.github.io/pygamezero/
ghoulash.py
1import pgzero, pgzrun
2
3bob = Actor('alien')
4
5TILE = max(bob.width, bob.height)
6TITLE = "Goulash"
7W = 8
8H = 5
9WIDTH = W * TILE
10HEIGHT = H * TILE
11
12print( dir(bob))
13
14def draw():
15 P = Rect((0, 0), (TILE, TILE))
16 C = [(0, 0, 64), (0, 32, 64)]
17 for c in range(W):
18 for r in range(H):
19 screen.draw.filled_rect(
20 Rect((c*TILE, r*TILE), (TILE, TILE)),
21 C[(c+r)%2]
22 )
23
24 bob.draw()
25
26# def update():
27# if keyboard.s: bob.y += 1 # TILE
28
29def on_key_down(key, mod, unicode):
30 print("%s, %s, %s" % (key, mod, unicode))
31 if key == keys.W: bob.y -= TILE
32 if key == keys.A: bob.x -= TILE
33 if key == keys.S: bob.y += TILE
34 if key == keys.D: bob.x += TILE
35 print(bob.pos)
36
37
38# slimearm = Actor('alien')
39# # slimearm.topright = 0, 10
40# slimearm.pos = 100, 56
41
42# WIDTH = slimearm.width - 10
43# HEIGHT = slimearm.height + 10
44
45# def draw():
46# # screen.clear()
47# screen.fill((16, 16, 28))
48# slimearm.draw()
49
50# def update():
51# slimearm.left += 2
52# if slimearm.left > WIDTH:
53# slimearm.right = 0
54
55# def on_mouse_down(pos):
56# if slimearm.collidepoint(pos):
57# set_alien_hurt()
58# else:
59# print("you missed me!")
60
61# def set_alien_hurt():
62# print("Eek!")
63# # sounds.eep.play()
64# slimearm.image = 'alien_hurt'
65# clock.schedule_unique(set_alien_normal, 1.0)
66
67# def set_alien_normal():
68# slimearm.image = 'alien'
69
70
71pgzrun.go()