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.

91 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
4 votes
1 answer
248 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 ...
Taylor's user avatar
  • 41
3 votes
0 answers
80 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?
Timur's user avatar
  • 29
2 votes
0 answers
128 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 ...
Seth Lamancusa's user avatar
2 votes
1 answer
769 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 ...
OverAchiever's user avatar
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 (...
Diapolo10's user avatar
  • 131
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
1 vote
1 answer
69 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
1 vote
0 answers
154 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
1 vote
1 answer
77 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 ...
Zoler1337's user avatar
1 vote
1 answer
124 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. ...
Command_Blocks's user avatar
1 vote
1 answer
192 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 ...
lilly mosling's user avatar
1 vote
1 answer
237 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 ...
Habib Ismail's user avatar
1 vote
0 answers
212 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 ...
Mantas's user avatar
  • 11
1 vote
0 answers
309 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: ...
markop's user avatar
  • 11
1 vote
0 answers
433 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/...
Kosmetika's user avatar
  • 121
1 vote
0 answers
164 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 ...
Kyle's user avatar
  • 69
1 vote
0 answers
305 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 ...
Pixdigit's user avatar
1 vote
2 answers
2k views

Why doesn't my pygame window close on MacOS?

I am trying to create a window and then close the window. Everything runs smoothly until I click the red X. When I click it, the window doesn't close and all that happens is that the colourful red ...
AskedSuperior's user avatar
0 votes
0 answers
20 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
50 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
42 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
37 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
33 views

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

...
esnar moquete's user avatar
0 votes
0 answers
32 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
0 votes
0 answers
73 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
0 votes
1 answer
69 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
0 answers
45 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
0 votes
1 answer
76 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
81 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
93 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
30 views

Why doesn't my image and text appear?

This is my code in question: ...
David Tan's user avatar
0 votes
0 answers
41 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
0 answers
52 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
66 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
420 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
0 answers
146 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
202 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
71 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
0 answers
367 views

Pygame does not respond when running this program in PyCharm

...
hasan abbas's user avatar
0 votes
0 answers
64 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
0 votes
0 answers
85 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
0 answers
590 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
128 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
0 votes
0 answers
248 views

Need to see if you clicked a rectangle in a grid. (Pygame)

Basically, I created a grid with this: ...
sawdog535's user avatar
0 votes
0 answers
203 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 ...
CodeWizard777's user avatar
0 votes
1 answer
130 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 ...
Maurice's user avatar
0 votes
1 answer
52 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 ...
Oleg Pittman's user avatar
0 votes
1 answer
261 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 ...
luckee365's user avatar
0 votes
0 answers
678 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 ...
Jayce's user avatar
  • 101
0 votes
0 answers
147 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 ...
AidanGamin's user avatar