Skip to content

Commit 53acd60

Browse files
committed
support background type: night
1 parent 1281c03 commit 53acd60

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

source/state/level.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def loadMap(self):
3232

3333
def setupBackground(self):
3434
img_index = self.map_data[c.BACKGROUND_TYPE]
35+
self.background_type = img_index
3536
self.background = tool.GFX[c.BACKGROUND_NAME][img_index]
3637
self.bg_rect = self.background.get_rect()
3738

@@ -91,7 +92,10 @@ def initPlay(self, card_list):
9192
self.drag_plant = False
9293
self.hint_image = None
9394
self.hint_plant = False
94-
self.produce_sun = True
95+
if self.background_type == c.BACKGROUND_DAY:
96+
self.produce_sun = True
97+
else:
98+
self.produce_sun = False
9599
self.sun_timer = self.current_time
96100

97101
self.removeMouseImage()
@@ -136,10 +140,10 @@ def play(self, mouse_pos, mouse_click):
136140
map_x, map_y = self.map.getRandomMapIndex()
137141
x, y = self.map.getMapGridPos(map_x, map_y)
138142
self.sun_group.add(plant.Sun(x, 0, x, y))
139-
if not self.drag_plant and mouse_pos and mouse_click[0]:
140-
for sun in self.sun_group:
141-
if sun.checkCollision(mouse_pos[0], mouse_pos[1]):
142-
self.menubar.increaseSunValue(sun.sun_value)
143+
if not self.drag_plant and mouse_pos and mouse_click[0]:
144+
for sun in self.sun_group:
145+
if sun.checkCollision(mouse_pos[0], mouse_pos[1]):
146+
self.menubar.increaseSunValue(sun.sun_value)
143147

144148
for car in self.cars:
145149
car.update(self.game_info)

0 commit comments

Comments
 (0)