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
0answers
15 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
1answer
13 views

Player not moving camera to the other side of the screen when hitting the screen edge

I'm working on a game where I want the player to appear on the other side of the screen when they get to the edge of the screen, essentially mimicking the background moving. When the player gets to ...
0
votes
0answers
11 views

PYGAME - Sprite movement seize to function when entire X and Y span is reviewed

I've created an sprite class that has a detection radius checking if the player enters the zone. If yes, the sprite moves towards the player. It works perfectly fine when the sprite checks for three ...
0
votes
1answer
25 views

Rendering tiles at a larger size for a detailed look

I'm trying to make my 32-bit tiled map become more "zoomed" in. However, I experience an error that I can't resolve. Firstly, I followed this post on how to render the tiles larger. This is ...
0
votes
1answer
20 views

How to get object or its index from mouse coordinates?

Basically, I have a NumPy array of rectangles that store their colour and position. I want to be able to compare my mouse position and clicked on the rectangle's position and get the index or the ...
0
votes
0answers
34 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
1answer
40 views

Animating from json file in pygame?

I have got a json file and I am trying to load the single sprites from that file but I gives this error after a few loops and also the animation is not smooth(gets stuck) error: ...
0
votes
2answers
38 views

How can I create a boundary so the sprites don't go off screen?

I'm attempting to create a boundary around the window to stop the sprites of my game from escaping but it doesn't seem to be work, when they hit the area where its supposed to stop them it instead ...
1
vote
1answer
45 views

Using multiple pygame_gui managers

I would like to structure my gui into different panels. so to help keep my code managable i thought it might be a good idea to have a main panel. with its own manager and then a secondary panel with ...
1
vote
1answer
39 views

The gameloop is stucking the window

