How do I trigger a change to a different audio channel via if/else using Python?

Advertisements Forgive me here, I’m very new to Python (and coding in general) but I’m honestly stumped. Essentially what I’m trying to do is I’m attempting to trigger a change in music on this guessing game I’m working on, when someone gets the answer they get um… rickrolled. The problem is that whenever I try… Read More How do I trigger a change to a different audio channel via if/else using Python?

Pygame Passing from main to game file causing errors

Advertisements I receive a "pygame.error: display Surface quit" when trying to run the main.py file. from Asteroid import Asteroid import neat import pygame pygame.init() neat.config.Config Screenw, Screenh = 500, 500 windo = pygame.display.set_mode((Screenw, Screenh)) game = Asteroidick.Game() game.__init__(windo) running = True while running: game.loop() for event in pygame.event.get(): if event.type == pygame.QUIT: running = False… Read More Pygame Passing from main to game file causing errors

How would I make a battery meter in pygame?

Advertisements I made a program in Python with a flashlight and want to make the battery meter change when the flashlight is on. I made a simpler version where it only changes like this: high = pygame.image.load("battery_high.jpeg") medium = pygame.image.load("battery_med.jpeg") low = pygame.image.load("battery_low.jpeg") battery = 100 while True: battery -= 0.1; for event in pygame.event.get():… Read More How would I make a battery meter in pygame?

In pygame how do I draw multiple circles and reduce their radiuses over time without resetting screen?

Advertisements I’m new to pygame. What I want to do is draw a circle on the screen (I did it successfully), then I want this circle’s radius to decrease over time until it becomes zero and the circle dissappers. I found that I could reset screen or draw a filled rectangle over the previous circle… Read More In pygame how do I draw multiple circles and reduce their radiuses over time without resetting screen?

Issue while creating a parallax background in pygame

Advertisements I’m trying to create a parallax background effect in pygame i.e., each layer of the background will move at different speeds. Here is the code I’ve written, import pygame pygame.init() surface_width=576 surface_height=200 screen=pygame.display.set_mode((surface_width,surface_height)) clock=pygame.time.Clock() dx=0 dy=0 bg=[] for i in range(1,6): back=pygame.image.load(f'{i}.png’).convert_alpha() bg.append(back) width=bg[0].get_width() height=surface_height-bg[0].get_height() run=True while run: clock.tick(60) for x in range(-3,3): speed=1… Read More Issue while creating a parallax background in pygame