18,028 questions
-1
votes
1
answer
47
views
Moving a figure around the screen using control keys [duplicate]
The figure moves in different directions: left, right, up, and down. While moving, it should also fire in the direction it's moving when the space bar is pressed. In this code, when moving to the ...
0
votes
1
answer
47
views
I need help getting the MOUSEWHEEL event to work [duplicate]
i'm trying to make it so that a surface moves whenever the user scrolls the mousewheel, like how this website moves when you scroll.
here's the code i'm working with so far.
scrollVal=74
for event in ...
-3
votes
1
answer
113
views
Pygame/Python window keeps crashing [duplicate]
I am a beginner to python & pygame, and im trying to make a pygame window. However, whenever the window opens, the window crashes and says not responding. can someone help me?
import pygame
...
0
votes
0
answers
54
views
Pygame particles force fields swirly effects
I'm trying to replicate some animation concepts of particles with force fields in order to generate a vertical beam of particles going upwards, except they can experience "turbulences" at ...
3
votes
1
answer
158
views
Pygame sprite is not visible
I am making a game in which you have to roll the blue block to the "Touch me" text. When I run the code, the blue block is not visible and there are no problems found in VS Code. How can I ...
1
vote
1
answer
62
views
Creating a class instance causes pygame to draw a black screen for 1 frame
I have different screens/menus set as instances of the Scene class. Whenever I want to switch screens, my gameloop checks for a button click, and if successful, it calls a function that defines the ...
1
vote
0
answers
344
views
DRI3, libEGL, and MESA errors in Pygame
When running my Pygame 3d maze, I encountered a new error when loading it up.
Here is my error:
Environment updated. Reloading shell...
pygame 2.6.1 (SDL 2.28.4, Python 3.11.10)
Hello from the ...
1
vote
1
answer
147
views
How to implement drag and drop to basic pygame chess engine [duplicate]
I'm building a chess engine using pygame as a personal project. I was following a tutorial but I want to go further.
For the moment I have the chessboard, the pieces in their initial position and the ...
-1
votes
1
answer
93
views
PyGame inputs not working with Nintendo Switch Pro Controller
I'm trying to add controller inputs to a game I'm making but when pressing one of the buttons on the controller, the action is not being performed.
I was told to use JOYHATMOTION but the Pro ...
1
vote
0
answers
124
views
Best way to do loops, slopes and tile handling for a Sonic game using Pygame? [duplicate]
I'm currently making a Sonic game using Pygame (full project here: https://github.com/Dingleberry-Epstein/Sonic-Pygame-Test) and I am stuck on how to perfectly handle loops, slopes and overall tile ...
-2
votes
1
answer
50
views
How do I use the rect? [duplicate]
I am using
player = pygame.draw.rect(screen, player_color, player_pos, 30, 1, 1, 1, 1, 1)
with
screen as my surface
player_color as my color
player_pos as my rectvalue
30 as my width
1 as my ...
2
votes
1
answer
146
views
How to program angled movement (for a Sonic game)? [duplicate]
I've been trying to get a Sonic The Hedgehog game working in Pygame and it works for the most part. Sonic can run fast, jump across platforms like a normal platformer, gets affected by gravity, ...
3
votes
1
answer
97
views
How to Use Windows System Menu via Python and Pygame
I have a fairly typical pygame project with a game loop that processes events, updates game state and data, and then draws the next frame. That's all working.
For various reasons, this is Windows only ...
1
vote
1
answer
56
views
Object moves a little bit weird with pygame vector2
I have an issue with pygame module. I have a small program where user can click on any place in a window and a ball will spawn there and start moving up-left with 45 degrees angle (135 actually) and ...
0
votes
1
answer
103
views
Can I change the letter spacing of a freetype font in pygame?
I am trying to draw some text using pygame.freetype.Font however for this font to look good in the context it's in, I want it to have a custom letter-spacing/kerning. By this I mean the ability to ...
0
votes
0
answers
32
views
404 error converting pygame to .wasm using pygbag [duplicate]
I'm trying to convert my pygame into .wasm using pygbag but getting the following error, as the site is no longer active:
ERROR 404: https://pygame-web.github.io/archives/0.9/pythonrc.py
Any ideas on ...
2
votes
1
answer
91
views
Artifacts with pygame when trying to update visible sprites only
I'm learning the basics of the pygame library and already struggling. The "game" at this point only has a player and walls. There are 2 main surfaces: "world" (the actual game map) ...
-1
votes
1
answer
42
views
Issue with Sprite not showing up, using Pygame [duplicate]
I'm following a begginner tutorial to start using pygame, but I'm stuck with the sprite display. I'm not able to make it visible on screen, please find below the code related to the sprite.
I'm not ...
0
votes
1
answer
70
views
Diagonal movement speed is faster, using an acceleration and friction movement system [duplicate]
I have made a top-down movement system in pygame, including acceleration and friction (the red square is the player):
import pygame
pygame.init()
running = True
x = 0
y = 0
speed = 3
friction = 10
...
0
votes
1
answer
83
views
How to prevent image blurring/flashing while moving?
I've recently created a camera which follows the player around the map. The camera centers the player in the middle and can zoom in and out with CTRL+Scroll wheel.
camera_handler.py:
import pygame
...
-1
votes
1
answer
60
views
PyGame multipleobjects comparisons/collision detection [duplicate]
I was able to create the collision of 2 objects in PyGame using the calculation of Euclidian distance.
Circles created are moving on the screen, changing the coordinates based on the "gravity&...
-1
votes
1
answer
49
views
Tuple has no attribute 'colliderect'? [duplicate]
So I am making a game for a school assessment where a turtle has to get to the water. Previously, I was playtesting the game as the turtle being a rectangle. But now I want the turtle to actually be a ...
1
vote
1
answer
45
views
how to keep window color changed in pygame
Im trying to make it so when my picture bounces, the window changes to a random color, but when it changes, it only changes for a split second when it collides then the window changes back to white
...
2
votes
0
answers
70
views
Pygame inherited classes acting differently [duplicate]
I'm making a python project for school, and created a general Enemy Class, which is then to be inherited by every common enemy. I created a Goblin Class that inherits this, and it works as expected, ...
-2
votes
1
answer
36
views
Pygame not responding when i run it [duplicate]
Hello first time user to the site, i am having a problem with Pygame not responding and don't know what is wrong i would be most thankful for any kind of help.
here is the code
sorry if this is not ...