Questions tagged [pygame2]

The PyGame 2.0 version. PyGame 2.0 is backward-compatible along with Python 2 support.

The PyGame 2.0 version of PyGame. Released on October 28, 2020, PyGame 2.0 is backward-compatible along with Python 2 support.

References:

58 questions
1
vote
1 answer

Issue in pygame.key.get_pressed() for movement function

I'm quite new with python and coding. Trying to code a simple game using pygame I have found an issue that I can't solve in my movement function. I have a function that uses the pygame method get_pressed() in order to set the direction of the player…
Marco
  • 53
  • 8
1
vote
1 answer

What is the difference between WINDOWCLOSE event type and QUIT event type

I've been wondering what is the difference between this two, I saw WINDOWCLOSE in the pygame docs but it doesn't have much information on it, so can someone tell me what is the difference between this two?
Zenthm
  • 104
  • 1
  • 8
1
vote
1 answer

Problem with generating random terrain pygame

I want to make simple game with randomly generated terrain but, when I move the terrain, instead of generating terrain randomly, it generates terrain at maximum height, which is 8. I am beginner in PyGame and this bug is irritating me. Code: …
kiciarozek
  • 47
  • 6
1
vote
1 answer

Pygame moving circles

im new to python and im working on moving circles in pygame. Im trying to put the circles in a group and move them. I am stuck. Right now, im trying to put the circles into a list, but i keep getting a error. I've been working on this project for…
Ven
  • 31
  • 5
1
vote
1 answer

test equality for pygame.font.Font

I was trying to make a font cache like this: from ._utils import SizedDict def copysurf(x,mod): if mod: return cs(x) return ImmutableSurface(x) class FontCache: def __init__(self): self.cache = SizedDict(20) …
user16829600
1
vote
1 answer

Boucing saw doesnt collide with player

Im making a game which if the saw collide the player then it dies, but when i made the saw bounce of the wall then the colliderect doesn't work. Heres my code: import pygame from pygame import draw from pygame import Rect pygame.init() width =…
1
vote
1 answer

Get RGB pixel data of a section of a screen as an array in pygame

My code allows a user to draw on a section of a pygame screen. I want to be able to extract all the RGB pixel values for this section of the screen and convert them to a 3d array, like this: top_left = [50, 50] bottom_right = [100, 100] pixel_data =…
1
vote
1 answer

How do I make my Pygame Sprite jump higher and farther?

I am making a game in Pygame and this is my code to jump: keys = pygame.key.get_pressed() if isjump == False: #Up arrow key if keys[pygame.K_UP]: isjump = True v = 5 else: m = 1 if v >= 0 else -1 F = m * (v**2) …
Pixeled
  • 316
  • 3
  • 10
1
vote
1 answer

Why is Pygame waiting for sprites to load before creating the window?

I've been trying to create a sprite creator, but I notice that the pygame window doesn't load until all of those sprites have been created, and I wanted to know 2 things: Why it only loads the screen when all of these sprites have been created How…
1
vote
1 answer

Line is detected as diagonal of rectangle while using collidepoint function in pygame

I am working on a graph based project. I am drawing lines to represent the edges. My goal is to change color of line when I click on the specific line. the problem is pygame treats line as diagonal of virtual rectangle. so when even if I don't click…
1
vote
1 answer

What would be causing pygame.init() to take 40 seconds to execute?

Pygame was working perfectly last night, now the pygame.init() function is taking ~ 40 seconds to finish compared to being instant before. import pygame import time start = time.time() pygame.init() print(f"Runtime: {time.time() - start}") Console…
Rebeljah
  • 35
  • 4
1
vote
1 answer

How to save an image with the outline text using pygame?

The following code is saving this image. import pygame pygame.init() font = pygame.font.SysFont('arialroundedbold.ttf', 60) text = font.render("hello world", True, (0, 0, 0), (255, 255, 255)) pygame.image.save(text, "hello_world.png") How do I…
Himanshu
  • 11
  • 1
1
vote
1 answer

How do I move to the mouse pointer and point towards it at the same time?

I am quite new to Pygame 2 (actually python in general), and I wanted to make a little game for school. I used the code from this, but I can't get it to move towards the cursor when I press SPACE. I don't want it to move in the x/y axis... This is…
1
vote
1 answer

How to output pygame.image.save to a variable instead of a file?

I want to send a pygame.surface.Surface to another computer using socket library. I tried using pygame.image.tostring but it took 900kb, but when I used pygame.image.save and I used jpg format it only took 45kb. But the problem is pygame.image.save…
mhn2
  • 119
  • 9
1
vote
1 answer

The SCALED flag in pygame's display.set_mode function has no effect

I'm using pygame (version 2.0.0) to visualize big matrices interactively. I use pygame's display.set_mode function to which I pass the SCALED flag in order to automatically scale-down the displayed image to fit the screen: image = # a numpy…
snakile
  • 52,936
  • 62
  • 169
  • 241