-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01acd7d
commit 4e35846
Showing
10 changed files
with
230 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pygame | ||
import pygame.font | ||
import asyncpygame as ap | ||
|
||
|
||
async def countdown(*, count_from=3): | ||
font = pygame.font.SysFont(None, 400) | ||
fg_color = pygame.Color("white") | ||
img = pygame.Surface((0, 0)) | ||
|
||
def draw(draw_target: pygame.Surface): | ||
rect = img.get_rect() | ||
rect.center = draw_target.get_rect().center | ||
draw_target.blit(img, rect) | ||
|
||
req = ap.DrawingRequest(draw) | ||
try: | ||
for i in range(count_from, -1, -1): | ||
img = font.render(str(i), True, fg_color) | ||
await ap.sleep(1000) | ||
await ap.sleep_forever() | ||
finally: | ||
req.visible = False | ||
|
||
|
||
if __name__ == "__main__": | ||
pygame.init() | ||
pygame.display.set_caption("Countdown") | ||
screen = pygame.display.set_mode((400, 400)) | ||
ap.run(countdown(count_from=5), fps=20, draw_target=screen, bg_color=pygame.Color("black")) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
__all__ = ( | ||
'progress', 'dispatch_event', 'draw', | ||
'init', 'run', | ||
'DEFAULT_PRIORITY', 'DEFAULT_ZORDER', 'STOP_DISPATCHING', | ||
'sleep', 'move_on_after', | ||
'anim_with_dt', 'anim_with_dt_et', 'anim_with_et', 'anim_with_ratio', 'anim_with_dt_et_ratio', | ||
'run_in_thread', 'run_in_executor', | ||
'sdl_event', 'sdl_frequent_event', | ||
'VisibleEntity', | ||
'DrawingRequest', | ||
) | ||
|
||
from asyncgui import * | ||
from asyncpygame_internal.constants import DEFAULT_PRIORITY, DEFAULT_ZORDER, STOP_DISPATCHING | ||
from ._api_facade import ( | ||
progress, dispatch_event, draw, | ||
sleep, move_on_after, | ||
anim_with_dt, anim_with_dt_et, anim_with_et, anim_with_ratio, anim_with_dt_et_ratio, | ||
sdl_event, sdl_frequent_event, | ||
run_in_thread, run_in_executor, | ||
VisibleEntity, | ||
DrawingRequest, | ||
) | ||
from . import _replace_facades_with_real_ones | ||
from ._runner import init, run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.