From db36a4cd7ac293f96878117a20fb3827a837fcb9 Mon Sep 17 00:00:00 2001 From: Zaponium Date: Sat, 27 Apr 2024 21:13:28 +0200 Subject: [PATCH] Commit 27/04-24 Woot Woot --- Main.py | 152 ++++++++++-------- Map/MapManager.py | 7 +- Map/__pycache__/MapManager.cpython-312.pyc | Bin 10555 -> 10950 bytes Map/__pycache__/TileTypes.cpython-312.pyc | Bin 4628 -> 4619 bytes .../__pycache__/ScriptUtils.cpython-312.pyc | Bin 164 -> 155 bytes 5 files changed, 90 insertions(+), 69 deletions(-) diff --git a/Main.py b/Main.py index 437d4e4..baa3f3a 100644 --- a/Main.py +++ b/Main.py @@ -21,83 +21,109 @@ maprect = map.get_rect() mapWidth = int(map.get_width()) mapHeight = int(map.get_height()) -y = 0 -bY = 5 -bX = 4 + time1 = pygame.time.get_ticks() - -while bX < mapWidth: - for x in range(bX, mapWidth): - if y < mapHeight: - map.set_at((x, y), (0,0,0,255)) - y += 1 - if y % 5 == 0: - map.set_at((x, y), (0,0,0,255)) - y += 1 - screen.blit(map, maprect) - pygame.display.flip() - bX += 8 +def initMapGen(): y = 0 - -y = bY - -while bY < mapHeight: - for x in range(0, mapWidth): - if y < mapHeight: - map.set_at((x, y), (0,0,0,255)) - y += 1 - if y % 5 == 0: + bY = 5 + bX = 4 + while bX < mapWidth: + for x in range(bX, mapWidth): + if y < mapHeight: map.set_at((x, y), (0,0,0,255)) y += 1 - screen.blit(map, maprect) - pygame.display.flip() - bY += 10 + if y % 5 == 0: + map.set_at((x, y), (0,0,0,255)) + y += 1 + screen.blit(map, maprect) + pygame.display.flip() + bX += 8 + y = 0 + y = bY -bX = 4 -y = 0 - -while bX < mapWidth: - for x in range(bX, -1, -1): - if y < mapHeight: - map.set_at((x, y), (0,0,0,255)) - y += 1 - if y % 5 == 0: + while bY < mapHeight: + for x in range(0, mapWidth): + if y < mapHeight: map.set_at((x, y), (0,0,0,255)) y += 1 - screen.blit(map, maprect) - pygame.display.flip() - bX += 8 + if y % 5 == 0: + map.set_at((x, y), (0,0,0,255)) + y += 1 + screen.blit(map, maprect) + pygame.display.flip() + bY += 10 + y = bY + + bX = 4 y = 0 -bY = 2 -y = bY - -while bY < mapHeight: - for x in range(mapWidth, 0, -1): - if y < mapHeight: - map.set_at((x, y), (0,0,0,255)) - y += 1 - if y % 5 == 0: + while bX < mapWidth: + for x in range(bX, -1, -1): + if y < mapHeight: map.set_at((x, y), (0,0,0,255)) y += 1 - screen.blit(map, maprect) - pygame.display.flip() - bY += 10 + if y % 5 == 0: + map.set_at((x, y), (0,0,0,255)) + y += 1 + screen.blit(map, maprect) + pygame.display.flip() + bX += 8 + y = 0 + + bY = 2 y = bY + while bY < mapHeight: + for x in range(mapWidth, 0, -1): + if y < mapHeight: + map.set_at((x, y), (0,0,0,255)) + y += 1 + if y % 5 == 0: + map.set_at((x, y), (0,0,0,255)) + y += 1 + screen.blit(map, maprect) + pygame.display.flip() + bY += 10 + y = bY + +initMapGen() class uText: def __init__(self): - self.font = pygame.font.SysFont('Comic Sans MS', 30) + self.font = pygame.font.Font(pygame.font.get_default_font(), 36) + self.texts = [] - def write(self, text): - text = self.font.render(text, antialias=True, color=(255,255,255)) - return text + def write(self, text, position): + self.texts.append((text,position)) + + def delete(self, text): + text2 = [] + for place in self.texts: + if place[0] != text: + text2.append(place) + self.texts = text2 + + def runText(self): + for text in self.texts: + textPrint = self.font.render(str(text[0]), True, (255, 255, 255)) + textPrintRect = textPrint.get_rect() + textPrintRect = textPrintRect.move(int(text[1][0]),int(text[1][1])) + screen.blit(textPrint, textPrintRect) + + def runTextTile(self, tile_pressed): + info = GameMap.getTileInfo(tile_pressed) + tile_pressed = str(tile_pressed) + tilePrint = self.font.render(tile_pressed, True, (255, 255, 255)) + tilePrintRect = tilePrint.get_rect() + tilePrintRect = tilePrintRect.move(1000,50) + screen.blit(tilePrint, tilePrintRect) uTexter = uText() +uTexter.write("State",(1000,0)) + pygame.image.save(map, "./Map/Images/blackstripes.png") GameMap = MapManager.MapManager() @@ -134,21 +160,11 @@ while running: # fill the screen with a color to wipe away anything from last frame screen.fill("black") - font = pygame.font.Font(pygame.font.get_default_font(), 36) - if tile_pressed != None: - tile_pressed = str(tile_pressed) - tilePrint = font.render(tile_pressed, True, (255, 255, 255)) - tilePrintRect = tilePrint.get_rect() - tilePrintRect = tilePrintRect.move(1000,50) - screen.blit(tilePrint, tilePrintRect) - - textPrint = font.render('State', True, (255, 255, 255)) - textPrintRect = textPrint.get_rect() - textPrintRect = textPrintRect.move(1000,0) + uTexter.runTextTile(tile_pressed) + + uTexter.runText() - screen.blit(textPrint, textPrintRect) - screen.blit(map, maprect) # RENDER YOUR GAME HERE diff --git a/Map/MapManager.py b/Map/MapManager.py index 0345c64..ea8241e 100644 --- a/Map/MapManager.py +++ b/Map/MapManager.py @@ -153,6 +153,7 @@ class MapManager: colour = mappedColours[f"{tilesMapped[tile.Position[0]][tile.Position[1]]}"] colour1, colour2, colour3 = colour[0], colour[1], colour[2] tile.paint_pixels(mapObject, int(colour1),int(colour2),int(colour3)) + tile.add_terrain(f"{tilesMapped[tile.Position[0]][tile.Position[1]]}") def findTileAt(self, pos): for x in self.tiles.keys(): @@ -161,7 +162,7 @@ class MapManager: if int(x) == int(tile.getId()): return x else: - print(f"Missmatching ID for found tile: {x} / {tile.getId()}") + print(f"Mismatching ID for found tile: {x} / {tile.getId()}") return (x,tile.getId()) print(f"Could not find tile at position: {pos[0]},{pos[1]}") @@ -171,6 +172,7 @@ class MapManager: info = {} info["id"] = id info["pixels"] = self.tiles[f"{id}"].getPixels() + info["terrain"] = self.tiles[f"{id}"].getTerrain() class Tile: @@ -187,6 +189,9 @@ class Tile: def getPixels(self): return self.pixels + + def getTerrain(self): + return self.terrain def add_pixel(self,pixel): self.pixels.append(pixel) diff --git a/Map/__pycache__/MapManager.cpython-312.pyc b/Map/__pycache__/MapManager.cpython-312.pyc index a483555ffe90e229b3e736894b2d2c23d944825b..66151b7ee3f501b27be60984696558315cfb524d 100644 GIT binary patch delta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AvAg%{v5W})iymp3@Y<+oNQ}XsH?Y5dW zB%TCWnQIi1jkuXk;`dOyeThn=0VClkf8T>v>7=~~)+*A@3;;?%ITteBe zfK6z{KVcCXv9h|UV8$U8W{0W;kW$RvO_6tyq^@YXNd~QzsS=XZ^uxyEc(*1BuW-5M z!Ko|MAORVtkLO_R%K)lHQb9?sQ)G%_T3U^csb;UTf>X6}(?P~+H$@#s6KueY=P+@} z8h#Cb)CO=a5-YTlJW1iV$QfA2KwV$gL9sN=(L=HhhG~PR5dUo>?@B7l$iWa9uT}iW zn=O1&_Y6|lE6MN%7o=|4NmQC9qYPsVIs+TV`T?YxDU+dwVTj>4gEe%RDTZZw8zMH= z`%$hxDgST#UDz=(sZ6KUPLiQMc4$V3;-?J&wmJ7U=iMvNcxc_>825$+AGGdr6jrOh DB)`et diff --git a/Map/__pycache__/TileTypes.cpython-312.pyc b/Map/__pycache__/TileTypes.cpython-312.pyc index b0bab43bf18d784819f0a64853b08a87c8843806..5303f28276a7ed7fcff9063c58b62105a8603488 100644 GIT binary patch delta 49 zcmbQD(yhXMnwOW00SJU2%WvfFWED4cwu%WYPAw{q@kq?eOO0_!EzT~ai0OP)5NX*MijB&|NF3nBND=Cg~&n)pM JO_~_$1^}Yg5m*2K