I tried to display a player image in a 800x600 window using PyGame but when I try it, the window just gets stuck (immovable with mouse drag, minimize,maximize and close button is stuck and not ...
0
votes
0answers
67 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
0answers
29 views

How to load a new map when player reaches a certain point using if tile_object.name == 'door" (pygame)

I have been working on creating a 2d game, and I am now at the point where I want the character to be able to interact with his environment. I have created a few different obstacles such as a house, a ...
0
votes
0answers
55 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
0answers
88 views

Using pygame with multiple threads

I have decided to try out pygame. I created a class that is supposed to handle all the GUI and game related stuff. My idea is that I would have two seperate threads. One to handle the GUI and one to ...
0
votes
0answers
23 views

How can the game graphics be stabilised when after each frame hundreds of calculations are taking place? [duplicate]

I am building a very basic 2D game purely using pygame library in Python 3x. The "game object" is blit(ed) onto the screen using a loop and after each pass, there are calculations taking ...
0
votes
0answers
49 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 ...
1
vote
1answer
53 views

delta_time with discrete movement

I have a basic snake game movement system with Pygame: ...
0
votes
0answers
19 views

How to fix edge scrolling on a 2d scrolling camera?

Afternoon all, I just cannot get this to work properly and I'd really appreciate any help. I have a camera that follows the player around a 2d tile based map. However, I want the camera to move only ...
0
votes
0answers
27 views

Pygame - RPG Battle-Style Animation and movement when not controlled by player

Examples: https://www.youtube.com/watch?v=C2cOiFntLY4 https://www.youtube.com/watch?v=iHl1YFkeR78 I am making a small little RPG based on a text-adventure game that I made. This RPG involves a battle ...
0
votes
1answer
37 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
1answer
24 views

I want my shapes to stay at screen

I am working on a paint project and it's almost complete but I want it to behave like the ms paint , in which whenever we draw an object (rectangle ,line) it shows it on the screen while we are moving ...
2
votes
1answer
74 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
2answers
43 views

Rotating Cannon's Mouth Toward Player

I am trying to make my cannon mouth rotate towards player, but the rotation is messed up and up I don't know how to fix it. ...
1
vote
1answer
116 views

Implementing melee combat in pygame?

I've gone about 2 ways for implementing melee attacks however, bboth have major flaws, hoping someone has a simpler answer. Method 1: Creating a "projectile" that's using an image, then ...
1
vote
1answer
73 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
votes
1answer
37 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
1answer
36 views

EndScreen Not Loading My Best Score And Current Score How To Fix?

I am trying to make my endscreen save last score and current score but it just appears as 0 for both everytime I die event he I picked up the coins image so basically it isnt saving my coins I had and ...
0
votes
1answer
90 views

Pygame End Screen Problem How To Fix?

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
0answers
50 views

Enemies Bullet Shooting At Player Problem How To Fix?

I am trying to make my enemies shoot at my player rect where ever the position the player is and when it collides with the rect it should remove the -1 health ***my problem is that when the enemy ...
-1
votes
1answer
67 views

Tiled Map Editor Vs Text File? | Pygame [closed]

I've only recently got into coding and was looking around on how to create a 2D platformer, a lot of tutorials I've seen have used text files to create their maps. However, one I saw in particular ...
0
votes
0answers
49 views

Problem WIth Enemies Bullets PyGame

I am trying to make my enemy shoot my player but for some reason the bullets arent showing nor they are shooting at the player I don't even know why, I even draw the bullets on my window VIDEO ...
0
votes
0answers
30 views

Pygame Collision | Why do I slide up walls in my tile based game?

My player if in contact with a wall either left/right/top(head) they will be able to just continue in the Y direction if you press jump as if you were flying. This is for all walls and invisible walls ...
0
votes
0answers
39 views

Pygame Tiled Map Object layer collision

I'm using pygame to make a top down shooter I've placed my tiles and object layers using Tiled Map Editor. My player and mobs collide with their spawn locations (object layer) is anyone able to help? ...
0
votes
1answer
89 views

Pygame Scrolling Bug With Enemys

I have a problem with my enemy where when my player scrolls left the enemy scrolls with the player is there anyway to fix this even Video my full code is below its to long to fit here though what I ...
0
votes
1answer
65 views

how do you get pygame to register multiple key presses at the same time

every time i try to operate player one and two or try to use the pickup key it stops the players.plz help here is my code- ...
0
votes
1answer
41 views

Player won't move correctly due to gravity force pushing him into the ground

I am making a tilemap platformer with pygame ad I defined the X and Y movement for the player and also a Y force that represents the gravity force to make it jump correctly. However, when my player ...
0
votes
1answer
35 views

Why doesn't my Pygame game scroll properly?

When I am clicking the arrow keys, in order to scroll my ground and my lucky block, I cant just press the key and it keeps on going scroll. So I need to press the key every second to get a kinda ...
0
votes
1answer
63 views

How do I make my level scroll side-to-side as the player moves?

I am trying to figure out how can I make a side-scrolling view in Pygame. If I am moving right or left, I want the portion of the level shown on-screen to shift to follow the player character. Here ...
0
votes
1answer
73 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 ...
0
votes
1answer
66 views

How to add multiple floors to a map in a text-based game?

I decided to learn how to make games during this quarantine. I am reading Mission Python, a book that teaches how to make games using python and pygame. I'm halfway through it, but the game only has ...
1
vote
2answers
305 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
1answer
362 views

Is there a way to get relative center of a Rect object in pygame?

Now, suppose I always want to draw a circle at the center of a rect object, now, the problem is: For example, if I do ...
1
vote
1answer
259 views

Why is my program “not responding” when I run it?

I'm trying to learn to code with python and while using pygame, I came across this: every time I run the window it says "not responding". Specifically, it happens when I click to drag the window; the ...
0
votes
0answers
30 views

Improving the efficiency of a grid-based ecosystem simulation

I'm trying to create a grid-based ecosystem simulation game. The design I came up with is something like a 1000 x 1000 (or larger) grid, with each cell being a representation of an object containing ...
0
votes
0answers
702 views

How can I remove a sprite from the screen using pygame?

I am having trouble with removing sprites on my screen using pygame. I am killing my sprite with sword.kill which is removing it from an all_sprites group, so it should disappear right? Here is ...
0
votes
0answers
42 views

How do a make a smooth animation with images of different sizes in pygame?

I have an animation where my player swings his sword, with 5 images in pygame. The normal resting image is 14x22, and the rest are 13x23, 21x23, 18x23, and 18x23. I am having trouble with my character ...
0
votes
0answers
64 views

How to stop snake game stuttering?

I have the following code and it seems to work pretty well except that every once in a while the program stutters and the snake teleports forward a few spaces. I can't tell what this is related to. <...
0
votes
0answers
132 views

pygame multiple collisions between two objects

Ok, so I have been trying to figure out how to set this up and can't get it working properly. I'm trying to get the functionality similar to the moving logs in the game Frogger if you are familiar ...
0
votes
1answer
112 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
vote
1answer
95 views

Problem with diagonal collision response using PyGame

So I have been having this problem for the last few days and it has me really frustrated. What I am trying to do is resolve collisions with custom hitboxes in PyGame and it looks something like this: ...

1
2 3 4 5
8