This file contains hidden or 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
| import subprocess, json | |
| def parse_json_dynamic(stream): | |
| dec = json.JSONDecoder() | |
| buf = '' | |
| for chunk in stream: | |
| buf += chunk | |
| while True: | |
| try: |
This file contains hidden or 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
| import math | |
| from dataclasses import dataclass | |
| from collections import deque | |
| import pygame | |
| from pygame import Vector2 | |
| @dataclass | |
| class Circle: |
This file contains hidden or 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
| import pygame | |
| # direction normals | |
| LEFT = pygame.Vector2(-1, 0) | |
| RIGHT = pygame.Vector2(1, 0) | |
| UP = pygame.Vector2(0, -1) | |
| DOWN = pygame.Vector2(0, 1) | |
| ZERO = pygame.Vector2(0, 0) | |
This file contains hidden or 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
| import socket | |
| from typing import Callable, Any, NamedTuple | |
| import select | |
| import heapq | |
| import time | |
| class Schedule(NamedTuple): | |
| when: float |
This file contains hidden or 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
| import pygame | |
| from pygame import Vector2 | |
| from dataclasses import dataclass | |
| @dataclass | |
| class Tile: | |
| name: str | |
| image: pygame.Surface | |
| position: Vector2 |
This file contains hidden or 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
| from dataclasses import dataclass | |
| from pygame import Vector2 | |
| import pygame | |
| import math | |
| @dataclass | |
| class Circle: | |
| center: Vector2 | |
| radius: float |
This file contains hidden or 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
| from pathlib import Path | |
| from platformdirs import PlatformDirs | |
| __all__ = ['path'] | |
| app_dirs = PlatformDirs('AppName', 'AppAuthor') # change this | |
| here = Path(__file__).absolute().parent | |
| SCHEMES = { |
This file contains hidden or 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
| from typing import Self | |
| import math | |
| import io | |
| type Number = int | float | |
| type TVec = tuple[Number, Number] | |
| class Vector: | |
| repr_precision = 6 |
This file contains hidden or 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
| import sys | |
| import pygame | |
| pygame.init() | |
| screen = pygame.display.set_mode((800, 600)) | |
| clock = pygame.time.Clock() | |
| class Triangle(pygame.sprite.Sprite): |
This file contains hidden or 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
| class List: | |
| _head: 'Node|None' | |
| _tail: 'Node|None' | |
| def __init__(self): | |
| self.reversed = False | |
| self._head = None | |
| self._tail = None | |
| def append(self, value): |
NewerOlder