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
48
votes
6 answers

How do I rotate an image around its center using Pygame?

I had been trying to rotate an image around its center in using pygame.transform.rotate() but it's not working. Specifically the part that hangs is rot_image = rot_image.subsurface(rot_rect).copy(). I get the exception: ValueError: subsurface…
Miha
  • 501
  • 1
  • 4
  • 4
38
votes
5 answers

How do I detect collision in pygame?

I have made a list of bullets and a list of sprites using the classes below. How do I detect if a bullet collides with a sprite and then delete that sprite and the bullet? #Define the sprite class class Sprite: def __init__(self,x,y, name): …
Mike Schmidt
  • 945
  • 3
  • 12
  • 31
6
votes
2 answers

How to fix this DeprecationWarning

DeprecationWarning: an integer is required (got type float). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python. win.blit(playerStand, (x, y)) DeprecationWarning: an integer is required (got…
Blazing_Sun
  • 93
  • 1
  • 1
  • 6
4
votes
1 answer

Pygame colliderect() function returning 0 (zeros) and 1 (ones) instead of True and False?

colliderect() function won't return True and False; instead, it is returning 0 and 1. When I use the function type it says int instead of bool. If I code using 0 and 1 instead of the boolean value the code works, but why is it happening? Pygame…
3
votes
1 answer

Why don't three R, G and B circles blend correctly?

I am trying to represent the RGB color model using python + pygame. I wanted to get the following: So then, I wrote the following code: import pygame, sys from pygame.locals import * ALPHA = 100 TRANSPARENT = (255,0,255) BLACK = (0,0,0) WHITE =…
3
votes
1 answer

Rotate a rectangle over waves

I am trying to move a rectangle over the waves,trying to simulate a boat sailing. For that, I rotate the rectangle using the height of the drawn lines and calculating the angle they form with the rectangle. However, for some reason, in some points…
3
votes
1 answer

pygame.font.SysFont() takes about 5 seconds on macOS

I'm using pygame 2.0.0.dev15 to develop games with Python. Everything works great so far, but I'm surprised that pygame.font.SysFont() takes a lot of time to process. Whenever I use fonts in my game, the startup takes about 5 seconds more than…
Robo Robok
  • 21,132
  • 17
  • 68
  • 126
2
votes
1 answer

How to create a rhomboid in pygame

I want to create a rhomboid like this. I can not do this I found the solution just for the diamond. my code: import pygame as pg pg.init() screen = pg.display.set_mode((500, 700)) clock = pg.time.Clock() BG_COLOR = pg.Color('gray12') BLUE =…
ALex Break
  • 59
  • 10
2
votes
1 answer

My pygame program doesn't want to change y axis

The goal is to make squares with random shade of green on screen, but i y axis doesn't want to change import pygame from random import randint #activate pygame pygame.init() #screen (x,y) screen = pygame.display.set_mode([500, 500]) #bool - if…
kiciarozek
  • 47
  • 6
2
votes
1 answer

In pygame how can i create a data struct that keeps track of resizing events and the coordinates of objects?

I'm looking to keep my mouse events in sync with my objects after resizing the screen. I'm told I need to create a data structure to keep track of: Resizing events New coordinates to match the resize How can I accomplish this using simple…
1
vote
1 answer

i am trying to make a pause function with space key but it seems i cant even get in the pause function

#Opening and globals from pygame.locals import * import pygame import time import random pygame.init() WIDTH, HEIGHT = 1000, 800 WIN = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Crypt Games") BG =…
1
vote
1 answer

Problem with Pygame Animating a Moving Sprite

I'm trying to make a game and when I want to make a moving sprite, there's trail that is behind it. When I remove it, then the sprite is not animated. When I try to fix that, it stops moving. As far as I know the problem is to do with the group…
1
vote
2 answers

Pygame Images won't load in after being called

I've been trying to make Space Invaders using PyGame in Python and make a list for the enemy images, and I make a for loop twice to load the images in and append them to the lists; 2 times for 2 rows. Though, the only pictures that appear are the…
edwardvth
  • 41
  • 3
1
vote
2 answers

pygame how to fix player going the opposite direction of left/right when colliding with the top/bottom of a mask

I have a program that detects mask collisions and moves the player to prevent it overlapping. It program works by moving the player by the dimensions of the area that is overlapped depending on the direction the player is moving. But when I press…
expoodo
  • 65
  • 1
  • 8
1
vote
1 answer

how to prevent two masks from overlapping in pygame?

How would I prevent two masks from overlapping each other when a collision is detected? I know how to detect mask collisions but I can't wrap my head around actually preventing them from colliding. I'm pretty sure the solution has to do something…
expoodo
  • 65
  • 1
  • 8
1
2 3 4