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
0 votes
0 answers
29 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
29 views

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

...
esnar moquete's user avatar
0 votes
0 answers
25 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, ...
Tiimzy's user avatar
  • 133
1 vote
1 answer
50 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:...
Tiimzy's user avatar
  • 133
0 votes
0 answers
30 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
82 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 ...
Tiimzy's user avatar
  • 133
0 votes
1 answer
62 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
172 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
191 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
59 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
113 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
32 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
68 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
134 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
69 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
72 views

pygame.error: video system not initialized

I don't know what's going on when I try to run pygame this error occures everytime no matter how much changes I have made. HERE'S THE CODE: ...
opidas's user avatar
  • 1
0 votes
0 answers
64 views

Make pygame rectangle disappear when ball collides

So I'm doing a brick breaker game using Pygame. I want that everytime the ball hits a brick, that brick disappears (idk how) Here's my code: ...
LGM's user avatar
  • 1
0 votes
0 answers
29 views

Why doesn't my image and text appear?

This is my code in question: ...
David Tan's user avatar
0 votes
0 answers
37 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
165 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
133 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
0 answers
49 views

PyOpenGL-Demo sample code -- exiting app doesn't work

I am using the cube.py sample from PyOpenGL-Demo, and there is this snippet there to handle the app exit when user presses the Esc key: ...
PaulM's user avatar
  • 101
0 votes
0 answers
64 views

Why is my code giving an infinite while loop/crashing?

I have this large code that produces buttons that are meant to be clicked. ...
3141592654's user avatar
0 votes
1 answer
48 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
108 views

How do I get my character to move?

This is my code: ...
David Tan's user avatar
1 vote
0 answers
142 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
352 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
409 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
133 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
370 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
277 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
583 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
193 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
114 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
68 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
1k 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
345 views

Pygame does not respond when running this program in PyCharm

...
hasan abbas's user avatar
0 votes
0 answers
61 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
3k 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
82 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
674 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
206 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
529 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
118 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
1 vote
1 answer
2k 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
  • 47
0 votes
1 answer
423 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
508 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
76 views

Error when creating random buttons

...
kot may's user avatar

1
2 3 4 5
10