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
# Alternative implementation of pygame.Rect that uses floats rather than integers | |
# | |
# Use FRect from pygame-ce instead of this! | |
# https://pyga.me/docs/ref/rect.html | |
# | |
# Don't question the implementation strategy, this is perfect | |
# Repurposed from another project of mine | |
# Constants needed for my direct translation of SDL_IntersectRectAndLine |
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
while (locals().get("f") or [globals().update(p=__import__("pygame")), p.init(), globals().update(w=p.display.set_mode((800,600))), globals().update(r=[p.Rect(c) for c in [(0, 0, 20, 60), (780, 0, 20, 60), (390, 290, 20, 20)]]), globals().update(b=[5, 5]), locals().update(f=1)]) and [not p.QUIT in [event.type for event in p.event.get()], p.time.wait(10), w.fill(0), [[p.draw.rect, p.draw.ellipse][rx == r[2]](w, "white", rx) for rx in r], p.display.flip(), [r[0].move_ip(0, (p.key.get_pressed()[p.K_s] - p.key.get_pressed()[p.K_w]) * 5), r[1].move_ip(0, (p.key.get_pressed()[p.K_DOWN] - p.key.get_pressed()[p.K_UP]) * 5), r[2].move_ip(*b)], [rect.clamp_ip(w.get_rect()) for rect in r[0:2]], setattr(r[2], "topleft", (390, 290) if r[2].x < 0 or r[2].right > 800 else r[2].topleft)][0]: b[1], b[0] = -b[1] if not 0 < r[2].y < 540 else b[1], -b[0] if r[2].collidelist(r[:2]) >= 0 else b[0] |
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
import cv2 | |
import pygame | |
import numpy | |
import functools | |
# WHAT IS THIS? | |
# This script is a simple ascii video player made in Python / pygame | |
# It allows you to drop in videos, or to use the webcam | |
pygame.init() |
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
import pygame | |
import pygame.camera | |
pygame.init() | |
pygame.camera.init() | |
desired_size = (1280, 720) | |
cameras = pygame.camera.list_cameras() | |
cam = pygame.camera.Camera(cameras[0], desired_size) |