Skip to content

Instantly share code, notes, and snippets.

View Mega-JC's full-sized avatar
🌌

Sunny J. C. Mega-JC

🌌
  • Berlin, Germany
  • 00:21 (UTC +02:00)
View GitHub Profile
@Mega-JC
Mega-JC / ce_logo_overlayer_gui.py
Last active January 20, 2024 18:51
ce_logo_overlayer_gui.py
import argparse
import glob
import os
import time
import sys
from gooey import Gooey, GooeyParser
from PIL import Image
@Mega-JC
Mega-JC / bot.py
Last active June 5, 2022 01:36
This is an example of a `discord.ext.commands.Bot` subclass that allows you to pass setup arguments to extension `setup()` functions in a backwards-compatible way.
"""This is an example of a `discord.ext.commands.Bot` subclass that allows you to pass
an `options=` keyword argument to `load_extension`. The argument can optionally receive
a dictionary that is passed to the `setup()` function of an extension. This works by
checking if an extension also implements an `options=` keyword argument and passing the dictionary
to it. Receiving this dictionary is opt-in, if `options=` is not implemented for the `setup()` function
of an extension, the resulting behavior will be as if `options=` were never passed to `load_extension`, thereby
making it backwards-compatible with any older extensions.
Tested with discord.py 2.0.0 alpha.
"""
import pygame
from pygame import Surface, Rect
pygame.init()
listtypes = set((list, tuple))
pygame_classes = set((Surface, Rect))
_text0 = "invalid Spritesheet coordinate: "
_text1 = ". Coordinates must be like this: (x, y, width, height)"
@Mega-JC
Mega-JC / CameraLib.py
Last active November 16, 2021 11:04
Basic 2D Camera System for pygame using LayeredUpdates and a Camera class.
# Two user-friendly classes for integrating a 2D camera system for pygame.
#
# The first class is Camera2, which is essentially a 2D camera with rect-like behaviour. To setup something like player tracking, one can simply do:
### Cam2 = Camera2(area=(0, 0, WIDTH, HEIGHT), view_distance=1000)
### Cam2.center = player.rect.center
# for even more precise control, one can do:
### Cam2.anchor = (Cam2.w*0.3, Cam2.h*0.7) # some coordinate on the screen