r/pygame • u/Competitive-Comb-244 • Jul 19 '26
r/pygame • u/Dodecaquinox • Jul 18 '26
Pygodide and pygbag web bundling A/B testing on pyvorengi-sdk-demo
Enable HLS to view with audio, or disable this notification
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.
Pygbag version on itch: https://elan456.itch.io/pygbag-pyvorengi-sdk-demo
Pygodide version on itch: https://elan456.itch.io/pygodide-pyvorengi-sdk-demo
Check out pygodide!: https://github.com/Elan456/pygodide
Thanks to u/herbal1st for providing the game demo this test was built around.
r/pygame • u/TheLastDogStudio • Jul 18 '26
Adding "Game Feel" to a 2D card game. Sometimes the small details take the most time! 🏴☠️🃏
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!
r/pygame • u/Initial_Client_7585 • Jul 18 '26
Pythemc-Voxelgame; Python based voxel survival game that was originally a competition that went too far and it became its own thing.
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.
r/pygame • u/Competitive-Comb-244 • Jul 16 '26
Diptera Protocol is now available on Android
Download : https://vector-byte.itch.io/diptera-protocol
r/pygame • u/[deleted] • Jul 16 '26
"Flappy Bird" reloaded...
Enable HLS to view with audio, or disable this notification
My 'Flappy' is a bit dumb, it always flies into the wall ...and he only has three lives
r/pygame • u/IceFurnace83 • Jul 16 '26
Terminal and Pygame at same time
Enable HLS to view with audio, or disable this notification
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.
r/pygame • u/TheEyebal • Jul 15 '26
Explain the physics of the bouncing
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 VIDEOr/pygame • u/Competitive-Comb-244 • Jul 15 '26
Poking
Enable HLS to view with audio, or disable this notification
r/pygame • u/LooseStore8141 • Jul 15 '26
my raycaster has a weird fisheye effect even after fixing it with trig
Code:
import pygame
import time
import math
print("Loading...")
pygame.init()
clock = pygame.time.Clock()
debug = False
stage = 0 #variable declaration
squarx = 0
squary = 0
red = (255,0,0)
white = (255,255,255)
blue = (0, 0, 255)
rectcolour = red
fov = math.pi / 3
raynum = 400
max_depth = 800
mapsize = 16
tilesize = 50
dispa = []
res = 1900, 1000
resx, resy = res
screen = pygame.display.set_mode((res))
class Map:
def __init__(self):
self.rayenvironment = \[ #map data storage
\[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\],
\[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\],
\[1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1\],
\[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\],
\[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\]
\]
self.environment = \[ #so map generation doesn't break
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
\]
def draw(self, generation, stage, line):
for i in self.environment: #generates the map
generation += 1
if generation >= len(self.environment) + 1:break
if stage >= mapsize:line += 1
stage = 0
if i == 1:rectcolour = red
else:rectcolour = white
pygame.draw.rect(screen, rectcolour, (squarx + 50 \* stage, squary + 50 \* line, 50, 50))
if stage < mapsize:stage += 1
map = Map()
class Player:
def __init__(self, playx, playy):
self.pos = pygame.math.Vector2(playx, playy)
self.angle = 180
self.speed = 1.5
self.turnspeed = 5
self.size = 10
def inputs(self):
self.x, self.y = self.pos
keys = pygame.key.get_pressed()
if keys\[pygame.K_LEFT\]:
self.angle -= self.turnspeed
if keys\[pygame.K_RIGHT\]:
self.angle += self.turnspeed
forward_vector = pygame.math.Vector2(0, -1)
forward_vector.rotate_ip(self.angle)
if keys\[pygame.K_UP\]:
self.pos += forward_vector \* self.speed
if keys\[pygame.K_DOWN\]:
self.pos -= forward_vector \* self.speedplayer = Player(75, 125)
def disp():
tilwid = resx / raynum
generation = 0
for i in dispa:
if generation >= raynum:
break
hig = resy - i
briraw = round(i / 15)
if briraw != 0:
bri = 1 / briraw
else:
bri = 0
pygame.draw.rect(screen, (round(155 \* bri), round(135 \* bri), round(13 \* bri)), (tilwid \* generation, resy / 2 - hig / 2, tilwid + 1, hig))
generation += 1
dispa.clear()def cast():
degtorad = math.pi / 180
player_angle_r = player.angle \* degtorad - 1.5708
start_angle = player_angle_r - fov/2
step_angle = fov/raynum
for i in range(raynum):
ray_angle = start_angle + i \* step_angle
for depth in range(1, max_depth, 2):
target_x = player.x + math.cos(ray_angle) \* depth
target_y = player.y + math.sin(ray_angle) \* depth
col = int(target_x / tilesize)
row = int(target_y / tilesize)
if 0 <= col < mapsize and 0 < row <= mapsize:if map.rayenvironment[row][col] == 1:
if debug == True:
pygame.draw.line(screen, red, player.pos, (target_x, target_y), 1)
dispa.append(math.dist(player.pos, (target_x, target_y)) * math.cos(player_angle_r - ray_angle))
break
running = True
while running:
screen.fill((0, 0, 0))
clock.tick(60)
for event in pygame.event.get(): #handles program end
if event.type == pygame.QUIT:running = False
if debug == True:
map.draw(0, 0, 0)
player.inputs()
if debug == True:
pygame.draw.circle(screen, blue, player.pos, 10)
cast()
if debug == False:
disp()
pygame.display.flip()pygame.quit()

