18,028 questions
-3
votes
1
answer
149
views
Get the frame number for a looping animation range based only on system time [duplicate]
I'm looking for a way to animate a sprite using just the system time, without having to increment and store the active frame or time passed as a variable. I should be able to achieve this by properly ...
3
votes
0
answers
45
views
Controller not recognized by pygame and DS4Windows after turning off and on Bluetooth [duplicate]
I am facing an issue with my controller in both pygame and DS4Windows. Initially, everything was working fine, but after I turned off my Bluetooth and then turned it back on, the controller is no ...
0
votes
0
answers
32
views
Python with Handheld Barcode Scanner and Keyboard Input [duplicate]
I'm working on a project that uses a physical barcode scanner. My code will wait for a scan input for the scanner to proceed and process the barcode. I would also like the use of a keyboard (...
1
vote
1
answer
71
views
Change the color of a pixel on a surface from a thread pool
I'm working on a voxel raytracer in Python, just ported from Tkinter to Pygame for window management and pixel drawing. I use a thread pool to do the raytracing for each pixel, in my original code the ...
2
votes
1
answer
83
views
Trianglular picture in pygame
Is it possible to put a picture in a triangle (or any polygon) in pygame?
It is easy to do on a rectangle so is it possible to maybe have a rectangle over a triangle and only show the union of the two ...
-1
votes
1
answer
89
views
How Do I Fix This Movement Pygame [duplicate]
I'm working with movements and I have made the red block follow the white block which is the player when ever the white block changes directions I have the red block also change directions is there a ...
2
votes
1
answer
625
views
PyGame: Use SDL2 to render a pixel
I want to render a singular green pixel in PyGame with SDL2. This is my current code:
import pygame
import pygame._sdl2
SCREEN_W = 800
SCREEN_H = 800
pygame.init()
pygame_screen = pygame.display....
-1
votes
1
answer
63
views
How to determine the three-point coordinates of a vector arrow [duplicate]
i want to draw a vector whenever i drag the object which is a ball. I have drawn a segment, the remaining thing is to draw an arrow indicating the direction of the vector. But I can't determine the ...
-1
votes
1
answer
191
views
ogg audio file is not played by pygame
I have the next version of pygame package: pygame 2.5.0 (SDL 2.28.0) in python 3.10.8.
.ogg file generated by telegram client and uploaded to server is successfully played by VLS application but next ...
0
votes
1
answer
57
views
Make parabolic movement frame independent
My code has a box that gets pushed with an initial velocity. I'm trying to make it travel the same distance with the same time taken regardless of the fps.
When I run the code with an FPS of 60, this ...
0
votes
1
answer
243
views
How do I access sound files from other folders in python? [duplicate]
I'm a beginner programmer right now and am using the pygame "Mixer" module to call sound files from the directory. When I move them to a separate "Audio" folder they cannot be ...
2
votes
1
answer
82
views
Pygame not processing input fast enough
I am making the game snake in pygame and have completed the game. I have one problem that does not happen every time, but every once in a while, it does not process the keys being pressed if I press ...
0
votes
1
answer
52
views
Pygame Passing from main to game file causing errors
I receive a "pygame.error: display Surface quit" when trying to run the main.py file.
from Asteroid import Asteroid
import neat
import pygame
pygame.init()
neat.config.Config
Screenw, ...
2
votes
1
answer
157
views
Pymunk body object being problematic
I am using this video tutorial: Video
I am making a ball (with 0 mass at the moment) in pymunk and trying to show it on pygame but it is not working
I tried doing this to make a ball in pymunk and ...
1
vote
1
answer
61
views
Python PyOpenGl OBJ model shown with fliped normals
i made this small program using Python, Pygame, PyOpenGl and the objloader module (https://github.com/yarolig/OBJFileLoader), it just displays a OBJ model:
import pygame
from pygame.locals import *
...
0
votes
1
answer
69
views
Pygame while loop is interrupting in taking a value from a list
I'm currently working on a pygame game where the dinosaur goes to the other side of the screen like in geometry dash. I'm not using classes, I'm a beginner at pygame and this is my first project. I'm ...
-2
votes
2
answers
189
views
How to bounce object off wall based off edge of shape instead of center of shape? [duplicate]
At the bottom is my full code that bounces a ball around a screen, each bounce on a wall changes color and size of ball. It is bouncing a ball off the edges of the screen based on the center of the ...
-1
votes
1
answer
77
views
How to stop .blit() from wrapping pixels across screen, or help finding an alternative that does the same?
I am trying to generate terrain randomly, and I have made it scroll it just as a test, but when the pixels hit the end of the screen, they play back on the other side as such:brokenscroll before ...
0
votes
2
answers
262
views
pygame, smoothscale png image with alpha transparency channels - black edges
I have a problem with scaling images in pygame library. I have a scene and character loaded from large PNG assets. Those PNGs has alpha transparency (mostly on the edge).
For my game, i need to scale ...
1
vote
1
answer
161
views
How would I make a battery meter in pygame?
I made a program in Python with a flashlight and want to make the battery meter change when the flashlight is on. I made a simpler version where it only changes like this:
high = pygame.image.load(&...
0
votes
0
answers
73
views
How to set timer to close one function then open another? [duplicate]
I'm just want to set a timer of 20 seconds in a function then jump to another:
Function 1:
example_gif = gif_pygame.load("giphy (1).gif")
def animatedgif():
while True:
...
1
vote
1
answer
74
views
Issue with Incorrect Tile Numbers When Scaling Window in Pygame
Could you identify a bug in my code and explain why, when I use int((mouse_x + scroll_x) // (tw / MAX_COL)), int((mouse_y // th / MAX_ROW)) and hover over some tile, it consistently prints incorrect ...
0
votes
1
answer
131
views
Using Mixer to Play Mp3 Throws Error About libmpg123-0.dll, but There's No Context
I wanted to play a .mp3 file to my microphone using python code that I found in a Stack Overflow post, but I had to do some tweaking with the steps I had to take.
Here are the steps that I had to do:
...
2
votes
1
answer
358
views
Pygame Surface Scaling Issue
I have a problem in Pygame where, if I scale a Surface with a grid (which is displayed correctly in the first image) to a smaller size, I experience a strange bug where the lines are not drawn ...
-1
votes
1
answer
505
views
Pygame window not Displaying [duplicate]
new to using the pygame module and have been trying to open a window but to no avail. Here's my code.
import pygame
WIDTH, HEIGHT = 500, 500
SCREEN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame....