EDIT: Reposted question so it is clearer. My issue is that the player rectangles are not on the player because of the camera offset. As a result, the game looks like this (see image 1). It’s not working because of the camera offset. I successfully repositioned the yellow rect over the player but I am having trouble repositioning the red
Tag: pygame
How do I change the image of a button when it’s clicked in pygame?
I have a button class and I can’t figure out how to change the image to a different one to make the button look like it’s been clicked. I’ve tried changing the button image to a different image from the file after “action” is true, which happens once the button is clicked. Answer You need to load 2 images and
center images and add padding according to screen resolution
I’m using pygame to show two images: I’ve maneged to resize the images according to the screen size of my user. But I’d like to standardized also the x and the y coordination position of my images. The images should always be in the middle according to the y axis and have the a little bit of pad to stay
Does running pygame usually make computers warm
When I run a simple pygame program using PyCharm on my M1 MacBook, I notice that my laptop gets kinda warm after running the program for 5-10 minutes. Is this normal, or does the while loop “tax” the computer. Thanks. Code below: Answer limit the frames per second to limit CPU usage with pygame.time.Clock.tick The method tick() of a pygame.time.Clock
Key compination at pygame
I’m using this python code https://gist.github.com/seankmartin/f660eff4787b586f94d5f678932bcd27#file-keyboardpress-py to get time for keyboard events. It’s working well, but I need to get KEYDOWN and KEYUP also for capital letters and exclamation point. So I modified it by adding to this part So now it looks like this But I still can’t get no capitals letter, no exclamation point. What i’m doing wrong?
How to make sprite move to point along a curve in pygame
I’m doing a pygame project for practice and I need a sprite to move to some point on screen and I did it, but it moves in a straight line and I would like to learn how to make it move to the same point in a curve. This movement looks like and I would like it to be like
Going through sprites in an array and redrawing them when it’s time to redraw causes some to blink
I’m working on a game that is like Cookie Clickers in Python. I’m trying to replicate the feature where when you get a cookie (1 cookie from CPS or from clicking the cookie) it makes a small cookie fall down the screen in the background with a random X position and a random Y position. But the falling cookies start
Why python tries to use directly Alsa as a sound output?
I’m using Ubuntu 20.04.5 LTS When I try to play sound with pygame or pyglet, it plays it normally. However, when my computer is playing sound from any other source, I just get error Here is the pygame version I get an error: It seems that pygame tries to play audio directly from ALSA and that’s why I cannot play
Pygame displays a black screen
I did some research to see if I could fix my problem on my own but it has been fruitless so far. I’ve checked to see if I ran the .display command too much but I haven’t, the program will run without error but the screen appears black except when I close the window out, you can catch a glimpse
Shorter way to make colliderect in if statement work?
I have two objects: And I want to make an if statement if they collide with a third object. This code actually works but is too long: And there’s an error when I try to write: So, what is wrong? Is there a shorter way to write it? Answer The first thing you can do is use shorter variable names,