Is it possible to change sprite colours in Pygame?

If the image is a “mask” image, with a transparent background and a white (255, 255, 255) mask, then you can “tint” the image with ease. Load the image: image = pygame.image.load(imageName) Generate a uniform colored image with an alpha channel and the same size: colorImage = pygame.Surface(image.get_size()).convert_alpha() colorImage.fill(color) Blend the image with maskImage, by … Read more

Detecting collision of two sprites that can rotate [duplicate]

A lot will depend on how you are managing your objects, but… import java.awt.Color; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.geom.AffineTransform; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.InputMap; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.KeyStroke; import javax.swing.Timer; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; public … Read more

Move an object every few seconds in Pygame

You can use an Event for this together with pygame.time.set_timer(): pygame.time.set_timer() repeatedly create an event on the event queue set_timer(eventid, milliseconds) -> None Set an event type to appear on the event queue every given number of milliseconds Here’s a simple, complete example. Note how the enemies move every 1000ms sideways, every 3500ms downwards, and … Read more

How do I draw the same moving image multiple times?

@KevinWorkman is right. You need some kind of data structure to hold the fireballs. In the example below I used a List of Fireball. List<Fireball> fireBalls; … private class Fireball { Image fireball; int x = 150; int y = 125; public Fireball(Image image) { fireball = image; } public void drawFireball(Graphics g) { g.drawImage(fireball, … Read more

How to convert the background color of image to match the color of Pygame window?

You don’t need to change the background color of the image to the background color of the window, but make the background of the image transparent. Set the transparent colorkey by pygame.Surface.set_colorkey: Set the current color key for the Surface. When blitting this Surface onto a destination, any pixels that have the same color as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)