Relative Content

Tag Archive for pythonpython-3.xpygamepygame-surface

Question: pygame image set_alpha not working

I’ve been working on a homemade Space Invaders game recently. During the development process, I used Pygame’s set_alpha() to draw semi-transparent images. However, despite seemingly correct parameter settings, set_alpha() didn’t work as expected.
I employed a CreateSprite class to easily set up characters, and used an opacity parameter to set transparency from 0 to 1. In the update() method, I used set_alpha(int(self.opacity*255)) on all costumes. The calculated value self.opacity*255 appears correct, yet set_alpha() remains ineffective. Below are snippets of the code and the complete script.

Pygame plasma effect won’t display

I’m porting this ancient code to Python 3. I’ve applied the varied palette to the surfaces and the plasma_buffer matrix changes, but pygame.display.flip() keeps showing a black screen. What’d I miss?

PyGame AI Enemy Plane

How to make the enemy not turn around behind the player so quickly. When a player flies close to an enemy plane, it changes its angle very quickly. Can this be limited so that the enemy cannot turn around so quickly?