Questions tagged [pygame]
A game development library based on the Python programming language. It wraps SDL for easy use alongside Python.
75
questions with no upvoted or accepted answers
4
votes
1
answer
239
views
Issues with player movement and character interaction within Pygame
I am working on a small game that deals the main character, which is a cat, and dogs that chase it. The dogs are able to wander around like they are supposed to do, but the cat will only move a small ...
3
votes
0
answers
75
views
SGC toolkit for PyGame and resizeable windows
Can I create a resizeable main window if I use the SGC GUI toolkit for PyGame? If so, how?
2
votes
0
answers
88
views
Pygame RESIZABLE display flag not working as expected on display re-initialization
I'm working on a simple script to be used as a personal code skeleton for pygame projects (making this primarily for practice with Python, PyGame, and game design) but I'm running into an issue with ...
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 ...
2
votes
1
answer
2k
views
How should I implement a dialogue box in Pygame?
I'm working on a small RPG with Pygame, using Python 3.5.1. I've spent a week trying to find a decent tutorial or example for a dialogue box implementation that would pull dialogue from a source file (...
1
vote
1
answer
56
views
Optimizing overlapping units vision calculations in RTS using PyGame
Currently I'm developing a RTS game using Python/PyGame and I got some problems with fps drops when there are many units on the screen.
Using Snakeviz profiling I found out that the function ...
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. ...
1
vote
1
answer
187
views
How do I draw my particles when an enemy is killed?
I have enemies that move left and right.
I was wonder how I could make my particles show up when the enemy is killed?
Here is my particle class
...
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 ...
1
vote
0
answers
180
views
Calculate velocity to hit the target on flat 2d surface
I am creating a game using Python and Pygame.
I have used this function before (with JS with p5.js and Java with libwjgl, but for some reason it does not work with pygame (I am not sure if it matters ...
1
vote
0
answers
284
views
Pygame collision
I'm making a dungeon game, and I'm making the collision system.
There is an object obstacle, which has got these properties:
...
1
vote
0
answers
412
views
Reimplemented steering seek behavior from PyGame to LÖVE is much slower than original
I'm learning about steering behaviors and watched this nice explanation tutorial - https://www.youtube.com/watch?v=g1jo_qsO5c4&feature=youtu.be with the source code available at https://github.com/...
1
vote
0
answers
158
views
Collision for array of pathfinding zombies to array of blocks
Relevant Background Information
I'm an eleventh grade high school computer science student in Canada. I'm doing pretty well in the course currently, I have a 96 in the course currently. We're working ...
1
vote
0
answers
283
views
Why is my partially transparent image blitted fully opaque?
I have a part in my program that should display the currently playing song's name for the first 4 seconds, then fade out. Even though Surface.get_alpha() returns ...
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
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
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
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 ...
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
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 ...
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
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
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
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 ...
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
0
answers
107
views
Need to see if you clicked a rectangle in a grid. (Pygame)
Basically, I created a grid with this:
...
0
votes
0
answers
119
views
Not being able to display pygame.freetype text
I'm trying to make a game where the player has to dodge asteroids coming, and I'd like to display the lives. I looked up some tutorials and decided to settle on pygame.freetype. When I run the code ...
0
votes
1
answer
82
views
Pygame Traffic signal logic
I am currently working on a traffic simulator with Pygame, however i am struggling with implementing the logic of the traffic signals.
Any help is welcome.
My traffic simulation is grid based. The ...
0
votes
1
answer
44
views
How to generate reliable labels for game state using Python and Pygame
I've been looking into making a small game where you would walk around and do puzzles (perhaps do some combat if I can get the basic framework going). So far, Googling for general game patterns used ...
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
0
answers
403
views
What is a good method for 2D isometric lighting in Pygame?
I'm making my first isometric game in Python using Pygame. It's a 2D tile-based dungeon crawler, but I want to create a nice lighting system. I've made a random level generator that creates the rooms ...
0
votes
0
answers
96
views
frameskipping in Pygame?
I am struggling to find a solution on how to skip frames and keep the game at a constant pace, I had tried using
...
0
votes
0
answers
114
views
How to make player shooting?
this my code
...
0
votes
0
answers
68
views
Layer sprites according to their vertical position
I need advanced blitting options in my game. It's a 2D game that has trees' sprites along with the player's sprite.
I want that every tree sprite to be displayed either in front of or behind the ...
0
votes
0
answers
82
views
Pygame unaccurate key press event handling
I have a problem with my game_over() function in Pygame.
When the player loses, the game_over() function gets executed but since ...
0
votes
1
answer
257
views
Top-Down Tank Physics with Pygame
I am trying to make a top-down tank shooter game in Python and pygame, but I can't get the tank movement right. My objective is to make it move forward in the direction it is pointing in which would ...
0
votes
0
answers
67
views
Pytmx loads no tiles or textures, it seems
So, I've been trying to load a tmx file through pytmx But when it loads the file, it only loads a black image with the same resolution as the tmx file.
...
0
votes
0
answers
360
views
How to make a z-depth buffer with pygame?
I am making a 3d renderer with python and so far am sorting the triangles which I want to replace with a z-depth buffer. The thing is, I don't know how to make a z-depth buffer in pygame. I still want ...
0
votes
0
answers
31
views
How would you have a range of movement within a class in pygame?
I have blitted 4 zombies to the screen in pygame. First, the zombies will wander in a specific region (let us say a 10 x 10 area). And when the player enters any one of the zombie's areas, the zombie ...
0
votes
1
answer
64
views
How do I click on specific text in an array of text?
I am trying to click on a specific word in an array but I can't think of how.
This is what I have:
...
0
votes
1
answer
218
views
Pygame Platform & Player collisions
I am trying to create a platform game where a player jumps between platforms horizontally (using a projectile curve). Currently, I have a class that blits platforms and a background, as well as the ...
0
votes
0
answers
92
views
Where to store polygons and polygon animation?
I thought about making something with ApeOut graphics long before it came out and its release motivated me to try - I'm having tons of fun but I stumbled upon a pickle.
I can imagine storing polygons ...
0
votes
0
answers
95
views
diagonal movement to a enemy in pygame
I spent a long time trying to make the diagonal movement in the form of code but I don't know how to write it. the code I have so far is almost complete but it is missing the pixelart that I will add ...
0
votes
0
answers
58
views
Dashing mechanic in top down projectile dodging game in pygame
im making a simple third person top down game where you dodge projectiles than fly in from either side of the screen, its a simple high score game where the longer you avoid being hit, the better your ...
0
votes
0
answers
122
views
Sprite walk animation blurring when sprite image moves too quickly
I didn't see any other questions like this that had an answer so I thought I'd ask in hopes this helps someone else too. I have a game I'm in the beginning stages of working on, and I've gotten to the ...
0
votes
0
answers
163
views
Are you supposed to be looping through all PhysicsObjects at every step in a physics engine?
I am currently making a small 2D game and I am trying to implement some basic 2D physics. I currently have a list of around 100 PhysicsObjects which I loop through every frame in order to update and ...
0
votes
0
answers
314
views
Failed to execute script {pygame.exe}
So I've made an game which just has a script named "TrainYourBrain.py". I wanted to make an exe of it but I failed.
It just gives the error Failed to execute script TrainYourBrain
My game ...
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
0
answers
269
views
Scrolling background in PyGame with Entity Component System
I know this type of question has been asked to death for 'normal' games, however I am struggling with relating a scrolling background to an entity component system (ECS) approach.
Generic samples here ...