So I am trying to make a tower defense game and I tried to make a back button and before it worked but now when I try it gives me a math domain error. I’ve seen online it may come if I take something like the root of -1 but that’s not possible because the value is being squared. It
Tag: pygame
How to fix Clock? For Chess. Python
I’m creating a Chess clock for my chess project. In chess there are time formats 5|5 is where each player (white and black) is granted a general 5 minutes, so when either player makes a move it adds 5 seconds to the clock. So 15|10 is 15 minutes in general and 10 seconds per move. My code: The issues I
How to run multiple while loops at a time in Pygame
I’m trying to work on a simple Pygame program for a project that simply displays some faces and talks in a text to speech voice, but there is a while loop at the end that is necessary for the code to run but blocks another while loop that I need for the program from running. The while loop I’m trying
Pygame how to change background colour without erasing anything else
I’m making this drawing thing in Python with Pygame. I have functions that draw circles and rectangles, but I want to add a function that lets me change the background colour, while not erasing the other circles and rectangles. Here is the code for the rectangles: A function for it would be best, but any solution would work. Answer You
Why is nothing drawn in PyGame at all?
i have started a new project in python using pygame and for the background i want the bottom half filled with gray and the top black. i have used rect drawing in projects before but for some reason it seems to be broken? i don’t know what i am doing wrong. the weirdest thing is that the result is different
Incrementing count variable without waiting the upper line of code to finish
So,I have this code. I want to increment count variable by not waiting this two audio files to process completely. In my code below it is very obvious that count variable will be incremented only if the two audio files done playing. Is there any idea on playing it on background or can I call a subprocess here ? Answer
How to zoom in and out of an image pygame and using the mousposition as the center of the zoom
I am having an issue with PyGame i can’t resolve. So: my idea is that I have a map I can zoom in/out on. zooming in works fine. But zooming out shows that the rest of the picture got deleted and only the part of the image that was previously visible on the window exists now. This is my code:
Is there any other way to load a resource like an image, sound, or font into Pygame? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I am working on a game in pygame and I published some of my previous games on itch.io. When I am loading image I used
Defining a classmethod outside of a class in Python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I am making a game with Pygame where there are going to be many different screens. I am making a class called Screen that will
‘event’ has no “key” attribute
** this is a part of a code ** ** error shows that: 38, in _cheak_events elif event.key == pygame.KEYDOWN: AttributeError: ‘Event’ object has no attribute ‘key’ Answer Replace all event.key with event.type