-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackround.py
More file actions
112 lines (92 loc) · 4.6 KB
/
backround.py
File metadata and controls
112 lines (92 loc) · 4.6 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import pygame
import time
from player import *
from constant import *
import sys
img = pygame.image.load("grass.png").convert()
floor_one = pygame.image.load("floor_one.bmp").convert()
wall_bottom = pygame.image.load("wall_bottom.bmp").convert()
wall_right = pygame.image.load("wall_right.bmp").convert()
wall_top = pygame.image.load("wall_top.bmp").convert()
wall_left =pygame.image.load("wall_left.bmp").convert()
class Tile(pygame.sprite.Sprite):
def __init__(self, image, is_solid):
pygame.sprite.Sprite.__init__(self)
self.image = image
self.rect = self.image.get_rect()
self.solid_state = is_solid
def update(self):
self.rect.x += -player.speedx
self.rect.y += -player.speedy
level_one = [[4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4],
[5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5],
[5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5],
[5,1,1,1,3,2,2,2,2,2,2,2,2,2,5,1,1,3,2,2,2,2,2,2,2,2,2,1,1,1,5],
[5,1,1,1,3,1,1,1,1,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,1,1,5,1,1,1,5],
[5,1,1,1,3,1,1,1,1,1,1,1,1,1,5,1,1,3,1,1,1,1,1,1,1,1,5,1,1,1,5],
[5,1,1,1,3,1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,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0],
[5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0],]
for y, row in enumerate(level_one):
for x, terrain_num in enumerate(row):
if terrain_num == 0:
None
elif terrain_num == 1:
tile = Tile(floor_one, False)
tile.rect.center = (x * 64, y * 64)
tile_group.add(tile)
elif terrain_num == 2:
tile = Tile(wall_bottom, True)
tile.rect.center = (x * 64, y * 64)
tile_group.add(tile)
elif terrain_num == 3:
tile = Tile(wall_right, True)
tile.rect.center = (x * 64, y * 64)
tile_group.add(tile)
elif terrain_num == 4:
tile = Tile(wall_top, True)
tile.rect.center = (x * 64, y * 64)
tile_group.add(tile)
elif terrain_num == 5:
tile = Tile(wall_left, True)
tile.rect.center = (x * 64, y * 64)
tile_group.add(tile)
#for y in range(40):
# for x in range(40):
# tile = Tile(img)
# tile.rect.center = (x * 70, y * 70)
# tile_group.add(tile)
#backround_img = pygame.image.load("backround.png").convert()
#class Backround(pygame.sprite.Sprite):
# def __init__(self):
# pygame.sprite.Sprite.__init__(self)
# self.image = pygame.transform.scale(backround_img, (6400, 4800))
# self.rect = self.image.get_rect()
# def update(self):
# self.rect.x += -player.speedx
# self.rect.y += -player.speedy
#backround = Backround()
#backround_list.add(backround)