Skip to main content

Questions tagged [pygame]

A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.

Filter by
Sorted by
Tagged with
1 vote
1 answer
41 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 ...
Brian K's user avatar
  • 113
1 vote
1 answer
78 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 ...
Bishnu Chalise's user avatar
0 votes
0 answers
47 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 ...
Joshua Carlson's user avatar
0 votes
0 answers
61 views

How to optimize random path generation with checkpoints and collision detection

I'm looking for a way to generate a random path based on midi note onsets (timing points) for a simulation/game. I will briefly explain how it works for context: I'm working on a simulation type game ...
Ingmar's user avatar
  • 1
0 votes
0 answers
61 views

Poor performance with camera zoom

I've created a Camera class that takes a source surface and draws it to a destination surface using the camera's parameters (position, zoom, size, etc.). The class ...
Rich. T.'s user avatar
0 votes
0 answers
43 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 ...
OneSec's user avatar
  • 1
0 votes
0 answers
38 views

How could I make the player rotate towards the cursor in pygame?

...
esnar moquete's user avatar
0 votes
0 answers
35 views

Collision glitches when player runs into side of a wall

I am coding a game for fun, and I am trying to implement collision; specifically, I want the player to be able to move to the side even when ramming into a wall diagonally (I had this problem before, ...
Tiimzee's user avatar
  • 133
1 vote
1 answer
56 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:...
Tiimzee's user avatar
  • 133
0 votes
0 answers
159 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 ...
Divyansh undley's user avatar
2 votes
2 answers
109 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 ...
Tiimzee's user avatar
  • 133
0 votes
1 answer
78 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 ...
Jet's user avatar
  • 1
0 votes
2 answers
200 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 ...
Intice's user avatar
  • 31
0 votes
1 answer
326 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 ...
anathrax's user avatar
0 votes
1 answer
76 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 ...
Lone's user avatar
  • 3
2 votes
1 answer
164 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 ...
Intice's user avatar
  • 31
0 votes
0 answers
59 views

Pygame showing surfaces at wrong coordinates with full screen

So I coded this line for the display surface: screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN|pygame.NOFRAME) But the thing is, when I place a rectangle ...
Le Guide Minecraft's user avatar
1 vote
1 answer
75 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 ...
anathrax's user avatar
0 votes
1 answer
213 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
Tokyn Blast's user avatar
0 votes
1 answer
95 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 ...
Mirula's user avatar
  • 1
0 votes
0 answers
46 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: ...
Zoler1337's user avatar
0 votes
1 answer
235 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 ...
WinterPanda's user avatar
0 votes
1 answer
150 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 ...
Zoler1337's user avatar
0 votes
1 answer
49 views

Why doesn't the fire appear when moving code to a function?

This is my code: ...
David Tan's user avatar
0 votes
2 answers
143 views

How do I get my character to move?

This is my code: ...
David Tan's user avatar
1 vote
0 answers
170 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 ...
Orisphera's user avatar
0 votes
1 answer
488 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 ...
KianMckenna's user avatar
0 votes
1 answer
598 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 ...
sliders_alpha's user avatar
0 votes
0 answers
159 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. ...
Kai van Loon's user avatar
0 votes
1 answer
459 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 ...
user14932992's user avatar
0 votes
2 answers
360 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. ...
theHouseExpands's user avatar
0 votes
1 answer
750 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, ...
DracoDaine's user avatar
0 votes
1 answer
209 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: ...
Shantanu's user avatar
0 votes
0 answers
20 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 ...
Zoler1337's user avatar
0 votes
1 answer
137 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: ...
tony_ramos.98's user avatar
0 votes
0 answers
72 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 ...
cupbord's user avatar
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 ...
Lost's user avatar
  • 1
0 votes
0 answers
389 views

Pygame does not respond when running this program in PyCharm

...
hasan abbas's user avatar
0 votes
0 answers
70 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? ...
s3246's user avatar
  • 1
1 vote
1 answer
4k 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 ...
Zoler1337's user avatar
0 votes
0 answers
91 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 ...
Zoler1337's user avatar
0 votes
1 answer
1k 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 ...
anathrax's user avatar
0 votes
1 answer
235 views

Create list of images for animation

I'm using pygame and trying to create an animation by going through a list of variables: self.image = self.walk_right[self.index] I have loaded the images into ...
jacko_123's user avatar
2 votes
1 answer
1k views

Pygame moving only once when key pressed integrated into player class

I'm having an issue when I have created a player class and want to move my sprite in between three lanes. I was able to get the sprite to move when I used ...
jacko_123's user avatar
0 votes
0 answers
677 views

Pygame lags on simple game

I am trying to build a game in pygame, however any movement feels laggy. Its not a big lag but more like a small stuttering. I created a boiled down version to showcase this. The code in the git below ...
Ogorf's user avatar
  • 1
0 votes
1 answer
131 views

Pygame, jump counter resetting on first button press

Been learning my first platformer game based on this tutorial. I decided I wanted to go off book and make it so the player could jump a second time before hitting the ground. I used the blit function ...
jacko_123's user avatar
2 votes
1 answer
3k views

Efficient way to check collisions for many objects

I am making a Bloons tower defense game and I came across a problem with regards to collisions. The way my code currently works is all the current bullets on the screen(could be potentially thousand) ...
Aayush's user avatar
  • 57
0 votes
1 answer
497 views

How to convert a list into coordinates in pygame

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...
CodeWizard777's user avatar
0 votes
1 answer
586 views

How can I make a multi-line dialog box?

I'm trying to make a dialog box with pygame, and initially everything was going well. I printed the letters sequentially on the screen and it works very well in a single line of text, but when I use <...
Furkan125's user avatar
-1 votes
2 answers
77 views

Error when creating random buttons

...
kot may's user avatar

1
2 3 4 5
10