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
20 views

Freecodecamp video Python platform, I followed everything but getting error of AttributeError:'Player' object has no attribute 'draw' any help why? [closed]

I followed the video to a Tee and I am stuck on part 27:29 timestamp to help you understand where I'm at, so far no problems otherwise.
0 votes
0 answers
36 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
0 answers
55 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
2 answers
82 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
1 answer
78 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, ...
0 votes
1 answer
79 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
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
54 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
47 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
2 answers
106 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 ...
  • 1
0 votes
0 answers
99 views

Pygame does not respond when running this program in PyCharm

...
0 votes
0 answers
31 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? ...
  • 1
0 votes
1 answer
291 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 ...
0 votes
0 answers
41 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
114 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 ...
0 votes
1 answer
55 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 ...
2 votes
1 answer
359 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
0 answers
288 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 ...
  • 1
0 votes
1 answer
58 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
336 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) ...
  • 47
0 votes
0 answers
75 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 ...
  • 4,366
0 votes
1 answer
190 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
218 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 votes
2 answers
76 views

Error when creating random buttons

...
1 vote
1 answer
259 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 ...
  • 15
0 votes
0 answers
15 views

Is there any way to compile a python script to web like unity webgl [duplicate]

I've been working on a game in pygame for a while and decided it was too much of a hassle to compile it to all the operating systems. So, naturally, I turned to the web. While I am well aware that you ...
0 votes
1 answer
967 views

Why do I get this error: "error: video system not initialized"?

The error occurs when I call keys_pressed = pygame.key.get_pressed() Here is the full code: ...
0 votes
1 answer
83 views

In pygame I am trying to add the text as an integer and it keeps crashing, why?

I am trying to convert the string as an integer when I am using the font.render() function but it keeps saying different things like it has to be a unicode or ...
  • 15
0 votes
0 answers
80 views

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

Basically, I created a grid with this: ...
0 votes
0 answers
85 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
161 views

How to properly set up a lives system for a side-scroller in pygame

I have a game where the player has to dodge asteroids coming towards it, and I would like to incorporate a life system. Unfortunately, when I tried this, it still killed my player immediately. I ...
0 votes
1 answer
205 views

1920x1080 Image don't fit to 1920x1080 screen

I'm making a game with pygame and I wanted to add a background for my game. I'm trying to add a 1920x1080 background to a 1920x1080 screen, but part of the background is not visible. My code: ...
0 votes
1 answer
410 views

pygame only moving when moving mouse

Every time I press the left or right arrow keys it moves a little however when I wiggle the mouse around while pressing the keys the player flys across the screen for no reason. I'm following ...
  • 1
1 vote
1 answer
52 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
2 answers
1k 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?
  • 133
0 votes
1 answer
78 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
41 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 ...
1 vote
0 answers
760 views

Circle and circle collision (with physics), but when lots of circles pile up things go wrong [closed]

I'm trying to make an as realistic as possible ball physics simulator. Currently, I worked out all the collisions between balls, and it works really well when there are few balls. But once you create ...
0 votes
1 answer
1k views

Collision detection between moving objects (in pygame)

I am trying to work out how to detect and resolve collisions between moving sprites in pygame, I followed the logic of this video: https://www.youtube.com/watch?v=VpSWuywFlC8 The basic idea is that I ...
0 votes
1 answer
41 views

How can I make pygame use a specific input device as the mouse?

I am working on (not really a game, but it's using pygame so I hope my question is on topic here). The program appears to be looking at /dev/input/event0, which is ...
0 votes
1 answer
297 views

How can I make a hitbox around my image?

I'm really new to PyGame and trying to program a game, and I can't figure out how to make a hitbox that when this image hits the edge, the game stops it from going past the edges ...
0 votes
1 answer
52 views

circles originating from player position not showing up on pygame window

I'm kinda new to python and pygame, anyone know why this won't show bullets coming out from my character? ...
0 votes
1 answer
186 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
325 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 ...
  • 101
0 votes
0 answers
74 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 ...
1 vote
1 answer
75 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
2 answers
2k views

How to make objects move continuously while a key is pressed in pygame?

So I made a new game in pygame and after hours of debugging, I got to a stage where all of my objects get blitted onto the screen. Well, that's great but now I want movement for a particular object. I ...
0 votes
1 answer
188 views

How can I move the object constantly downward in pygame?

I want the object to move continuously downward even while I'm pressing the upward key in keyboard. Eventually causing the object to drop completely after some moment. ...
2 votes
0 answers
75 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 ...
0 votes
1 answer
250 views

Pygame : having trouble with implementing movement with vectors

I've been struggling a lot to learn how to use vectors in programming. Now I've successfully made my own vector class but I still can't use vectors for movement. This is my class : ...
  • 216

1
2 3 4 5
10