Skip to main content

Easier Pygame!, Made by Crystal!!

Project description

CRYSTALWINDOW!!!

A tiny but mighty Pygame framework that gives you a full window system, GUI magic, physics, and file power — all packed into one clean lil module.

No setup pain. No folder chaos.
Just import it. Boom. Instant game window.


Quick Start

pip install crystalwindow

Basic Window
Create a new Python file:

from crystalwindow import Window  # imports everything from crystalwindow (here it's Window)
win = Window(800, 600, "Crystal Demo")  # setup: Window(width, height, title, icon=MyIcon.ico)
win.run()  # runs the window loop
win.quit()  # closes it (for RAM n CPU)

Run it. Boom — instant working window. Yes, THAT easy.

Easy CrystalWindow Window + GUI + Text

from crystalwindow import *

win = Window(800, 600, "CrystalWindowLib Mega Sandbox")

gui = GUIManager()
toggle1 = Toggle((50, 50, 100, 40), value=False)
slider1 = Slider((50, 120, 200, 30), min_val=0, max_val=100, value=50)

btn1 = Button(
    rect=(50, 200, 150, 50),
    text="Click Me!",
    color=random_color(),
    hover_color=random_color(),
    callback=lambda: print("Button clicked!")
)
lbl1 = Label((250, 50), "Hello GUI!", color=random_color(), size=24)

gui.add(toggle1)
gui.add(slider1)
gui.add(btn1)
gui.add(lbl1)

# --- Debug Overlay ---
debug = DebugOverlay()

# --- Camera Shake ---
shake = CameraShake(intensity=20)

# --- Main loop ---
def update(win):
    gui.update(win)
    gui.draw(win)

    # --- draw text examples ---
    win.draw_text_later("Normal Text", pos=(400, 50), size=18, color=random_color())
    win.draw_text_later("Bold Text", pos=(400, 80), size=20, color=random_color(), bold=True)
    win.draw_text_later("Italic Text", pos=(400, 110), size=20, color=random_color(), italic=True)
    win.draw_text_later("Bold + Italic", pos=(400, 140), size=22, color=random_color(), bold=True, italic=True)

    # --- draw toggle/slider values ---
    win.draw_text_later(f"Toggle: {toggle1.value}", pos=(50, 90), size=18)
    win.draw_text_later(f"Slider: {int(slider1.value)}", pos=(50, 160), size=18)

    # --- draw gradient ---
    gradient_rect(win, (50, 300, 200, 100), (255,0,0), (0,0,255))

    # --- screen shake example ---
    shake.update()
    x_off, y_off = shake.offset
    win.draw_rect((0,255,0), (500+x_off, 300+y_off, 100, 50))
    
    # --- draw random name + color ---
    win.draw_text_later(f"Random Name: {random_name()}", pos=(50, 420), size=20, color=random_color())
    
    # --- debug overlay ---
    debug.draw(win, fps=int(win.clock.get_fps()))

win.run(update)
win.quit()

What's Inside

  • Built-in window manager
  • Built-in GUI (buttons, sliders, toggles, labels)
  • Built-in gravity + physics engine
  • Tilemap system (place & save blocks)
  • Image loader (with default base64 logo)
  • Safe startup (works even inside PyInstaller)
  • No external dependencies (only pygame)
  • Works offline
  • Minimal syntax
  • Full debug overlay

Window System Example

from crystalwindow import *

win = Window(800, 600, "My Game", icon="MyIcon.png")

def loop(win):
    win.fill((10, 10, 30))
    # draw or update stuff here

win.run(loop)
win.quit()

Features:

  • Handles events
  • Tracks keys + mouse
  • Supports fullscreen
  • Safe to close anytime

Player Example

player = Player(100, 100)

def loop(win):
    player.update(win.keys)
    player.draw(win.screen)

Methods:

  • move(dx, dy) -> moves player
  • take_damage(x) -> takes damage
  • heal(x) -> heals
  • draw(surface) -> renders sprite

#TileMap Example: tilemap = TileMap(32) tilemap.add_tile(5, 5, "grass") tilemap.save("level.json")

#Methods(Tilemap):
add_tile(x, y, type)
remove_tile(x, y)
draw(surface)
save(file) / load(file)

GUI System

btn = Button(20, 20, 120, 40, "Click Me!", lambda: print("yo"))
gui = GUIManager()
gui.add(btn)

#Built-in Widgets:
Button(x, y, w, h, text, onclick)
Label(x, y, text)
Toggle(x, y, w, h, text, default=False)
Slider(x, y, w, min, max, default)

#Gravity Example

g = Gravity(0.5)
g.update(player)

Makes objects fall realistically. ez.

#FileHelper Example

save_json("data.json", {"coins": 99})
data = load_json("data.json")

#Also supports:
save_pickle / load_pickle
FileDialog("save") (tkinter dialog popup)

#DrawHelper DrawHelper.draw_text_later("Hello!", (10,10), (255,255,255), 24) DrawHelper.draw_rect(win.screen, (100,0,200), (50,50,100,60))

Perfect for UI & quick visuals.

Debug Tools

debug = DebugOverlay()
debug.toggle()
debug.draw(win.screen, {"hp": 100, "fps": win.clock.get_fps()})

Example Game

from crystalwindow import *

win = Window(800, 600, "My Cool Game")

def update(win):
    win.fill((25, 25, 40))

win.run(update)
win.quit()

#Default Logo
There is a lil encoded PNG inside the file called:
DEFAULT_LOGO_BASE64
Used when no icon is given.
Set your own like:

Window(800, 600, "My Window", icon="MyIcon.png")

Example Integration

from crystalwindow import Window

win = Window(800, 600, "My Window", icon="MyIcon.png")

while win.running:
    win.check_events()
    win.fill((10, 10, 20))
    win.run()
win.quit()

Credits
Made by: CrystalBallyHereXD
Framework: CrystalWindow
Powered by: Pygame
License: Free to use, modify, and vibe with it!

Project details


Release history Release notifications | RSS feed

This version

2.3

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crystalwindow-2.3.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crystalwindow-2.3-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file crystalwindow-2.3.tar.gz.

File metadata

  • Download URL: crystalwindow-2.3.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for crystalwindow-2.3.tar.gz
Algorithm Hash digest
SHA256 03a1f41dfef7b2e96f3873cf0393fbf119da5e56680f71d1211ce6082e09771a
MD5 e04624cdf806202bbd940ea827f91d33
BLAKE2b-256 43f4ad076dc86691b0882a3df8f66b6c2c5a48e65547ffdf211d9a5db25a595a

See more details on using hashes here.

File details

Details for the file crystalwindow-2.3-py3-none-any.whl.

File metadata

  • Download URL: crystalwindow-2.3-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for crystalwindow-2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bc0d2e48cfcb3548e0ae95b17025004a59e02586b979af0f8e2fcdd786d3f9ce
MD5 394b2b58f4c72a49898ef28248cb87f9
BLAKE2b-256 b6dbf6384f0e014ccfc2c72f8f96733a802944ab9db0dd8fa111e3be36d2ce63

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page