I been using pygame to try to color a box I choose in some grid. The box is supposed to be colored when I hover over it with my mouse and press ‘s’ on the keyboard. Only thing is that the wrong box is being colored in the grid. It is always the first box which is being colored and
Tag: pygame
os unable to load image pygame.error: Couldn’t open imgspipe.png
source code : https://github.com/techwithtim/NEAT-Flappy-Bird line 28 – 31 (tech with tims flappy bird deep learning ai) i at first thought it was a local problem but after fiddling with python and uninstalling installing and reinstalling it i can conclude it is almost certainly not that. here’s t…
Object escapes the window in pygame . How to prevent it from doing so?
So, I am python beginner and wanted to create a space invader game. But I’m facing an issue. The player object escapes the pygame window if I press the left arrow key or the right arrow key for a longer duration of time. Here’s my code – Before asking this question I’ve tried this but …
Pygame doesn’t let me use float for rect.move, but I need it
I’ve recently recreated a version of Lunar Lander (you know, the old retro game) in Python 3 and Pygame: my lander moves (̀̀̀rect.move) each frame along the y axis because of gravity. Problem: Until I hit 1 m/s, the y value added to rect.move is a float under 1: I must use int() to round it up, as pygam…
Pygame : player sprite that disappears behind the background
So there you go, I wanted to experiment a little pygame but I find myself stuck. Context I created a small sprite (with Piskelapp) that represents the player and looks like: player.png then add my background in jpg format. However when launching the game, my sprite is cut by the background as follows: The shi…
How do I change the volume in realtime for my music player (pygame)
I am trying to change the volume of my music in realtime for my music player. My code: And here are the action events: But I don’t know how to change the volume while the music is playing, it only changes the volume after I restart the song. I tried: But that didn’t work it just game me an error.
Running two files on a single project on PyCharm
I am currently developing a IoT sensor value simulator using the PyCharm IDE (along with pygame). Essentially, I am trying to produce/send data to Microsoft Azure IoT platform while there is a GUI available for users, in which they can see the temperatures of each sensor, change the sensor outputs, etc. Since…
Python3 PyGame how to move an image?
I tried to use .blit but an issue occurs, here is a screenshot to explain my problem furthermore: The image appears to be smudged across the screen following my mouse code: Answer Fix the indentation in your given code, it puts all the important stuff outside the while loop. You can also add a function that r…
ValueError: is not in list
I trying to make spaceship game from using pygame. Just simple game what warship shoot bullet and collide enemies. But when I play my game, after 6 or 7 collisions I get below error. creating bullet class creating enemy class and defining collide def calling collide definition in for enemy loop Then take this…
Problem to install pygame on ubuntu 20.04LTS
I am on Ubuntu 20.04LTS, and I try to install pygame (for python) for a school project. But when I try this: I received an error: Can you help me, please? Answer Try installing it with instead. The error you are getting is because you are missing the Pygame dependencies, which apt should install for you. As a…