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
| /** | |
| * @typedef {{x:number, y:number}} Point | |
| * @typedef {{x:number, y:number, z:number}} Vec3 | |
| * @typedef {{x:number, y:number, z:number, w:number}} Vec4 | |
| * @typedef {number[][]} Mat4 | |
| */ | |
| /** @type {HTMLCanvasElement} */ | |
| let canvas = document.getElementById('mycanvas'); | |
| let ctx = canvas.getContext('2d'); |
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 | |
| import moderngl | |
| from pyglm import glm | |
| import numpy as np | |
| VERTEX_SHADER = """ | |
| #version 330 | |
| uniform mat4 mvp; | |
| in vec3 in_pos; |
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 pyglm.glm import vec2, vec3, vec4 | |
| from pyglm import glm | |
| def to_screen(point: vec2, screen_v: vec2) -> vec2: | |
| """ | |
| ndc (-1, 1) to actual screen coords (0, width), (0, height) | |
| """ | |
| n = (point + 1) / 2 # (0, 1) |
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 ast import BinOp, Add, Sub, Mult, Div, Mod, Constant, Tuple | |
| import ast | |
| import re | |
| class Dice(Constant): | |
| pass | |
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 |
NewerOlder