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
1
vote
0answers
38 views

Pygame rotation around center not working properly

here is the code I use to rotate an image around its center : ...
1
vote
1answer
38 views

Recycling bullets versus spawning them on demand

Until now, I know 2 bullets' algorithms/configurations : (I mean 2 ways of logically creating a bullet class) Make a bullet class and create only one instance from it that represents the bullet. The ...
2
votes
1answer
42 views

Can't check collision between a mask and a rect in pygame

I'm new to using masks in Pygame and I'm having trouble with them. I have already learned how to check collisions between two masks but I'm wondering about an effective way to check collisions between ...
1
vote
1answer
28 views

What is surface locking and unlocking in Pygame?

I've read a little about surface locking and unlocking in pygame in Beginning Game Development with Python and Pygame. However, I still don't understand it. I've read that it can improve the game ...
1
vote
1answer
58 views

Ensure that random enemies don't spawn just near the player

I need to find a method using which I can ensure that random enemies and objects don't spawn just near the player. In fact, if they do, the player will be more likely to collide with them and lose. ...
0
votes
0answers
20 views

Why isn't my player in its pygame rect?

I am making a game in pygame and my player is supposed to be in its rect but it's not. Here is my code, What is wrong and how do I fix it? ...
0
votes
1answer
61 views

How to make a number show how much the player will lose

Bit new to python. I'm making a game where you click on a strawberry, then it reappears in a new location, and so on and so forth. But you see, every time the player misclicks, they lose Score equal ...
0
votes
1answer
52 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
1answer
73 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 ...
0
votes
0answers
21 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
0answers
22 views

How I can get my pong ball collide on the paddle and bounce back?

Here is my code so far: ...
0
votes
0answers
18 views

pygame jump animation

So, I am trying to learn a little bit of Pygame and I really can’t get my little rectangle to jump. Using this code everything seems right to me. First the player should go up, then once ...
1
vote
1answer
13 views

Pygame some methods aren't working properly (collidepoint and get_rect)

I'm making a game menu in Pygame, consider the following block of code: ...
0
votes
1answer
55 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 ...
1
vote
1answer
51 views

What is get_bounding_rect() method in Pygame?

I got used to get_rect() when detecting collisions in Pygame but I've just discovered that another method called ...
0
votes
0answers
13 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
0answers
27 views

How to remove a sprite from a group?

I am trying to make a chess game with Pygame, but am unable to remove the chess piece when it is captured. Stack Overflow already has a question on this here. But this code doesn't seem to work. When ...
0
votes
0answers
20 views

Pygame tile_size scalling to fullscreen/resizable window

I'm a newbie and I ran out of videos to watch on how to scale your tiles/sprites to fullscreen/resizable window on Python using Pygame. When I try to resize the window it looks like this: When I'm in ...
0
votes
1answer
28 views

“contains support” for Dreamcast/Atari/etc, but “not officially supported”?

I found this on the About page on the official Pygame website: Truly portable. Supports Linux (pygame comes with most main stream linux distributions), Windows (95, 98, ME, 2000, XP, Vista, 64-bit ...
-1
votes
1answer
42 views

How to stop player from slingshotting across my game window

In my pygame dungeon rpg when my player collides with a wall at the top or the bottom of its rect and I move the player in either x-direction, the player gets slingshotted off the screen. Using print ...
0
votes
1answer
34 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
1answer
39 views

why doesn't spritecollide method work?

In my code, I wanted to use the spritecollides method but I got the following error message: Traceback (most recent call last): File "/Users/lanik2009/Documents/pygame testing.py", line 76, ...
0
votes
0answers
13 views

VS Code is no more suggesting Pygame methods for me

I've been using Pygame a lot. And I'm cuurently coding in VS Code. Last week, I have installed JAVA and started learning it's basics. However, from the moment I installed the JDK, VS Code have changed ...
0
votes
0answers
38 views

How to make gravity in pygame?

I'm not sure why my gravity isn't working... Can pleas anyone help?? Here my code: ...
0
votes
0answers
14 views

How to make my sprite jump in pygame?

I wonder how to make a sprite jump in pygame! Can anybody explain if possible? Thank you!
0
votes
0answers
26 views

Why don't my keypresses work in Pygame?

I don't know why my attempt to read keypresses in Pygame is not working. ...
1
vote
1answer
96 views

How to display the counter in pygame.time.set_timer?

in pygame, we use pygame.time.set_timer() to repeatedly create an event. This function takes 2 arguments : the event type and the delay time after which the event ...
0
votes
1answer
19 views

Full screen to windowed screen workaround causing segmentation fault in pygame

I'm having an issue that causes the window bar to appear above the screen when jumping between full-screen and windowed mode. Did some googling on the issue and it turns out it's actually a pygame bug,...
0
votes
1answer
26 views

Pygame bullet firerate not working sometimes

i have made this bullet class but i have a problem with the firerate. Sometimes i'm not able to shoot even when the little delay (700ms) between the two shots has ended. I guess it's due to the ...
0
votes
1answer
52 views

Image color being changed when pygame blitting to screen

I'm working on my first game, and I decided to add some trees that twinkle to the game. For some reason when the image is blitted to the screen using pygames blit ...
0
votes
0answers
45 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
0answers
26 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
1answer
31 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
0answers
22 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
0answers
38 views

Having Problems in PyGame with Mouse Cursor and Sprite Collision

I know something is not right but I'm just starting out and hit a wall. Basically, I just want to MouseClick on a Sprite and make something happen. The mouse clicking itself works, the sprite ...
0
votes
0answers
40 views

How can I upload a pygame that I made on a website? [duplicate]

I'm a beginner programmer and I want to know how can you upload your pygame on websites like coolmathgames or any game websites, do you upload your code after you get a deal with them? do you save it ...
1
vote
1answer
63 views

player teleporting into other levels

So I basically want to load another map once the player collides with a object, specifically a "Portal" in my game. Which is really making the player move onto other levels. I don't want to ...
1
vote
1answer
171 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
0answers
35 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
0answers
62 views

How can I change the background color of the image?

I'm trying to change my background image color, but somehow it doesn't work. I have provided my code below and hope you will be able to tell me how I should do this, and why my code didn't work. ...
0
votes
0answers
35 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
0answers
67 views

How to make a sprite face the player sprite (pygame 2d)

Basically I have a sprite and I want its front/face to face the player sprite. All the sprites are rectangles/squares and use .get_rect(). I have a base class for ...
0
votes
0answers
22 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
0answers
22 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
20 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
14 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
54 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
32 views

How to get object or its index from mouse coordinates? [closed]

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
52 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
124 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: ...

1
2 3 4 5
9