Couldn't beat graphic bugs with sprite caching. Returned to old way. Need to create branch with sprite caching and try to finish it.

This commit is contained in:
shiva404
2026-02-16 00:30:17 +03:00
parent f679dde81f
commit 2e6e75866b
8 changed files with 55 additions and 33 deletions

View File

@@ -45,8 +45,6 @@ class Map:
self.cells[line].append(deepcopy(final_cell))
def draw_map(self, screen, current_frame, grid = True):
for j in range(len(self.cells)):
for i, cell in enumerate(self.cells[j]):
@@ -64,8 +62,8 @@ class Map:
if cell.creature_obj:
cell.creature_obj.draw(dd)
#if grid:
# pygame.draw.rect(screen, self.color, pygame.Rect(dd["x"], dd["y"], dd["w"], dd["h"]), self.bord)
if grid:
pygame.draw.rect(screen, self.color, pygame.Rect(dd["x"], dd["y"], dd["w"], dd["h"]), self.bord)
@dataclass
class Engine:
@@ -113,6 +111,8 @@ class Engine:
unlock = True
current_frame = 0
max_fps = 60
global_counter = 0
global_counter_cap = 100000
while running:
# poll for events
@@ -125,6 +125,7 @@ class Engine:
self.screen.fill("chartreuse4")
easy_map.draw_map(self.screen, current_frame + 1)
#print(easy_map.cells[0][0].item_obj.sprite_cache)
if unlock:
keys = pygame.key.get_pressed()
@@ -143,8 +144,11 @@ class Engine:
if keys[pygame.K_ESCAPE]:
running = False
#print(current_frame + 1)
current_frame = (current_frame + 1) % max_fps
if global_counter < global_counter_cap:
global_counter += 1
else:
global_counter = 0
# flip() the display to put your work on screen
pygame.display.flip()