Skip to content

Commit

Permalink
Added roofs, with corresponding fire/dragon behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
BinkyToo committed Sep 27, 2014
1 parent b4dbd97 commit 5e27750
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 5 deletions.
13 changes: 12 additions & 1 deletion Cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, groundcolor, collectablecolor):
self.temperature = 20
self.fireignitechance = 0
self.fireoutchance = 1
self.hasroof = False
if groundcolor == BLACK:
self.image = images.Wall
self.transparent = False
Expand Down Expand Up @@ -87,7 +88,7 @@ def __init__(self, groundcolor, collectablecolor):
self.solid = False
self.difficulty = 8
self.name = "forest"
self.fireignitechance = 0.18
self.fireignitechance = 0.5
self.fireoutchance = 0.1
self.top = True
elif groundcolor == DARKYELLOW:
Expand All @@ -102,6 +103,15 @@ def __init__(self, groundcolor, collectablecolor):
self.solid = False
self.difficulty = 1
self.name = "paving"
elif groundcolor == DARKPINK:
self.image = images.Floor
self.transparent = True
self.solid = False
self.difficulty = 1
self.name = "floor"
self.fireignitechance = 0.18
self.fireoutchance = 0.02
self.hasroof = True
else:
raise Exception("Unknown map color")

Expand Down Expand Up @@ -133,6 +143,7 @@ def destroy(self):
if not self.destructable:
return False
self.damaged = True
self.hasroof = False
self.name = "shattered debris"
self.collectableitem = None
self.top = False
Expand Down
2 changes: 1 addition & 1 deletion Dragon.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def addtuple(a, b, c=1):
cellmap.ignite(tile, True)
break

if not cellmap[playerpos].top and random.random() < Dragon.speed:
if not cellmap[playerpos].top and not cellmap[playerpos].hasroof and random.random() < Dragon.speed:
offset = tileoffset(self.position, playerpos, cellmap.size)
if offset[0]**2 + offset[1]**1 <= Dragon.detectionrange**2:
newdirection = list(self.direction)
Expand Down
4 changes: 2 additions & 2 deletions World.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def placeBears(number):
break
return created

self.bears = placeBears(int(self.cellmap.size[0] * self.cellmap.size[1]/2000))
self.bears = placeBears(int(self.cellmap.size[0] * self.cellmap.size[1]/3000))

def placeDragons(number):
'''Randomly add dragons to the map'''
Expand All @@ -40,7 +40,7 @@ def placeDragons(number):
pos = (random.randint(0, self.cellmap.size[0]-1), random.randint(0, self.cellmap.size[1]-1))
created.append(Dragon(pos))
return created
self.dragons = placeDragons(int(self.cellmap.size[0] * self.cellmap.size[1]/4000))
self.dragons = placeDragons(int(self.cellmap.size[0] * self.cellmap.size[1]/10000))

def moveplayer(self, x, y):
'''Move the player by (x, y), move other fauna, update world surface around player'''
Expand Down
3 changes: 2 additions & 1 deletion colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
DARKYELLOW = (127, 127, 0)
BROWN = (127, 64, 0)
DARKGREEN = (64, 127, 64)
BLUEGREY = (64, 127, 127)
BLUEGREY = (64, 127, 127)
DARKPINK = (128, 0, 128)
1 change: 1 addition & 0 deletions images.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
DeepWater = pygame.image.load("tiles/DeepWater.png").convert()
Rock = pygame.image.load("tiles/Rock.png").convert()
Paving = pygame.image.load("tiles/Paving.png").convert()
Floor = pygame.image.load("tiles/Floor.png").convert()
Grass = pygame.image.load("tiles/Grass.png").convert()
Marsh = pygame.image.load("tiles/Marsh.png").convert()
Wall = pygame.image.load("tiles/Wall.png").convert()
Expand Down
Binary file modified map/World7-ground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tiles/Dragon-Red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tiles/Floor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tiles/floor.xcf
Binary file not shown.

0 comments on commit 5e27750

Please sign in to comment.