This question already has answers here:
Why does my game made with Pygame suddenly lag for a few seconds? [duplicate]
(1 answer)
Pygame is running slow
(1 answer)
Closed 2 years ago.
I'm designing a game in pygame that you can download here: https://github.com/hailfire006/games unfortunately, when you fly the ship near the space station, the framerate drops from a nice 30-40 to 16-20. I believe this is due to my blitting sprites onto the screen every frame, and I have been told that there is a way to only redraw parts of the screen that need redrawing, but no one ever explains how to do this.
Someone please help, I'm beginning to worry that I should abandon hope of ever making a good game in python, and that I'll have to learn an entirely new language just to deal with framerate...
p.s. any other way you know how to raise the fps would be welcome also
Related
This question already has answers here:
how to make image/images disappear in pygame?
(1 answer)
How do I delete rect object from screen once player collides with it?
(1 answer)
Closed 1 year ago.
I am making a game in python using pygame for the visual interface and pymunk to simulate the physical collisions between the ennemies and everything works just fine but now i want to remove the enemy bodies when they die (get to 0 health), so i used pymunk.Space.remove(space, enemy.shape) and pymunk.Space.remove(space, enemy.body) and so far everything works , when the enemy dies he disappears but the problem is once the image disapeared the pymunk "bodies" that process collision still persist which then blocks the other enemies. Also i dont wan't to just once they die move their bodies out of the map as i'm worried about it causing lags > see the photos
This question already has answers here:
pygame - How to display text with font & color?
(7 answers)
How to display some text in pygame?
(1 answer)
Closed 2 years ago.
I am creating a simulation using pygame and have noticed that pygame makes it a little complicated to have text on the window while the application is running. Right now, my program shows a ball moving around the screen and creates a trail of colors identifying how many times it has passed over that area. What I need to happen, and what the text will be used for, is to display the day and temperature above the grid the ball moves around. Every 20 directiontional changes equals a day and each day has a temperature associated with it, so as the program runs, the text has to change respective to the current day and temperature.
My question is:
Are there any good modules that I could import which could do this efficiently, as I only want to use pygame for rendering my simulation in a not so computationally expensive way?
This question already has answers here:
Pygame lags after drawing full window grid
(1 answer)
How Can I Improve My Terrain Generator Performance I Get 40 FPS
(1 answer)
Closed 1 year ago.
I'm creating a game with my team in Python and Pygame.
It is a 2d battle royale game based in zombsroyale.io.
As the map is really big, the game starts to lag because it is loading the entire map, even the parts that aren't being shown on screen.
We would like pygame to only load the graphics that are currently being shown on screen, and when you move, stop loading the graphics that now aren't being shown and load the new graphics.
How could we achieve this in Python 3?
Thanks for reading.
EDIT: we've also checked that the game is less laggy when we set the screen window size to a smaller one (e.g. 680x680). How can we make the game's performance be good with a big window size (e.g. 1280x720)?
This question already has answers here:
How to get keyboard input in pygame?
(11 answers)
How can I make a sprite move when key is held down
(6 answers)
Closed 2 years ago.
So I have a small problem.
I am a beginner and I am just making my first game, chose to do a pong clone.
However, I can not move the second paddle with the keys a and z and for the life of me I canĀ“t find out why.
I would be extremely grateful if someone could help me.
Just for heads up, laud mean paddle, pall means ball and aken means screen. I am not a native speaker.
This question already has answers here:
How do I detect collision in pygame?
(5 answers)
How to detect collisions between two rectangular objects or images in pygame
(1 answer)
Closed 2 years ago.
I'm using Pygame with my group to develop a game for this semester in school. I'm responsible for building the physics engine.
My question: How do I get a player object to stop on collision with a rect object? I've scoured the internet, and this website for answers, but everything seems to complicated to grasp.
Here's the code particular block of code I'm trying to get to work:
if player.rect.left == rect.right:
player.undo_right()
This block is preceded by the game loop. All I want to do is make it so the player is consistently 20 pixels away from the box. I'll be able to apply better bounds once I get this test to work. Right now, it repels the player sporadically, and never consistently. Sometimes, I'll run it, and it'll bounce away once, and then the player will go through the rectangle freely.
I realize there are numerous links on the internet for this type of thing, but I wanted to try to get collision to work using simple code like this. If I'm not able to, then why? Can someone exaplin a simple and efficient way to do this?
Thanks.