-
Notifications
You must be signed in to change notification settings - Fork 1
/
listing3-5.py
42 lines (31 loc) · 931 Bytes
/
listing3-5.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
#!/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, 0, 0, 0, 1],
[1, 0, 1, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 1],
[1, 1, 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 = 7
room_width = 5
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()