Render tiles that have been seen previously but are not currently visible with a...
authorStan_Lewry <stanley.jml@gmail.com>
Tue, 20 Jul 2021 17:24:56 +0000 (18:24 +0100)
committerStan_Lewry <stanley.jml@gmail.com>
Tue, 20 Jul 2021 17:24:56 +0000 (18:24 +0100)
Algorithm.py
Assets/doomSheet.png
GameObject.py
Renderer.py
Texture.py
Writeup/vision_previously_seen.png [new file with mode: 0644]

index d47216f..090d05b 100644 (file)
@@ -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)))
index 08a709b..d6964d0 100644 (file)
Binary files a/Assets/doomSheet.png and b/Assets/doomSheet.png differ
index 95d191e..be12156 100644 (file)
@@ -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
index 210a58c..1662461 100644 (file)
@@ -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),
index 64987e2..c2a2bf4 100644 (file)
@@ -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 (file)
index 0000000..b1fcaaf
Binary files /dev/null and b/Writeup/vision_previously_seen.png differ