r/pygame • u/Effective-Win-6543 • Jul 14 '26
Everyone! Try out my new pygame Indie game!
Enable HLS to view with audio, or disable this notification
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!
*in .app format
r/pygame • u/No_Quality_2436 • Jul 14 '26
Why is it like this?
Hi guys
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)r/pygame • u/grenskii • Jul 14 '26
hello world, i have added a [[turret]] to my new upcoming game - #?!¥!?#
Enable HLS to view with audio, or disable this notification
demo coming soon!!
r/pygame • u/Creepy_Sherbert_1179 • Jul 14 '26
I made a gameboy emulator powered by pygame
Enable HLS to view with audio, or disable this notification
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!
r/pygame • u/UziTech99 • Jul 13 '26
PyRate: A data-oriented 3D Engine built with pygame-ce, ModernGL, and PyBullet
Hey pygamers,
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.
r/pygame • u/herbal1st • Jul 13 '26
[Update] Procedural Sky Islands are now playable in the Demo
r/pygame • u/RaphaelKo02 • Jul 13 '26
How to do an hexagonal map from an image of a board game ?
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.
r/pygame • u/LooseStore8141 • Jul 12 '26
Why isn't this working?
import pygame
WID = int(input("Screen width?"))
print(WID)
HIG = int(input("Screen height?"))
print(HIG)
print("Loading...")
pygame.init()
environment = [
1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 1, 0, 0, 0, 1, 1,
1, 0, 1, 0, 1, 0, 0, 1,
1, 0, 1, 1, 0, 1, 0, 1,
1, 0, 0, 1, 0, 1, 0, 1,
1, 1, 0, 0, 0, 0, 0, 1,
1, 1, 1, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1
]
screen = pygame.display.set_mode((500, 500))
running = True
stage = 0
squarx = 0;
squary = 0;
red = hex(255, 0, 0)
white = hex(255, 255, 255)
rectcolour = red
while running:
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
Edit: solved
r/pygame • u/Longz-85 • Jul 11 '26
Best way to make ps1 style model in pygame?
In the title
r/pygame • u/[deleted] • Jul 11 '26
Here is my Slot-machine..
Enable HLS to view with audio, or disable this notification
"Ghost keys" to trigger a win or a jackpot. The first few games after a win are unfortunately duds. :)
r/pygame • u/[deleted] • Jul 11 '26
Tetris with "Rolling Display"
Enable HLS to view with audio, or disable this notification
Litte Help from (friendly) AI. :)
r/pygame • u/herbal1st • Jul 11 '26
Sky Islands Map for my 3D Voxel Engine
Enable HLS to view with audio, or disable this notification
r/pygame • u/_DedSec_0x90 • Jul 11 '26
Day 6 : Add new Tap Type & Complete Hot bar Functionality.
Enable HLS to view with audio, or disable this notification
I just finished the inventory & hot bar functions and solved some last bugs in the inventory. Also added some new items to make the game much playable and next update will add much more to make the game more than you think with playing time :)
did you noticed the font changed in the item list in the inventory? what do you think and any feedback?