Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.py #35

Merged
merged 2 commits into from
May 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 41 additions & 28 deletions Visualiser2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,57 @@
from Visualiser2.config import Config
from game.utils.vector import Vector

pygame.init()

config = Config()
class ByteVisualiser:

size: Vector = config.SCREEN_SIZE
# size = width, height = 1366, 768
tile_size: int = config.TILE_SIZE
black = 0, 0, 0
def __init__(self):
pygame.init()
self.config = Config()
self.turn_logs: list[dict]
self.size: Vector = self.config.SCREEN_SIZE
# size = width, height = 1366, 768
self.tile_size: int = self.config.TILE_SIZE
self.black = 0, 0, 0

screen = pygame.display.set_mode((size.x, size.y))
self.screen = pygame.display.set_mode((self.size.x, self.size.y))

clock = pygame.time.Clock()
simple_font = pygame.font.Font(None, 50)
self.clock = pygame.time.Clock()
self.simple_font = pygame.font.Font(None, 50)

tick: int = 0
self.tick: int = 0

turn_logs: list[dict]
def load(self):
self.screen.fill(self.black)

while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()
def prerender(self):
if self.tick % self.config.NUMBER_OF_FRAMES_PER_TURN == 0:
# NEXT TURN
pass
else:
# NEXT ANIMATION FRAME
pass
self.tick += 1

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE: sys.exit()
def render(self):
pygame.display.flip()

# DO ACTIONS
screen.fill(black)
def postrender(self):
self.clock.tick(self.config.FRAME_RATE)

if(tick % config.NUMBER_OF_FRAMES_PER_TURN == 0):
# NEXT TURN
pass
else:
# NEXT ANIMATION FRAME
pass
def loop(self):
self.load()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT: sys.exit()

tick += 1
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE: sys.exit()

self.prerender()
self.render()
self.postrender()

# Render Frame
pygame.display.flip()
clock.tick(config.FRAME_RATE)

if __name__ == '__main__':
byte_visualiser: ByteVisualiser = ByteVisualiser()
byte_visualiser.loop()