pygame

How to draw a border around a sprite or image in pygame?

梦想的初衷 提交于 2021-02-10 03:29:41
问题 I'd like to draw a red border around an image, but can't figure out how. I've tried to fill the image of the Hero sprite and set the colorkey to red self.image.set_colorkey(red) , but that makes the image invisible. Drawing a red rect onto the image, just filled it completely: pygame.draw.rect(self.image, red, [0, 0, width, height]) . I just want a red border that will help with collision detection in the future. The code in main.py : import pygame from pygame import * import sprites from

Why is the pygame rect not in the right place?

喜你入骨 提交于 2021-02-10 03:29:16
问题 I have collisions but I'd like my code to work so that when the bird touches the blocks, it print('x') . It is doing that but not in the right place of the bird. Apologies for the long code but it is needed for it to run. import random import pygame vec = pygame.math.Vector2 BLACK = (0,0,0) RED = (255,0,0) WIDTH = 500 HEIGHT = 400 pygame.init() window = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Flappy Bird') clock = pygame.time.Clock() class Bird(): def __init__

Why is the pygame rect not in the right place?

柔情痞子 提交于 2021-02-10 03:21:39
问题 I have collisions but I'd like my code to work so that when the bird touches the blocks, it print('x') . It is doing that but not in the right place of the bird. Apologies for the long code but it is needed for it to run. import random import pygame vec = pygame.math.Vector2 BLACK = (0,0,0) RED = (255,0,0) WIDTH = 500 HEIGHT = 400 pygame.init() window = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Flappy Bird') clock = pygame.time.Clock() class Bird(): def __init__

Why is the pygame rect not in the right place?

♀尐吖头ヾ 提交于 2021-02-10 03:16:00
问题 I have collisions but I'd like my code to work so that when the bird touches the blocks, it print('x') . It is doing that but not in the right place of the bird. Apologies for the long code but it is needed for it to run. import random import pygame vec = pygame.math.Vector2 BLACK = (0,0,0) RED = (255,0,0) WIDTH = 500 HEIGHT = 400 pygame.init() window = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption('Flappy Bird') clock = pygame.time.Clock() class Bird(): def __init__

Draw rectangle over texture OpenGL

杀马特。学长 韩版系。学妹 提交于 2021-02-09 05:33:19
问题 I'm using python 3 with pygame and OpenGL to try to accomplish what I thought it would be a simple task: Drawing a rectangle. The idea is to have a white rectangle over (or bellow) a transparent texture, but whenever I add the texture to the screen the rectangle vanishes, whether I render it before or after the texture. Bellow is a sample code displaying the problem (you can add any Player1.png image of your choice, the problem will remain the same - at least in my computer) import pygame

Draw rectangle over texture OpenGL

ぐ巨炮叔叔 提交于 2021-02-09 05:31:24
问题 I'm using python 3 with pygame and OpenGL to try to accomplish what I thought it would be a simple task: Drawing a rectangle. The idea is to have a white rectangle over (or bellow) a transparent texture, but whenever I add the texture to the screen the rectangle vanishes, whether I render it before or after the texture. Bellow is a sample code displaying the problem (you can add any Player1.png image of your choice, the problem will remain the same - at least in my computer) import pygame

How to import pygame in visual studio code?

懵懂的女人 提交于 2021-02-08 23:32:26
问题 I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be import ed in visual studio code). 回答1: Here is the solution I tried: From left bottom of your vs code you can find python environment, you can in the image I marked red: after clicking in the red marked area you can see below option to select: from the option select your desired one.

How to import pygame in visual studio code?

江枫思渺然 提交于 2021-02-08 23:18:22
问题 I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be import ed in visual studio code). 回答1: Here is the solution I tried: From left bottom of your vs code you can find python environment, you can in the image I marked red: after clicking in the red marked area you can see below option to select: from the option select your desired one.

How to import pygame in visual studio code?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-08 23:17:45
问题 I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be import ed in visual studio code). 回答1: Here is the solution I tried: From left bottom of your vs code you can find python environment, you can in the image I marked red: after clicking in the red marked area you can see below option to select: from the option select your desired one.

How to import pygame in visual studio code?

安稳与你 提交于 2021-02-08 23:09:50
问题 I use visual studio code for coding (python) and now I have to write a program with pygame for my project and I can't import pygame in visual studio code (I can import it with the python script, it just can't be import ed in visual studio code). 回答1: Here is the solution I tried: From left bottom of your vs code you can find python environment, you can in the image I marked red: after clicking in the red marked area you can see below option to select: from the option select your desired one.