WIP sdl renderer
This commit is contained in:
parent
68aa90cac8
commit
ef3f64bfa2
3 changed files with 22 additions and 11 deletions
|
|
@ -5,7 +5,9 @@ from __future__ import annotations
|
|||
from typing import Protocol, TypeAlias
|
||||
|
||||
import attrs
|
||||
import tcod.console
|
||||
from tcod.console import Console
|
||||
from tcod.event import Event, Quit
|
||||
from tcod.event import wait as wait_for_event
|
||||
import tcod.event
|
||||
|
||||
import g
|
||||
|
|
@ -16,10 +18,10 @@ class Screen(Protocol):
|
|||
|
||||
__slots__ = ()
|
||||
|
||||
def on_event(self, event: tcod.event.Event) -> ScreenResult:
|
||||
def on_event(self, event: Event) -> ScreenResult:
|
||||
"""Called on events."""
|
||||
|
||||
def on_draw(self, console: tcod.console.Console) -> None:
|
||||
def on_draw(self, console: Console) -> None:
|
||||
"""Called when the screen is being drawn."""
|
||||
|
||||
|
||||
|
|
@ -84,9 +86,10 @@ def main_loop() -> None:
|
|||
"""Run the active screen forever."""
|
||||
while g.screens:
|
||||
main_draw()
|
||||
for event in tcod.event.wait():
|
||||
if event.type == 'WindowClose':
|
||||
raise SystemExit()
|
||||
for event in wait_for_event():
|
||||
match event:
|
||||
case Quit():
|
||||
raise SystemExit()
|
||||
tile_event = g.context.convert_event(event)
|
||||
if g.screens:
|
||||
_apply_screen_result(g.screens[-1].on_event(tile_event))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue