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:
14
eb_engine.py
14
eb_engine.py
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user