18,063
questions
-3
votes
0
answers
23
views
How do I make caves randomly generate in pygame?
My game is supposed to be like Minecraft using pygame, but 2D. I do not know how to generate caves, and other questions I looked at didn't really work, like this: Perlin worms for 2D cave generation. ...
-3
votes
0
answers
22
views
Are there any capable with Ren'Py libraries (bare-python) which allow to hide the title bar? How do I do it? [closed]
I need to remove the title bar of my Ren'Py game window, but nothing I know works.
I tried PyQtGraph which is said to be bare-python, but it didn't work as well. (Seems like I did something wrong):
...
0
votes
1
answer
27
views
How to play a sound set amount of times [duplicate]
import pygame
pygame.init()
pygame.mixer.init()
clock = pygame.time.Clock()
walking = pygame.mixer.Sound("Walk.mp3")
run = True
while run:
# Your game logic and drawing code will ...
-2
votes
0
answers
12
views
Problem adding a Jump_Forward() function in an MP3 player using tkinter
I want The Jump_Forward() function to jump 10sec forward in the song but it just restarts the song at the time it is called
I put the code here
I tried to stop the music and restart it using pygame....
-2
votes
0
answers
22
views
how to install pygame for python3.4.4 in windows XP
How do i install pygame in windows XP for python3.4.4, i have a problem with it.
I have this windows XP on a 32-bit computer that i would like to install pygame in, but i've tried everything that ...
-1
votes
0
answers
33
views
Why are lines of my 3D cube still visible even when the cube is behind the camera in Pygame? [duplicate]
I have recently been trying to create a 3D cube in pygame that I can view by moveing a camera. I have been trying not to import any modules other than math, so I can keep this relavively vanilla.
I ...
-1
votes
0
answers
40
views
Why is my ball falling through the rotating body when moved?
I am trying to create a physics simulation of a ball moving on a seesaw-like structure in Python using the pymunk and pygame modules.
import pymunk
from pymunk import pygame_util
import pygame
import ...
-2
votes
0
answers
13
views
I get the "ModuleNotFoundError: No module named 'pygame'" error when trying to import pygame in Spyder [duplicate]
I am using Spyder (Python 3.12.4) and when using import pygame I keep getting this error:
Traceback (most recent call last):
File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in ...
-1
votes
0
answers
36
views
Game of life in pygame running extremely slow [duplicate]
I am writing a simple version of Conways Game of Life in Python with pygame. It only runs at about 1 fps or even less and I can´t find out why. I´ve read similar questions and found out that nested ...
-1
votes
0
answers
37
views
Pygame image FilenotFoundError no such file or directory on Mac OS [duplicate]
So im making a game in Pygame using pycharm and every time I try to load the image it says "FileNotFoundError: No file 'Cloud.png' found in working directory '/Users/lendimaxhuni/PycharmProjects/...
-1
votes
1
answer
43
views
Tkinter window opening alongside Pygame window [duplicate]
I am writing some python code that initially opens a TKinter window, when this is closed it should and does open a Pygame window. You can prompt the opening of another TKinter window alongside the ...
-1
votes
0
answers
48
views
how to create stereo output using pygame [duplicate]
I would like to use pygame to send synthesized sine waves to my speakers, with a different frequency for the left and right side speakers. I would like to toggle between the left and right side ...
-1
votes
0
answers
40
views
TypeError: Invalid rect, all 4 fields must be numeric [duplicate]
I'm using Pygame to build a game for fun, and have come across an issue in my code that i just simply cant understand. the console keeps returning:
File "C:\Users\XXXXXX\PycharmProjects\...
0
votes
0
answers
39
views
player can't jump in pygame [duplicate]
My player can't jump unless I hold A and then press space when I'm near an edge
import pygame.display
from settings import *
class Player(pygame.sprite.Sprite):
def __init__(self, pos, surface, ...
-3
votes
0
answers
22
views
How do I solve this problem with the Pygame? [duplicate]
s_w=1000
s_h=int(s_w*0.8)
screen=pygame.display.set_mode((s_w, s_h))
player=pygame.Rect((300,250,50,50))
pygame.display.update()
pygame.init()
run=True
while run:
pygame.init()
...
-2
votes
0
answers
30
views
Class not working with Pygame collision detection [duplicate]
this class has been bugging me for a while but for some reason it will not let me do collision detection
I've tried pretty much all of the Pygame collision function, and they are not working it is ...
-1
votes
1
answer
44
views
Why are Tkinter Scales broken across multiple files?
My tk scales for rgb values and 'logic' variable are ceasing to function when I import my class into a file with another 'main tk'. The scales are present and interactable but fail to change the ...
-3
votes
0
answers
28
views
Pygame collision detection with groups [duplicate]
The code works also don't worry about the box class that's for future bits. I am a noob with pygame and this is my first game so can I have some help please?
I tried setting up collisions in multiple ...
-1
votes
0
answers
16
views
How to place an image in pygame, where i want it [duplicate]
I am trying to code a game and for this in pygame I need dice in my GUI. However, I got them to show but I can't move them from the top left corner
this is my code:
dice1 = pygame.image.load('dice1....
2
votes
0
answers
73
views
How Do I Change The View To Orbit Around A Changing Pivot Point?
I wanted to know where I am going wrong with my code. I'm trying to replicate a similar view to how Old School Runescape works, except instead of 3D objects I am using sprite stacked objects to fake a ...
-1
votes
1
answer
34
views
Automaton rendering/state issue
I'm working on sort of automaton where there is one red with "state = 2" square which checks neighboring squares in order up, left, down, right and if one of them is has "state = 0"...
0
votes
1
answer
43
views
pygame._sdl2 and SDL2 - Efficient Texture Storage on GPU with Multple Renderers
I'm working in pygame._sdl2 so that I can create multiple (2) windows simultaneously. I think this is an SDL2 question, not specific to pygame:
I want to be able to blit() the same textures into both ...
-1
votes
0
answers
15
views
Pygame Windows Position setting fails [duplicate]
I have this code, which is basically a copy of another question here to the same topic, but the window is still centered.
I want to set the window position.
import pygame, sys
from pygame.locals ...
-3
votes
0
answers
39
views
My python editor crashes on the first code I write with pygame [duplicate]
I am starting off Python programming with a pygame tutorial.
The tutorial tells me to write the below code:-
import pygame
pygame.init()
screen = pygame.display.set_mode((800,400))
and when I press ...
0
votes
0
answers
45
views
Pygame Window Minimizes and Becomes Unresponsive [duplicate]
I'm encountering a persistent issue with a Pygame application that I'm developing. When I run my script, the Pygame window pops up briefly and then minimizes. When I try to restore the window, it ...
1
vote
2
answers
51
views
How to spawn random color-changing shapes and add a counter in pygame
Currently, my game involves a player collecting shapes of a certain color a random number of times. The shapes will randomly spawn all over the screen, with ten shapes in all. The shapes will stay in ...
1
vote
1
answer
57
views
How to draw lines with a color gradient in Pygame?
I wish to draw a sequence of lines with a color gradient, so that the color fades from bright white to either black or fully transparent:
Ideally, pygame.draw.lines() would accept a list as the color ...
-1
votes
1
answer
40
views
When using torch snake_game is moving in a cirlce and not collecting food/reward. How do I fix this?
So I have a game of snake made in pygame where the snake starts off in the middle and grows bigger after collecting the food.
import pygame
import random
from enum import Enum
from collections import ...
0
votes
0
answers
47
views
Tetris block visually disappears for one frame after locking? [duplicate]
I am trying to make a Tetris clone in Pygame. Whenever my piece locks, I have an annoying black flicker for one frame where neither the piece sprite nor the grid sprite displaying all the pieces draws ...
0
votes
1
answer
56
views
Why doesn't Marching Square Visualization In Pygame draws nothing?
so i wanted to draw implicit equation of heart in pygame via using the marching squares algorithm in it. i implemented the marching square's algorithm but it doesn't work? can anyone help me out why?
...
0
votes
0
answers
24
views
Stopping the shape from moving directly past a wall when checking for a collision [duplicate]
So I am attempting to program a physics simulation in Pygame and am having trouble adding solidity to the walls. As of now, I have only programmed solidity for the left wall, and the squares do ...
-1
votes
2
answers
61
views
Why are no X's appearing on the screen once mouse is clicked?
I want to implement the feature where the program blits an 'X' to the screen at the position where the mouse is pressed. However, once I run the program, nothing appears. The take_turn function stores ...
0
votes
0
answers
31
views
How would i go about adding a first person camera to my pygame 3D cube renderer? [duplicate]
The python code:
import pygame
import pygame.draw
import pygame.time
import numpy as np
import json
from pygame.locals import *
# Constants
ORIGIN_X = 0
ORIGIN_Y = 0
CAMERA_X = 0
CAMERA_Y = 0
...
1
vote
1
answer
34
views
Trying to get PyOpenGL Shaders to Work (Only White Screen Appearing); Maybe Vertex Wrong?
I attempted to use a pygame font surface and converting it to pixel data using data = pygame.image.tostring(img, "RGBA", 1) and then used a gl function to create an opengl texture and draw ...
0
votes
2
answers
88
views
How do I keep my progress bar indicator from showing outside of it's rounded corners?
My progress bar when I use rounding overflows its border:
My fix (a transparent arc outside rounded rectangle using pygame.draw.arc) still leaves a part visible. The arc function uses a rectangle, so ...
-2
votes
1
answer
80
views
Event polling with event.get() returning result with exception set [duplicate]
Resolution: I've been in conversation with an active pygame developer who, after running through my issue, has confirmed that a recent update to pygame has caused this issue. Again, none of the ...
-2
votes
1
answer
43
views
How to make the collison function iterop with the animation function in a 2-d platformer game
I am making a game using pygame.
But the collision using pygame.sprite.collidemask() and my animator() function don't seem to work together to show the expected output.
The gravity func of the player ...
2
votes
2
answers
92
views
How to make the window size to constantly shrink in pygame?
I'm making a game in pygame and for one of the levels in my game, the window would shrink constantly, forcing the player to move fast before they couldn't see the screen anymore but I don't know how ...
0
votes
1
answer
57
views
Pygame - Load letters and display text for an image
I'm following Tech with Tim's guide on how to create a platformer game link
I created a function to load letters from a sprite image, based on his load_sprites function:
def ...
-2
votes
1
answer
84
views
How to use Pygame and Kivy
My question is not how to merge pygame and kivy screens. My problem is that I am working using kivy but in my code I added a function which runs a pygame program. When this program runs, the screen ...
-3
votes
1
answer
66
views
I tried to draw a red rectangle in Pygame, but the screen is black [duplicate]
This is my pygame code:
import pygame as pg
pg.init()
W, H = 500, 400
screen = pg.display.set_mode((W, H))
run = True
rect = pg.Rect(50, 50, 60, 60)
screen.fill((0, 0, 0))
pg.draw.rect(screen, (255, ...
-1
votes
1
answer
81
views
Having Trouble making a Simple Dress Up Game in Pygame [duplicate]
I'm trying to make a simple dress up game where there are three buttons. Depending on which button you press, you can put either a pink, blue, or green shirt on a mannequin.
However, my problem is ...
2
votes
0
answers
32
views
Why does PyGame Mixer play MP3s loaded with PyDub too fast on Windows, but correctly on Linux?
I have a situation where I need to load MP3 sounds into PyDub to edit them (specifically, trimming off 0.15 seconds of near-silence from their beginnings), then pass the trimmed result to PyGame to ...
0
votes
2
answers
39
views
Can I make Pygame rectangle outline with two different color?
if(blueBoxX!=redBoxX or blueBoxY!=redBoxY):
pygame.draw.rect(scrn, (0, 100, 255), (blueBoxX*75, blueBoxY*75, 75, 75), 3)
pygame.draw.rect(scrn, (255, 100, 0), (redBoxX*75, redBoxY*75, 75, 75), ...
0
votes
1
answer
69
views
frames drop to 0 when my mouse is not in motion in pygame
I am new to pygame and am trying to code the dino game that plays when internet is down on google. I've noticed that whenever I stop moving my mouse on the animation window, the frame rate drops to 0....
-1
votes
1
answer
33
views
Boundaries gap in a zoomable 2d map
I'm rendering an interactive 2d map with pygame.
My idea is to exract the coordinates of each regions from a png and use them to scroll and zoom with the following algorithm:
x - offset[0] * zoom, y - ...
-1
votes
2
answers
45
views
I got the key input to register into the game loop, but now it just doesn't register whenever I let go [duplicate]
The code works fine, jut whenever I let go of (in this case A) the character.x pos just keeps moving.
run = True
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
...
0
votes
1
answer
65
views
How can I access font families in pygame
I am currently trying to use a font family I have within my working directory in pygame. After looking at the pygame.font.Font documentation I couldn't find anything on this and I also searched on ...
0
votes
1
answer
250
views
pip install pygame not working and i don't know why [duplicate]
On Ubuntu, trying to install pygame using pip within my venv.
This is the full error message thrown when I try:
$ pip install pygame
Collecting pygame
Using cached pygame-2.6.0.tar.gz (15.8 MB)
...
2
votes
0
answers
44
views
Pygame Offset Grid by Fraction or Pixels [duplicate]
I am working on a Chess block by following a YT video, but I want my board more centered. I did that, however, now my event.get() event.pos isn't working quite right. About 15 pixels from the bottom ...