Questions tagged [pygame]
A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.
458
questions
0
votes
0
answers
77
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
131
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
1
answer
40
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
1k
views
How to restart game from end screen, rather than resume the previous game state?
Video as you can see there I am trying to make my end screen restart my game but whats happening is that its not restarting my game its just loading the same thing when I die >> how could I make it so ...
0
votes
1
answer
61
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
50
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
2
answers
509
views
Pygame.display.set_icon unable to show transparecy
On Python 3.2.5 32 bit, I installed pygame. I made some code with it. It included pygame.display.set_icon(image). The image file is .png and I loaded it by using <...
0
votes
1
answer
2k
views
python sockets: receive data only when data is available?
I am writing an update to a game I have written in python, and I am currently adding server support. I can't show you the main code (for the client), as it is hundreds of lines long. However, what I ...
0
votes
1
answer
573
views
Why does collision only work sometimes when there are multiple objects in the game?
when i was making a pygame in python for the first time
i kinda have a problem where sometimes the player and the object would touch and the game would not close as intended i dint seem to find the ...
1
vote
3
answers
1k
views
Pygame polygon click detection
Here is my problem: I am creating a game and I have a board made out of polygons (hexagons). I want to be able to click on the different tiles but I can't find a simple method. I understood how to ...
0
votes
2
answers
130
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
0
answers
47
views
Line collisions in pygame
I am very new to python and pygame.
I am taking a class and we have to do a simulation where lines are randomly generated, and we have to check if they intersect with 6 straight lines displayed on the ...
1
vote
2
answers
454
views
How can i make a sprite appear middle of your cursor? Pygame
I made a sprite (hitmarker) to appear middle of your mouse when you click on a sprite (egg), but the hitmarker sprite appears at the right bottom of your mouse like this:
however, I wanna make it ...
0
votes
1
answer
100
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
1
answer
206
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, ...
2
votes
1
answer
712
views
Collision in PyGame for spinning rectangular object.touching circles
I'm creating a variation of Pong. One of the differences is that I use a rectangular structure as the object which is being bounced around, and I use circles as paddles. So far, all the collision ...
0
votes
0
answers
15
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
63
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
52
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 ...
5
votes
2
answers
1k
views
Simple 2D games - what is faster to render - images or drawing?
I am developing simple 2D environment in Pygame (Python 3.6), however I think this question is general. The environment is moving (player is rendered on the same position and everything else is ...
0
votes
2
answers
161
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
194
views
0
votes
0
answers
33
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?
...
0
votes
1
answer
594
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 ...
3
votes
1
answer
481
views
How do I make mask work
I have been trying to make a game, but mask collision doesn't seem to work. Here is my code:
...
0
votes
0
answers
42
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
172
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 ...
1
vote
2
answers
2k
views
Is there a way to make a game that uses Python/pygame that will work through a web browser?
Is there any framework or method that will allow to use browser to run a 2D game made in python with pygame graphical library?
1
vote
2
answers
450
views
Pygame - Maze collisions problem
I am a beginner in Python and Pygame and I have a problem with my game in pygame. I have Maze class and Player class but I can't do proper collisions. I reached the moment where I have no idea why my ...
0
votes
1
answer
5k
views
In Pygame, how can I check if an object is touching a color?
Is there a way to tell if a sprite is touching a specific color on the screen, maybe given as a hex code. I know you can do pygame.sprite.collide for sprites, but ...
1
vote
2
answers
1k
views
How can I publish a Python game on itch.io as html?
I'm making a game with Python, using Pygame. I want to publish my game on itch.io so that it's playable in the browser.
Is there a way to do this? If so, how?
0
votes
2
answers
4k
views
Clearing screen in Pygame so content on the screen is not lost, but updated
I am creating a Tetris game using Pygame. It generates a random shape from a list and draws it onto the screen. However, when the arrow key is pressed by the user, it draws the shape again without ...
2
votes
1
answer
542
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 ...
0
votes
1
answer
281
views
How do I update this code to hit a moving target from a moving shooter?
I am working on a game where one spaceship("Origin") can shoot a dumb projectile("Projectile") at another spaceship("Target").
Since the target is moving we will have to ...
0
votes
1
answer
200
views
How do I change only the angle of a certain PNG relative to the position of the mouse? (Python, Pygame)
Basically, I'm doing a game for a school project and I am not really sure how to make a player point towards the mouse pointer in a pygame tab. also if anyone has ideas of how i could point a bullet ...
0
votes
1
answer
70
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 ...
0
votes
1
answer
221
views
Turn-based grid movement - each click of the clock you want to move the player
I am working one the movement for a tactical turn-based pygame.
I'm stumped as to how to get a selected object to move one tile at a time up to it's max movement to the mouse's pos.
Right now this is ...
0
votes
0
answers
336
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 ...
0
votes
1
answer
230
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, ...
0
votes
1
answer
71
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 ...
1
vote
1
answer
507
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) ...
0
votes
0
answers
99
views
Draw Surface using destination rect in pygame
Is there a way to draw a region of a pygame Surface into another region on a target Surface?
If I have a screen ...
0
votes
1
answer
272
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 <...
1
vote
1
answer
202
views
Problem With Enemy Bullets Attacking The Player Pygame
I am trying to make my enemy bullets attack the player but it only attack its x and y how could I make it curve instead of zigzagging VIDEO the bullets only attack the y axis and it wont curve or go ...
0
votes
1
answer
69
views
How to disable pause() in game_loop() once game_over() function is called?
How can I disable pause() in game_loop() once game_over() function is called?
game loop
...
1
vote
2
answers
3k
views
How do you rotate a sprite in pygame?
I am making a game in Pygame and I want it so every time the sprite jumps it rotates mid-air and lands on its side. A lot like Geometry Dash jumping if you have ever played that. I have some code but ...
-1
votes
1
answer
248
views
Collision detection / physics for simple game
I am currently working on a mini game for class (first time doing something like this) and I don't really know how to start with collision detection at all. The game I'm creating is a top down sumo ...
-1
votes
2
answers
76
views
1
vote
1
answer
361
views
Using collision with classes in pygame
I am trying to make some games using classes. But I got a problem when trying to make the ping pong game. I made 2 paddles and a ball but I just do not understand how should I make the collision ...
1
vote
1
answer
80
views
What is the easiest way to make pixelated maps with obstacles in pygame?
So I have been trying to create a game with a small map that moves with the player. If the player goes to a wall, the camera also stops. No scrolling. If you want to discover an area, you go to it. ...