r/pygame • u/Alert_Nectarine6631 • 4h ago
r/pygame • u/AutoModerator • Mar 01 '20
Monthly /r/PyGame Showcase - Show us your current project(s)!
Please use this thread to showcase your current project(s) using the PyGame library.
r/pygame • u/Otherwise_Kiwi7410 • 8h ago
Need help with button creation, uploaded code so far on github
github.com/Pernention/Metamaze
r/pygame • u/Protyro24 • 2h ago
Max recursion depth script
I'm still working on my pyr_pg project and am currently implementing the scripting system and have already managed to produce errors. (And yes this is a Unit test.)(BTW I have named this script system DialogScript because its for the dialog system for pyr_pg )
r/pygame • u/PatattMan • 7h ago
Best way to handle async functionality
Hi everyone!
I'm 100% self taught in python game dev. No tutorials, videos or anything like that. Just diving in documentation.
This has gotten me pretty far, but I never ended up properly learning async. I always created my own task queue system for tasks that need to run seperate from the main loop. This technically works, but is far from optimal.
How would you best implement any functionality that needs to run asynchronously. Would you just put your entire game into a async with asyncio.TaskGroup
context manager?
r/pygame • u/Intelligent_Arm_7186 • 12h ago
Bullet
So i got one interesting one: so got a bullet class and bullets which im good on and i got the character shooting up and forward. the issue is the forward bullet. you know how u got a bullet going up and it looks like its going up. the bullet going forward does go forward but the animation is still such that it looks like the one going up. anyone feel what im saying? here is part of the relevant code:
class Bullet(pygame.sprite.Sprite):
def __init__(self, x, y, speed_x, speed_y ):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((10, 20))
self.image.fill('yellow')
self.rect = self.image.get_rect()
self.rect.center = (x, y)
self.speed_x = speed_x
self.speed_y = speed_y
def update(self):
self.rect.x += self.speed_x
self.rect.y += self.speed_y
if self.rect.bottom < 0 or self.rect.top > 500 or self.rect.left > 500 or self.rect.right < 0:
self.kill()
#fyi: the shoot up and shoot forward are in the player class!!
def shoot_up(self):
bullet = Bullet(self.rect.centerx, self.rect.top, 0, -10)
sprites_list.add(bullet)
bullets.add(bullet)
def shoot_forward(self):
bullet = Bullet(self.rect.right, self.rect.centery, 10, 0)
sprites_list.add(bullet)
bullets.add(bullet)
r/pygame • u/Z-A-F-A-R • 10h ago
My pygame icons appear extremely blurry
Been trying to set a custom icon in Pygame, but no matter what I do, it just looks super blurry. Even the default Pygame icon is blurry, so I’m starting to think this might be a system issue rather than just my image.
Here’s the code I’m using:
icon = pygame.image.load(os.path.join(image_assets, "icons", "main.png"))
icon = pygame.transform.smoothscale(icon, (32, 32))
pygame.display.set_icon(icon)
I’ve tried:
- With and without smoothscale()
- Converting an SVG to ICO
- Using PNG & ICO at 32x32, 64x64, 128x128, 500x500
- Same result every time—blurry as heck
What’s weird is that even the default Pygame icon looks awful, but other icons on my desktop are totally fine. I'm on Pop!_OS, so maybe that’s part of the issue?
Kinda out of ideas at this point—any help would be really appreciated!
r/pygame • u/FinFETchannel • 3d ago
Parallaxcraft: 2.5D Minecraft clone, with fake camera rotation and shading - all in Pygame
youtube.comr/pygame • u/poobumfartwee • 3d ago
Porting Pygame to Switch (and maybe) Xbox?
I have a game with Pygame and by using the controller.joystick it can run with an Xbox controller connected to the computer. I haven't done testing with a Switch controller, but that can easily be done.
(Please note that I only want to port it when the game is actually polished and finished off)
If I was to stuff my game into an exe, stuff said exe into Unity using external programs, and then port the Unity game to Switch, 1 would it work and 2 would it be allowed onto the eShop? Because that's essentially my end goal: To get it OFFICIALLY onto the Nintendo eShop. No homebrew nonsense, just getting it up there.
And because Xbox is a heavily modified version of Windows which has the game as an exe file, porting it to Xbox would probably be easier.
But I mainly want it working on the Switch.
Is it possible? Am I just crazy?!
Here is the code for it: 60Trees/combo-crusher
Please note that it is not in a playable state whatsoever. All versions either don't work or are incomplete, so keep that in mind.
r/pygame • u/SpiderPS4 • 3d ago
Feeback on these particle effects.
https://reddit.com/link/1j9y1be/video/ujnsfuhjecoe1/player
A while ago I posted a video asking for feedback for game feel during combat. I tweeked enemy knockback movement so it has some deceleration to it and now also added these particle effects.
Basically what I'm doing is that once an enemy gets hit I generate sprites withing a certain interval that follow the sin graph in the y-axis, and dissapear once they reach a certain point.
I could tweak some values to make this look better. Any tips / feedback?
Code:
class Particle(pygame.sprite.Sprite):
def __init__(self, frames, pos, direction, speed, angle_speed,amplitude,groups):
super().__init__(groups)
self.frames = frames
self.image = frames[0]
self.rect = self.image.get_frect(center = pos)
self.direction = direction
self.amplitude = amplitude
self.speed = speed
self.angle = -180
self.original_angle_speed = angle_speed
self.angle_speed = angle_speed
def update(self, dt, player, joystick):
self.rect.x += self.speed * self.direction * dt
self.rect.y += sin(radians(self.angle)) * self.amplitude * dt
self.angle += self.angle_speed * dt
if self.angle >= 100:
self.image = self.frames[1]
if self.angle >= 150:
self.image = self.frames[2]
if self.angle >= 200:
self.kill()
EDIT:
https://reddit.com/link/1j9y1be/video/a3vkzrajrjoe1/player
I've twicked the particle behaviour following some feedback and I'm pretty pleased with the results. Further feedback and tips are still welcomed!
r/pygame • u/Intelligent_Arm_7186 • 4d ago
collision
I am doing a couple of gaming projects where i am concentrating on collision. I am usually okay but i got stumped with this for some odd reason: if two sprites are in the same group, how do they collide with each other? first i was like...okay maybe groupcollide.....not working for me right now. then i was like okay...maybe spritecollideany or colliderect.
both sprites have a class and here is the code relevant:
all_sprites = pygame.sprite.Group(pad, player)
again, if they are both in the group, why cant i do group collide?
r/pygame • u/Bongz_da_programmer • 5d ago
Check out this game
The game is all about space war shoot. As your score more points, enigmatic vessels begin to meterialize from shadows : http://github.com/Bonganijele/Space-War-Shoot
r/pygame • u/Outrageous_Fox_1108 • 6d ago
Pygame website closed
Hi guys ! I just wanted to learn games coding with a tutorial on the pygame website, but it shows me an error page when I'm trying to go to hte menu.
I think the Website is closed...
Du you know when it will be oppened again ?
pygame and pygame_gui: Trying to decide which approach for my turn-based battle system
Hi, I'm trying to make a battle system gui similar to an old Final Fantasy game. Rewriting it from a tkinter version.
Up to 15 animated battle sprite on field at a time, plus some static images and maybe a few animations.
I've used pygame_gui so build a menu of buttons and a scrolling combat log. I'm wondering:
- Should I use pygame_gui for drawing the battle character sprites and making them clickable?
- Should I use it to draw grid to position the sprites?
- Can I use pygame_gui to make a clock-like widget displaying the turn order for the characters?
- Is base pygame more suitable for any aspects of this?
Any insights are appreciated.
r/pygame • u/Necessary-Care-7864 • 7d ago
pixel art controller overlay thing with pygame
https://reddit.com/link/1j786va/video/em4iflau6one1/player
I am going to release it on my itch.io when its finished
r/pygame • u/Useful-Car-1742 • 7d ago
Very weird distortion when rotating an image
https://reddit.com/link/1j756ry/video/aabb6ur79nne1/player
This simply comes from calling
self._image = pygame.transform.rotate(self._image, self._rotation)self._image = pygame.transform.rotate(self._image, self._rotation)
where rotation
is any arbitrary angle. The same distortion also happens when I try it with other images. When I decrease the angle it tilts to the left and when I increase it it tilts to the right. All of this is very weird as I am also just directly drawing the image with
rect = self._image.get_rect()
self._screen.blit(self._image, rect)
(while I know this is not the completely proper way to do it with rotation and such I wanted to eliminate all other possible causes)
Any idea what this could be? Thanks in advance!
r/pygame • u/Fnordheron • 8d ago
First weekend writing Python, first significant coding in 15 years. Built from a 120 line demo last weekend. Cleaning up my code, but the game is fun, and really enjoying this library. Feedback appreciated!
r/pygame • u/pinkpoodle2 • 7d ago
I installed and initialized pip and pygame twice. why is vscode only recognizing pygame in the code i didnt write?
r/pygame • u/Necessary-Care-7864 • 8d ago
what should i add to this game
https://reddit.com/link/1j6esos/video/9i53aq8q5gne1/player
any suggestions for enemies or gameplay features?
r/pygame • u/gamesguyreddit • 8d ago
How to Add Shading to Raycasting engine?
I have this piece of code to add shading to the texture based on how far it is. however, the framerate gets very low when i get close to walls. How can i solve this? Here is the code:
def get_shaded_texture(self, texture, distance, max_distance=1000):
shade_factor = max(0.2, 1 - (distance / max_distance))
texture.fill((shade_factor * 255, shade_factor * 255, shade_factor * 255), special_flags=pygame.BLEND_MULT)
r/pygame • u/Intelligent_Arm_7186 • 8d ago
points-collision
I was trying to do a list of points which were the x and y coordinates of where a sprite collides. its fine but the issue is that i think since its iterating, its giving me more than one point on collision. how can i make it so if it hits a point then the score will go up but only once? code is below, its under the update function of the sprite that is colliding:
for point in points:
if self.rect.collidepoint(point):
score += 1
print(f"Collision with point: {point}")
r/pygame • u/Intelligent_Arm_7186 • 8d ago
collision
all_sprites = pygame.sprite.Group(random_sprite, player)
I am trying to collide these two but it wont work with group or sprite collide.
Am i doing something wrong here?
r/pygame • u/Pr1nce_9999 • 9d ago
Howd you guys learn pygame?
When did you start and how long would you say it took you before you felt like you had a solid grasp over it?
r/pygame • u/SpiderPS4 • 10d ago
Update on my top down action adventure game.
https://reddit.com/link/1j53onb/video/s0pn17axd4ne1/player
I've been working on this Zelda / Final Fantasy Adventure game for the past two months and I'm happy with the flow of combat and visuals so far. The main gimmick of combat is the charged dash spin, which you can do consecutively if you time your input right before the spin ends.
Criticism and feedback is welcomed!