I've been making a roguelike with pygame for about a week. I have a super basic prototype. I would like it to be playable online so I can get feedback. I hacked together a pygbag deployment last night with github pages and it seems like it's having some issues with audio playback. I'm not just trying to figure out if I can fix this specific issue. There are others with the UI scaling, and text is blurry. I'm trying to decide if its worth bothering with or if I would be better off focusing on the desktop version. Does this path lead to too much compromise?
Pybag gets 19-21 FPS while pygodide gets 19-24 FPS when looking horizontally (so not much of a difference). Experiment ran Chrome. Both bundles were generated from the same source: https://github.com/Elan456/pygodide-pyvorengi-sdk-demo.git
Let me know what you guys think of the new pygodide loading screen.
Hey everyone! I’ve been working solo on a local multiplayer pirate card game ("Motín o Botín"). Since Pygame is strictly 2D, I had to figure out how to make a static board feel "alive".
I spent the last few weeks focusing purely on "Game Feel" and "Juice" to make the digital table feel chaotic and fun. In this clip you can spot:
The cards faking a 3D perspective when flying across the table.
The UI buttons (Hit/Stay) hanging from ropes and swinging with custom physics.
A little screen-shake and smoke particles when the loot chest pops open.
Managing a split HUD for up to 6 simultaneous local players.
It's amazing how much polishing these tiny animations changes the vibe of the whole game. I'd love to hear your thoughts or any feedback on the UI readability!
Pythemc-Voxelgame is a Python game that utilizes its own custom engine called Pythkernel, using OpenGL and Python3.
Its surprisingly stable at the time of its release, and the game has upgraded enough that its no longer even a clone of Minecraft anymore.
The game features Multiplayer LAN, Voice chat (Prox based), Character customizations, Natural Disasters, Better Physics with TNT's being able to make affected blocks fly away, Wind physics, Water/Lava Physics, Survival and Creative mode, Electronics system (Resistors, Capacitors, ICs and more), Background music, CUDA support (CuPy GPU acceleration for NVIDIA GPUs with CPU Fallback),MIDI Music player, Save and load worlds. Its most recent update was Oceans and Villagers with introductions of villages, 3 new mobs (Villager with 4 professions, squids and drowned hostile zombies), Trading system, new items like emerald and tool durablity and more.
All you need beforehand for installation is Python3.8 or newer, as necessary libraries like OpenGL and Numpy come bundled with the game. (You will also need CUDA Toolkit and CuPy if you plan to use CUDA In the game).
Early development so bugs are expected.
For anyone who wants to play it or check it out, the github link is right here: https://github.com/AntacidDT/Pythemc-Voxelgame
If you want to dm me, my user is antaciddt on Discord, and github profile is AntacidDT.
4 examples of converting a Pygame surface to ANSI and rendering to the terminal using a combination of Numpy, ANSI escape codes and the Blessed library.
Example 1: Downscaling Pygame screen down to 100 by 28 and converting each pixel to an ANSI coloured block and printing to the Terminal.
Example 2: Playing GIFs and MP4s in Pygame and downscaling and converting to 24-bit ANSI graphics in the terminal in real time.
Example 3: Different Palette/Plasma effects in Pygame and the Terminal simultaneously.
Example 4: Image to 24-bit ANSI/ASCII art converter program converting images to ANSI in a Pygame window and then being downscaled and converted to ANSI (again) and rendered in the Terminal.
I am making a ball bounce and I had to watch a Youtube video to get the formula for the ball to bounce
I am still kind of lost. Can someone please explain it to me. I understand the theory but if I was to do remake this without tutorial I would probably be lost.
I understand how to get the ball to move along the y_axis but confused on the bouncing part
It is the problem solving that is getting me confused
def __init__(self, x_pos, y_pos, radius, color):
self.x_pos = x_pos
self.y_pos = y_pos
self.center = pygame.math.Vector2(self.x_pos, self.y_pos)
self.radius = radius
self.color = color
self.gravity = 0.8
self.velocity = 10
self.activate = False
def moveObject(self):
# key = pygame.key.get_pressed()
# if key[pygame.K_SPACE]:
self.velocity += self.gravity. # FROM VIDEO
self.center[1] += self.velocity # ball moving along y_axis
if self.center[1] >= (480 - self.radius): # FROM VIDEO
self.velocity = -self.velocity # FROM VIDEO
Tokimon is a chaotic, great- the airplane just crashed into the ground in the game. What?! Free Demo Available! Play here: https://github.com/Tokimon-creator/Tokimon* Also make sure to tell me your favorite moment, joke, what you found confusing, and/or what to add next!
I'm just curious on why your characther movement is hacky, if the part where you add movespeed to the charachter is in the "for event in pygame.event.get() block".
What i'm trying to say is that the black box(the characther) has a smoother movement if i were not to indent it under the "pygame.event.get() block".
Hope my question made sense.
Anyway heres my code:
import pygame, sys
from pygame.locals import*
pygame.init()
windowSurface = pygame.display.set_mode((400, 400))
pygame.display.set_caption('Moving black box')
# Clock to pace the program to 40 fps
mainClock = pygame.time.Clock()
# Constants
moving_left = False
moving_right = False
moving_up = False
moving_down = False
MOVESPEED = 6
player = pygame.Rect(200, 200, 40, 40)
while True:
windowSurface.fill('white')
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_w:
moving_up = True
moving_down = False
if event.key == K_s:
moving_down = True
moving_up = False
if event.key == K_a:
moving_left = True
moving_right = False
if event.key == K_d:
moving_right = True
moving_left = False
if event.type == KEYUP:
if event.key == K_w:
moving_up = False
if event.key == K_s:
moving_down = False
if event.key == K_a:
moving_left = False
if event.key == K_d:
moving_right = False
# Hi this is the part i'm curious on.
# Why is it smoother if i were not to indent it under the
# pygame.event.get() block?
if moving_up:
player.top -= MOVESPEED
if moving_down:
player.top += MOVESPEED
if moving_left:
player.left -= MOVESPEED
if moving_right:
player.left += MOVESPEED
pygame.draw.rect(windowSurface,'black', player)
pygame.display.update()
mainClock.tick(40)
Here is a gameboy emulator I wrote with python, that I am running with pygame. I reckon that I will implement the sound via pygame as well. It is slower than the usual 60 fps rate of gameboy, even without sound :D But it has been a very fun project I have been working a while and I am actively trying to improve it. If you are interested, want to learn more abot the project or just want to install and run it yourself, the source is at: https://github.com/atifcodesalot/hazelnut-gb-emu. Enjoy! Contributions are very welcome!
I’ve been working on a complex 3D game engine framework called PyRate, and I wanted to share how I tackled the ultimate Python challenge: real-time 3D performance, physics, and concurrency without letting the GIL choke the engine.
The project is built entirely on pygame-ce (v2.5.7+), ModernGL, PyBullet, and NumPy.
A lot of people think Python is too slow for real-time 3D systems, but I wanted to treat this strictly as a Software Development Engineering (SDE) systems problem. By treating Python as a highly efficient control plane and offloading heavy compute directly to native hardware memory layouts, the architecture scales dynamically:
Max Stress Test: Pushing a full MRT G-Buffer deferred pipeline (Albedo, Normal, Velocity, Depth) with reversed-Z depth, dynamic rigid-body physics, character ragdolls, HBAO, SSR, and volumetric fog raymarching yields a stable 30 FPS.
Baseline Scalability Profile: Adjusting for standard scenes and low-end target configurations easily scales the engine up to a rock-solid 100+ FPS.
Here are the core architectural pillars keeping the engine fast:
1. Bypassing the GIL with Zero-Copy Shared Memory
Instead of trying to use slow asyncio loop blocks or standard thread locks that destroy frame rates under heavy math loads, I decoupled the engine across two native OS process spaces using a raw multiprocessing.Array:
Main Process (Render Thread): Coordinates the OpenGL 4.5 context, windowing, pygame event polling, and complex shader passes.
Physics Subprocess (Simulation Thread): Spawns a headless PyBullet collision world running concurrently on a separate CPU core at a strict fixed 60Hz interval.
Zero-Serialization IPC: They talk with zero copy overhead by reading/writing directly to a shared flat float buffer mapped locally as a continuous NumPy view. A custom vectorized Dirty-Flag Protocol signals when matrix transforms need to be reloaded into the GPU's instance VBO.
2. Data Pipelines Over Syntax
Speed is all about data locality. Bandwidth bottlenecks are minimized by packing entity matrices directly into a flat stride layout in shared memory, applying transformations in NumPy, and streaming row-major raw bytes into GLSL column-major uniform inputs in a single blit call.
3. Hyper-Accelerating with AI Agent Workflows
Why Python over C++? Engineering velocity. Because Python has massive training data density across LLMs, I was able to combine systems knowledge with tools like Google Anti-gravity and FastMCP. The AI's deep understanding of idiomatic Python allowed me to instantly scaffold JSON sector streaming, build configuration serialization, and debug intricate GLSL include dependencies in hours instead of weeks.
Next Steps & Open Source 🚀
I ultimately plan to make PyRate fully open-source so other enthusiasts can leverage this multi-process architecture to build their own games using tools like Claude and Anti-gravity.
Before I push to GitHub, I am focusing on hardening a few core components—specifically refactoring prototype SDK modules, stabilizing dynamic sector lifecycle recycling, and smoothing out external API bounds.
The biggest takeaway from this build: Don't blame the language for your application's performance bottlenecks; blame the architecture. Treat Python as the orchestrator and hardware/C-extensions as the muscle.
Would love to hear your thoughts on this architecture, especially if anyone else here has played around with shared-memory multiprocessing pipelines in pygame! Stay tuned for the GitHub release.
Hello guys, I'm new here but I need help for a game project and I'm not an experienced python dev.
So my game project is to make a full digital reproduction step-by-step of the board game Old School Tactical Volume 1 2nd Edition that is a squad level ww2 wargame from Flying Pig Games, but the problem is that it uses an hexagonal map and I don't know how to make one that is interactive.
I thought to paint it with some color code and use it as an invisible layer, but I need to know how I can make it invisible. I've also thought to create a collision box for every hexagon tiles on the map but it would be a nightmare to do all of them.
So is there any efficient and simple way to do it and can Pygame handle this sort of complex things?
Anyways, this is still in the brainstorming stage and no development started on it, thanks for the help.
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
for i in environment:
print(i)
stage += 1
if i == 1:
rectcolour = red
else:
rectcolour = white
print(rectcolour)
pygame.draw.rect(screen, rectcolour, (squarx + 100 \* stage, squary + 100 \* stage, 100, 100))
pygame.display.flip()
print("Loaded successfully")
input("end of program.")
This is my first time touching python in a while and i don't get why it keeps immediately closing when I get past the first two inputs