Relative Content

Tag Archive for pythonpygame

How can I fix my pygame collision not working correctly?

Ive been going crazy trying to figure out how to get the collision right on pygame. Whenever the player falls onto and collides with a platform, it runs correctly and puts the player onto the platform. But if the player falls off the platform and its side hits the side off the platform, it puts the player back on top of the platform.

Sprite not centering in pygame when being scaled up

I’m trying to make a game where a laser is being fired and you have to dodge it, but when i resize the laser to make it taller, the image moves downwards. I think this is because the sprite isn’t properly centered. How do i center it? Sorry if I’m asking a stupid question.

Flickering images – Pygame rects

I’m trying to create a scrolling star background. It runs fine and creates all of the stars, but when one is removed, every star on the screen flickers.

Variable outside function being modified without a “return”

My apologies if this is really obvious but I honestly have no clue what’s happening.
I call a function with a list entry as one of the parameters. Inside the function, I modify the values because I need to, and somehow the original list ends up being changed even though never referenced?

correcting my computer car’s path following in pygame

So, i tried making a race game with a computer car and a player car. I have appended the points to a path variable and coded the necessary functions and everything. the code doesn’t seem to work as well. at the beginning the computer car seems to tilt before it starts moving which seems to mess up the angle calculation so the car doesn’t follow the point exactly. when i reduced the velocity and rotational velocity of the computer car it follows the path. not quite well but at least it doesn’t completely veer off the designated race track. i still want to fix the tilt at the beginning.

Removing the border around an object in pygame

How do I remove the blue border around the ship so that the background, which is loaded as a .bmp image, can be seen?
I added the convert_alpha and set_colorkey functions but it didn’t help. I don’t know if I need to add another function or do something in the alien_invasion.py file

Pygame level/menu states

With my code below what would be the simplest and easiest way to implement game states to control levels? If I wanted to start with a title screen then load a level, and proceed to the next level on completion? If someone could explain the easiest way to handle this that would be great!

Pygame Fullscreen Lag Despite Proper Scaling

My program runs natively in a smaller resolution due to some mistakes when first creating it. I am unfortunately far beyond the point of resizing all assets manually, and wanted to create the option to fullscreen using pygame’s built in methods.