Questions tagged [pygame]
A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.
487 questions
0
votes
0
answers
67
views
Applying greyscale shading to objects in a Python 3D renderer
I need help with how to apply greyscale shading to objects in a 3D renderer I made in Python. The code is pasted below:
...
0
votes
0
answers
150
views
Why does a sprite with a larger texture render faster?
While drawing a map for a game in Pygame, I encountered a strange problem. Loading my grass sprite, which is a little over a kilobyte, and placing it, the FPS dropped by half. However, replacing the ...
0
votes
0
answers
21
views
How do I make smooth 2 way shooting in pygame? [duplicate]
I have been trying many thing to make my code work to make a player shoot a small box both ways (left and right) without being able to change the direction of the projectile mid shot.
I would be very ...
0
votes
0
answers
105
views
How do I create a shooting tool that works on both sides?
I am a fairly new user of pygame and i decided to start out with a simple but 'funny' game.
I have successfully implemented jumping mechanics, movement mechanics and a one directional shooting ...
0
votes
0
answers
71
views
Pygame won't display volume control
I'm making a game in Pygame running in Python 3.10 and the lastest version of pygame, and I can't get to display a volume control for the background music . The music is played correctly, but there is ...
0
votes
1
answer
146
views
Can I Create a Camera System in Pygame Without Using Classes?
I am working on a basic side scroller platformer in Pygame. I want to add a camera system that tracks the camera and scrolls the world and I want to make the camera systems without using Classes. ...
1
vote
1
answer
94
views
Pygame display.Info() / fullscreen not working under Linux
I am experiencing some issues with pygame.display.Info() and the FULLSCREEN property on Linux. The game is displaying at roughly ...
0
votes
0
answers
62
views
How to use sensors and ray casting for collision detection in Pygame (using a custom Mask/sensor class)?
I am making a Sonic game in Pygame and I have recently gotten my hands on a Python class that uses pygame.rect and pygame.mask in unison to create sensors that can be used to accurately detect the ...
1
vote
0
answers
88
views
How to handle collision events in games with multiple interactive objects?
I'm developing a 2D game where multiple types of objects interact with each other through collisions. Currently, I'm using pygame.spritecollide() to detect ...
0
votes
1
answer
204
views
Score counter in Python game assigning points to both players
I am trying to learn to code a simple game with 2 players shooting at horizontal-moving enemies from the bottom of the screen.
Everything is working fine except for this:
When player 1 hits enemy ...
0
votes
0
answers
63
views
How to Make Circular Space After Collision?
How to make circular space after collision like this?
Before collision:
After collision:
I'am using PyGame
0
votes
1
answer
181
views
How can I improve vector collision algorithm?
I'm making a game (shocker) in pygame and had issues with tile-based collision detection. There are 5 different non-empty tile types (pictured below) which can be rotated in increments of 90 degrees ...
1
vote
1
answer
124
views
Reading steering wheel events has 180 degree dead zone. How to remove/reduce dead zone?
I'm making a GUI that can be controlled by a steering wheel. It need only run on Windows.
It works as expected with exception of the fact that the first 90 degrees in either direction seems to be ...
1
vote
1
answer
117
views
Connecting Isolated Paths in Randomly Generated Maps
I am new to game development, I previously created games using tiledmap editor and pygame, but manually creating map was real pain, so i begun to look how can i procedurally generate map, after ...
0
votes
0
answers
160
views
How to make a tilemap in pygame?
so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help ...
0
votes
0
answers
66
views
How can I change checkers pieces to move only horizontally and vertically?
I am a beginner level programmer trying to learn Python. I could not figure out how to change the values so I can restrict the pieces of checkers from moving diagonally. I want them to be able to move ...
0
votes
0
answers
63
views
1
vote
1
answer
89
views
Player not sliding on the side of a wall when two keys are pressed
I am making a game right now, and I am working on collision for different Rect walls (all of their data is stored in a list). It works great, except for one problem:...
0
votes
0
answers
459
views
Collision between a sprite and a rect in PyGame
I'm trying to make a simple platformer game, which has code to move the camera towards a player as they jump around.
Now I have two classes: one for the player, and one for the platform.
In the ...
2
votes
2
answers
191
views
How to stop moving a sprite if the user is holding down the opposing moving key at the same time?
I am new to creating games with graphics, and I want to make a very hard game. I have the movement down, but it has a weird bug where it if the user presses down the opposing movement key (i.e. A is ...
0
votes
1
answer
166
views
Bounding Box/Rectangle collision glitches
I've been working on this golf game for a couple of weeks and have been trying to create a reliable collision system for whenever a golf ball (mini golf) hits a block. I'm using regular rectangular ...
0
votes
2
answers
323
views
Infinite scrolling with mouse
I know we're able to scroll a background image hardcoded or using awsd keys(or arrows) if they're pressed. But what about scrolling it with mouse movement? So I have a piece of panoramic image as a ...
0
votes
1
answer
704
views
Pygame code/file structure
I am currently working on a Pygame project and would like to seek your advice on best practices for organizing my code, particularly when it comes to creating additional scripts. I find myself ...
0
votes
1
answer
105
views
Sprite chasing a target using move_towards_ip does not move
I'm trying to get a turtle sprite to chase a falling algae sprite utilising Pygame's inbuilt functionality. I have spent many hours reviewing questions and answers and suspect I'm missing some ...
2
votes
1
answer
322
views
How do I mix an image with a specified color?
I have some images of static objects using per-pixel alpha (trees, rocks) for a background. In order to make them look a bit more natural, I want to create some kind of atmospheric fog, which means ...
1
vote
1
answer
109
views
Selecting Tiles Correctly With Scroll
I would like to understand the process of selecting the correct tile from a scaled Surface when I have information about the number of tiles on the x and y axes, the length of the Surface, and also ...
0
votes
1
answer
450
views
Sprite Animation in Pygame Zero
How do I use a sprite sheet in pygame zero?
The height of the images are 32, width is 25
0
votes
1
answer
151
views
Client and server with fixed tick in pygame
I'm trying to write a 2D RTS game with maximum of 10 players.
When server finish intializing each player receives start coordinates and game start time so each client will start processing ticks ...
0
votes
0
answers
78
views
Perspective projection distortions
I'm building my own engine using python and pygame however my cube model is not able to be displayed correctly. This is my result after applying translation, scaling and projection matrices:
...
0
votes
1
answer
355
views
PyGame moves object in one direction but not in the opposite one
I'm having trouble with a PyGame animation I'm writting. I have a Ball class that defines an object that moves on the screen and bounces on the edges. I initialize ...
0
votes
1
answer
237
views
Perspective projection not working as intended
I copied a perspective projection matrix from here (https://jsantell.com/3d-projection/) and applied it to my vertices. It looks ok but without depth. Rotation matrices also work.
When I try to divide ...
0
votes
1
answer
90
views
Why doesn't the fire appear when moving code to a function?
This is my code:
...
0
votes
2
answers
286
views
How do I get my character to move?
This is my code:
...
1
vote
0
answers
251
views
Why don't people use try-finally to call pygame.quit() in pygame programs?
I've seen several games made in Pygame, and none of them uses try/finally to call ...
0
votes
1
answer
642
views
Variable not updating while program is running
I am having issues where the variable action_cooldown does not update. I could remove this but then both the player and enemy attack at the same time, which is something you do not want in a turn ...
0
votes
1
answer
917
views
How to get better performance with pygame?
I'm not a gamedev, I'm a API/Cloud dev, performance has never been an issue for me since most of the time we are limited by network calls.
I've been playing with that for the past 2 days, I wanted to ...
0
votes
0
answers
197
views
How do I reduce the size of a sprite hitbox?
I am making my own pygame game, but I want to reduce the size of the player's hitbox in order to make dodging bullets easier.
...
0
votes
1
answer
647
views
for event in pygame.event.get(): pygame.error: video system not initialized
I'm going through a tutorial and trying to build a game using Python and struggling to resolve below error. Not sure what I'm missing here can someone help with it
Alien_invasion.py
...
0
votes
2
answers
465
views
Collision detected early between images
Im making a "catcher" style game in python, where the player has to collect "Gems", and avoid the "Spikes". However the games collision detection is off by quite a lot. ...
0
votes
1
answer
972
views
Having trouble trying to figure out why pygame.sprite.Group's draw method isn't working properly, but switching to player sprite does work
Goal, Description & Scope (when encountered issue)
I was building a testing script to see how implementing different ideas (event handling, update handling, draw method) to loading sprite images, ...
0
votes
1
answer
240
views
Collisions detected prematurely, before rectangles actually touch
I am creating a game with Pygame but my collisions are registering too soon. I'm using this code to end the game when the player collides with a pipe:
...
0
votes
0
answers
24
views
Find which tiles are intersected between two points on an isometric tilemap [duplicate]
I need to be able to find out which tiles are intersected when a line is drawn between two points.
I'm currently working with a isometric perspective which makes things a little more complicated.
I've ...
0
votes
1
answer
227
views
How to move blocks down to fill the gap after clearing a row in Tetris?
I'm working on a Tetris clone. When I clear a line, my code does this:
I want to move the squares down + 1.
My code is:
...
0
votes
0
answers
85
views
Game window freezes whenever enter is pressed on textbox
I recently programmed a game in Pygame and added a text box (which I made using pygame_gui) which will send data directly to a MySQL database. But whenever I type ...
0
votes
2
answers
2k
views
does having code spread in multiple files decrease performance?
Let's say there's a game that I could code in 1 file main.py but I decide to split it in more files like:
main.py
graphics.py
settings.py
interface.py
menu.py
and so on, would the game in turn perform ...
0
votes
0
answers
441
views
0
votes
0
answers
91
views
Emulating a Forza telemetry server and/or an OBD Bluetooth adapter (in Python)
I'm making a driving game in Pygame, and want to give a player the option to send game data to a Forza-compatible dashboard app (like SIM Dashboard) or to an OBD app (like RevHeadz). How do I do so?
...
2
votes
1
answer
5k
views
Creating a nav mesh
I'm coding a custom engine using Python and Pygame. It's a top down 2D isometric RTS and I wan't to implement pathfinding for my units.
My research has lead me to using a Navigation mesh which seems ...
0
votes
0
answers
147
views
Connecting nodes for A* algorithm
I am currently working on implementing a pathfinding module for my 2D game engine that I am writing in Python using Pygame.
Currently there are objects such as trees or buildings which can be placed ...
0
votes
1
answer
2k
views
How fps limiting works in pygame (specific example)
I recently wrote a program where I needed to limit the fps. After some searching I found a way via pygame built-in methods pygame.time.Clock() and ...