18,026 questions
-5
votes
0
answers
170
views
File wont save python [closed]
In my code pasted below, I try to save the new level status(what level the player is on) in stats.txt. When I read the text file after saving it in the code, the file has the correct value. But when I ...
Advice
1
vote
2
replies
80
views
Python Pygame Pygbag
I am new to Python from having programmed in VBA my entire life, so please don't laugh at my code :-0. I know it is might be ugly and that it is not very consistent, and probably more VBA'ish that ...
-3
votes
0
answers
58
views
Why is my Pygame background not updating properly?
import os
import sys
import math
import random
import pygame
from scripts.utils import load_image, load_images, Animation
from scripts.entities import PhysicsEntity, Player, Enemy
from scripts....
-2
votes
1
answer
70
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 ...
-4
votes
1
answer
116
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
...
3
votes
1
answer
120
views
Pygame window not appearing
I'm using replit as my IDE, and I installed everything correctly. for some reason, when I run the code, it says it's running but has no pygame window in the display tab.
my code:
import pygame
import ...
0
votes
0
answers
58
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 ...
-4
votes
1
answer
113
views
Pygame image not facing the mouse [duplicate]
Here is my rotating code:
pos = pygame.mouse.get_pos()
x_dist = pos[0] - self.rect.centerx
y_dist = -(pos[1] - self.rect.centery)
self.angle = math.degrees(math.atan2(y_dist, x_dist))
self.image = ...
3
votes
1
answer
162
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 ...
-2
votes
1
answer
130
views
How do I remove blurry rendering in Pygame or Pygame-CE?
I am trying to make a pixel-art 2d platformer in Pygame-CE. When I use a standard pygame display, the pixels come out as blurry:
Minimal Reproducible Example:
#Import everything
import pygame, sys
...
1
vote
1
answer
64
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 ...
-4
votes
1
answer
100
views
Collision glitchy because of movement in pymunk
I'm working on a little project (a video game) that asks me to use accurate physics events. My goal is to have 2 rectangles who can move (here with the keyboard) and can collide. In case of a ...
2
votes
1
answer
400
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 ...
0
votes
1
answer
70
views
Strange behaviour of pygame.event.clear in a for loop
I created a way to handle the inputs for my pygame project, but made a mistake that resulted in a code that works the same way as the following:
def run(self):
got_mouse_click = False
...
1
vote
1
answer
157
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 ...