From: Stan_Lewry Date: Tue, 20 Jul 2021 17:24:56 +0000 (+0100) Subject: Render tiles that have been seen previously but are not currently visible with a... X-Git-Url: https://stanlewry.com/index.cgi?a=commitdiff_plain;h=e4f31a8682b76d3458b8379adfe2dd13044ab6a6;p=pyroguelike.git Render tiles that have been seen previously but are not currently visible with a darkened effect. --- diff --git a/Algorithm.py b/Algorithm.py index d47216f..090d05b 100644 --- a/Algorithm.py +++ b/Algorithm.py @@ -77,6 +77,7 @@ def line(x0, y0, x1, y1): while x != x1: if x in range(0, World.worldWidth - 1) and y in range (0, World.worldHeight - 1) and not World.world[int(y)][int(x)].containsSolid(): World.world[int(y)][int(x)].visible = True + World.world[int(y)][int(x)].seen = True Debug.debugRects.append((x, y, (255, 0, 0))) err -= dy if err < 0: @@ -90,6 +91,7 @@ def line(x0, y0, x1, y1): while y != y1: if x in range(0, World.worldWidth - 1) and y in range (0, World.worldHeight - 1) and not World.world[int(y)][int(x)].containsSolid(): World.world[int(y)][int(x)].visible = True + World.world[int(y)][int(x)].seen = True Debug.debugRects.append((x, y, (255, 0, 0))) err -= dx if err < 0: @@ -99,4 +101,5 @@ def line(x0, y0, x1, y1): else: break World.world[int(y)][int(x)].visible = True + World.world[int(y)][int(x)].seen = True Debug.debugRects.append((x, y, (255, 0, 0))) diff --git a/Assets/doomSheet.png b/Assets/doomSheet.png index 08a709b..d6964d0 100644 Binary files a/Assets/doomSheet.png and b/Assets/doomSheet.png differ diff --git a/GameObject.py b/GameObject.py index 95d191e..be12156 100644 --- a/GameObject.py +++ b/GameObject.py @@ -29,6 +29,7 @@ class WorldCell(): def __init__(self): self.objects = [] # order this list somehow to get Z self.visible = True + self.seen = False def containsSolid(self): return any(ob.solid for ob in self.objects) \ No newline at end of file diff --git a/Renderer.py b/Renderer.py index 210a58c..1662461 100644 --- a/Renderer.py +++ b/Renderer.py @@ -23,7 +23,7 @@ class Renderer: for y in range(World.worldHeight): for x in range(World.worldWidth): - if (World.world[y][x].visible): + if (World.world[y][x].seen): for gameObj in World.world[y][x].objects: worldX = (gameObj.worldX * actualWidth) - (actualWidth / 2) worldY = (gameObj.worldY * actualHeight) - (actualHeight / 2) @@ -34,6 +34,18 @@ class Renderer: actualWidth, actualHeight)) + if not World.world[y][x].visible: + gameObj = World.world[y][x].objects[0] + worldX = (gameObj.worldX * actualWidth) - (actualWidth / 2) + worldY = (gameObj.worldY * actualHeight) - (actualHeight / 2) + tCoord = Texture.spriteDict["prev_seen"] + self.screen.blit(sheet, + (worldX - screenTopX, worldY - screenTopY), + (tCoord[0] * actualWidth, + tCoord[1] * actualHeight, + actualWidth, + actualHeight)) + worldX = (player.worldX * actualWidth) - (actualWidth / 2) worldY = (player.worldY * actualHeight) - (actualHeight / 2) self.screen.blit(sheet, (worldX - screenTopX, worldY - screenTopY), diff --git a/Texture.py b/Texture.py index 64987e2..c2a2bf4 100644 --- a/Texture.py +++ b/Texture.py @@ -23,7 +23,8 @@ spriteDict = { "wall_slime" : (4, 1), "wall_side" : (5, 1), "floor_tile" : (0, 2), - "floor_panels" : (1, 2) + "floor_panels" : (1, 2), + "prev_seen" : (0, 3) } # spriteDict = { # "player" : (1, 19), diff --git a/Writeup/vision_previously_seen.png b/Writeup/vision_previously_seen.png new file mode 100644 index 0000000..b1fcaaf Binary files /dev/null and b/Writeup/vision_previously_seen.png differ