pygame

How to import pygame in visual studio code?

馋奶兔 提交于 2021-02-08 23:08:35
问题 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?

a 夏天 提交于 2021-02-08 23:08:25
问题 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.

Pyinstaller - Error Message: name Actor is not defined

大憨熊 提交于 2021-02-08 11:25:31
问题 I created a small game with Pygame and MU IDE. Then I wanted to convert the .py file to a .exe file with pyinstaller. It was no problem to create the exe file. But if I want to execute the created exe file I get the following error message: 'name Actor is not defined'. With MU IDE I can execute the corresponding .py file without any problems. How can I fix the problem? The full error message is: Hello from the pygame community. https://www.pygame.org/contribute.html Traceback (most recent

Pygame collision detection, transparent border

半世苍凉 提交于 2021-02-08 10:52:18
问题 For my pygame project, I must detect collision betweeen various .png image that move on the screen. I have put the image inside sprite, and the sprite inside group, then I use this : pygame.sprite.spritecollide(perso, zombie_group, False) However, sometime, my image don't touch, but pygame detect a collision... This is due to the fact that my images are png with transparent borders. The transparent border collide, and pygame detect this :( Any idea to stop the transparent border from

Pygame collision detection, transparent border

北慕城南 提交于 2021-02-08 10:50:38
问题 For my pygame project, I must detect collision betweeen various .png image that move on the screen. I have put the image inside sprite, and the sprite inside group, then I use this : pygame.sprite.spritecollide(perso, zombie_group, False) However, sometime, my image don't touch, but pygame detect a collision... This is due to the fact that my images are png with transparent borders. The transparent border collide, and pygame detect this :( Any idea to stop the transparent border from

Pygame collision detection, transparent border

早过忘川 提交于 2021-02-08 10:49:45
问题 For my pygame project, I must detect collision betweeen various .png image that move on the screen. I have put the image inside sprite, and the sprite inside group, then I use this : pygame.sprite.spritecollide(perso, zombie_group, False) However, sometime, my image don't touch, but pygame detect a collision... This is due to the fact that my images are png with transparent borders. The transparent border collide, and pygame detect this :( Any idea to stop the transparent border from

Pygame.MOUSEBUTTONDOWN coordinates are off unless i'm in xwindows

青春壹個敷衍的年華 提交于 2021-02-08 09:48:19
问题 If I load my pygame code from the console, it is reading the touchscreen coordinates wrong, but if I boot into xwindows, it reads them correctly. I've gone in and calibrated the touch screen, and if I run evtest from the console, I am getting the correct coordinates back. It is only within python that it is returning the incorrect coordinates of the touch. Is there something i'm missing to tell python how to calibrate? import sys, pygame pygame.init() black = 0, 0, 0 size = width, height =

python pygame the background image changes with the screen size

☆樱花仙子☆ 提交于 2021-02-08 09:15:53
问题 I set screen=p.display.set_mode((width,height),flag,0) as my pygame screen and flag=p.RESIZABLE makes the screen can be stretch. At this time i load an image as the background, now when i stretch the screen, the background wont change the size by the screen, how can i do it? here's the codes: #! /usr/bin/python import sys import pygame as p pic="/home/finals/python/alien/image/muha.png" def screen_setting(width,height): p.init() flag=p.RESIZABLE screen=p.display.set_mode((width,height),flag,0

Pygame: What is the best way to display these ships and their movement from sprite sheet?

与世无争的帅哥 提交于 2021-02-08 07:37:23
问题 Attached below is one of the sprite sheets I am using. Right now, I am wondering the best way to display the ships with their animation when moving. The ships have 9 frames. I have found old examples with deprecated code, or examples that have you break the images into individual files. I would love for someone to show me the best way to use these sprites as they are. Thank you for your time. 回答1: What is the best way can't be answered, because in the end that's subjective; and depends on

argument 1 must be pygame.surface, not list

纵然是瞬间 提交于 2021-02-08 06:15:30
问题 I'm programming a minor python game and some of my code doesn't seem to work. Have a look: import pygame import sys import pygame.sprite as sprite import time pygame.init() pygame.display.set_caption("Uni Mario") m_x = 100 m_y = 350 width = 40 height = 60 vel = 5 left=False right=False walk_count = 0 walkRight = [] walkLeft = [] myfont = pygame.font.SysFont("monospace", 25) screen_over = pygame.font.SysFont("monospace", 100) hitcount = 0 score=0 clock = pygame.time.Clock() FPS = 30 background