-
Notifications
You must be signed in to change notification settings - Fork 1
/
listing3-5_training.py
44 lines (33 loc) · 1.07 KB
/
listing3-5_training.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
#!/usr/bin/env python
# coding: utf-8
# Spacewalk
# Personal work following the book “Mission Python” (Sean McManus)
# pgzrun import (+ pgzrun.go() command) makes the code running
# when calling it using the python/python3 command.
import pgzrun
room_map = [ [1, 1, 1, 1, 1, 1, 1, 1, 1],
[1, 1, 0, 0, 0, 0, 0, 1, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 1, 1, 0, 0, 0, 0],
[1, 0, 0, 0, 1, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 0, 0, 1],
[1, 1, 1, 0, 0, 0, 1, 1, 1],
]
# Window Size
WIDTH = 800
HEIGHT = 800
top_left_x = 100
top_left_y = 150
DEMO_OBJECTS = [images.floor, images.pillar]
room_height = 9
room_width = 9
def draw():
for y in range(room_height):
for x in range(room_width):
image_to_draw = DEMO_OBJECTS[room_map[y][x]]
screen.blit(image_to_draw,
(top_left_x + (x * 30),
top_left_y + (y * 30) - image_to_draw.get_height()))
pgzrun.go()