sprite

How do I assign Images to Sprites with pygame

How do I assign Images to Sprites with pygame Question: I am struggling to give each sprite their own image in the code below and i cant seem to find a way to do it, if anyone could help it would be much appreciated. Thanks. (This is my first time using stack overflow so aplogies …

Total answers: 1

how can we get rid of the blur in pygame image?

how can we get rid of the blur in pygame image? Question: import pygame as pygame , sys pygame.init() size = (700,500) window_game = pygame.display.set_mode(size) print(pygame.mouse.get_cursor()) _run_ = True class mySprite(pygame.sprite.Sprite): def __init__ (self,width,height,cord_x,cord_y,color): super().__init__() self.image = pygame.Surface([width,height]) self.image.fill(color) self.rect = self.image.get_rect() self.rect.center = [cord_x,cord_y] #my background image bgimg = pygame.image.load("download.jpg") bgimg = pygame.transform.smoothscale(bgimg, size) …

Total answers: 1

My pygame sprites get missaligned overtime

My pygame sprites get missaligned overtime Question: I am trying to develop a platformer, but when I started implementing gravity and a jump mechanic the sprites of my terrain get misaligned on the y axis and I really don’t know what is wrong. My code consist of tree main classes: Player: This class has all …

Total answers: 1

Sprite leaves duplicates when I move it

Sprite leaves duplicates when I move it Question: I have been learning online and used various tutorials to draw a sprite in a pygame window. I am now trying to have it move a set number of pixels across a screen (dependant on the number returned from a diceroll). def diceroll(): roll = random.randint(1, 6) …

Total answers: 1

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

How do I make my Pygame Sprite jump higher and farther? Question: 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 …

Total answers: 1

How i can remove the black background on my sprite sheet in pygame

How i can remove the black background on my sprite sheet in pygame Question: I’m trying to learn how use sprite sheets on pygame , and on my first try my sprite for some reason have a black background , i don’t know how i can fix this problem , i alredy put 000 on …

Total answers: 2

Changing colour of a surface without overwriting transparency

Changing colour of a surface without overwriting transparency Question: I want to change the colour of a rect dynamically during runtime. Currently set_colour is filling all of the pixels of the surface with a single colour value. This works, but an issue arises when a method like set_outline is called, which modifies the transparency of …

Total answers: 1

Setting a pygame surface to have rounded corners

Setting a pygame surface to have rounded corners Question: This Rectangle class extends from pygame.sprite. I’d like to use set_rounded to modify how round the corners of the rect are. For example https://imgur.com/2N5NHlg class Rectangle(pg.sprite.Sprite): def __init__(self): pg.sprite.Sprite.__init__(self) self.original_image = pg.Surface((10, 10)) self.image = self.original_image self.rect = self.image.get_rect() def set_rounded(self, roundness): pass The roundness argument …

Total answers: 1

Rect won't update position when the sprite it is taken from moves

Rect won't update position when the sprite it is taken from moves Question: player_rect = Pfront_n.get_rect() Here ‘Pfront_n’ is a sprite, and I am getting a rect for that sprite. This is outside of the main loop. When inside the main loop, print(player_rect) shows that when my player moves, the rect doesn’t follow. My players …

Total answers: 1

Python pygame – Deleting offscreen sprites

Python pygame – Deleting offscreen sprites Question: I created a simple 2D game with python 2 and pygame where you have to avoid squares that are moving down. I created this class for the ‘enemy’: class Enemy(pygame.sprite.Sprite): def __init__(self, game): self.groups = game.all_sprites pygame.sprite.Sprite.__init__(self, self.groups) self.game = game self.image = pygame.Surface((TILESIZE + 10, TILESIZE + …

Total answers: 2