Skip to content
Advertisement

Tag: pygame

How to spawn sprites from multiple sides?

I´m creating simple game where I play as aeroplane and i´m dodging rockets (rockets appear from right side), I did something like barrier which block enemies and kill them, but it´s too OP, so I want to nerf it, so I´m going to spawn enemies from both, right side, and top side. But I really don´t know how to spawn

Draw rectangle on key click

I want to draw a rectangle with a button click , but the problem is with every loop it updates the display , display is filled with a color So the rectangle is only seen for a brief period of time. How to solve this. Answer You have to draw the rectangle in the application loop. For example add a

Pygame functions having two brackets

Why does pygame.dispay.set_mode(()) and other similar functions has two braces instead of one and why it isnt working if i just put only one brace? Answer The display mode gets a tuple with two items to describe the resolution for the render-screen. And a tuple will be defined by When using the default you just use the empty tuple definition

AttributeError: ‘Event’ object has no attribute ‘button’

Here’s my Code and I am just trying run my xbox controller for later on if statements to control dc motors: I get the error message below when I run my code: Answer Each event type generates a pygame.event.Event object with different attributes. The button attribute is not defined for all event objects. You can just get the button attribute

Why does pygame load slow?

I have a simple project that display a “button” with an image,a text and a background color: that’s works fine but the problem is that when i launch the game it load the main window, wait some time(something like 1 second) and then load the button.I tried to add more button and it loaded them one at a time.I don’t

Exception has occurred: error mpg123_seek: Invalid RVA mode. (code 12)

I am recording audio using sounddevice and I want to play it through a virtual audio cable through pygame, I keep receiving this error Exception has occurred: error mpg123_seek: Invalid RVA mode. (code 12) My code is below: Any help is appreciated. Answer There’s a couple of issues. The first is that scipi.io.wavefile.write() only writes an uncompressed WAV file (ref:

How can i collide with a 45 degree slope?

I have spent the past 3 days trying to understand this but with every article I have read and every youtube video I have watched I have failed to comprehend the concept. I have given this my best go at listening and reading from what I have seen online, before asking here. I just want one rectangle to go up

Pygame window isn’t updating

I’m writing a small python game just to learn how to use python better. I wanted to try to start using multiple scripts, as keeping all of the code in one script can get a little crowded. I made a second script, created a function main(scrn) and everything seems to be working fine. Calling that function in my main script,

Advertisement