pygame

Lag when win.blit() background pygame

旧巷老猫 提交于 2021-01-29 22:13:20
问题 I'm having trouble with the framerate in my game. I've set it to 60 but it only goes to ~25fps. This was not an issue before displaying the background (was fine with only win.fill(WHITE) ). Here is enough of the code to reproduce: import os, pygame os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (50, 50) pygame.init() bg = pygame.image.load('images/bg.jpg') FPS = pygame.time.Clock() fps = 60 WHITE = (255, 255, 255) BLUE = (0, 0, 255) winW = 1227 winH = 700 win = pygame.display.set_mode((winW,

How to hold a 'key down' in Pygame?

99封情书 提交于 2021-01-29 22:12:18
问题 I use Pygame 1.9.6 and Python 3.7.4. I want to hold down the space bar and it continuously does the same action over and over. I know how to have have the button get pressed with KEYDOWN . I looked at the question: How to efficiently hold a key in Pygame? for answers but can't understand the one answer: while not done: keys = key.get_pressed() if keys[K_DOWN]: print "DOWN" for e in event.get(): pass # proceed other events. # always call event.get() or event.poll() in the main loop I don't get

pycharm doesn't recognize pygame package

别来无恙 提交于 2021-01-29 22:11:49
问题 I'm using mac OsX 10.8.2 , pyCharm 2.7.1 . python 2.7.2 I want to use pygame package with pycharm . I followed the instructions on the pygame site and installed pygame 1.9.1 successfully. When I write "import pygame" pycharm doesn't find the package. I tried installing the latest updates of python, pycharm and pygame. I tried using the "install" window in the preferences. It installed "pygamess", "pygameui" and "pyviewx.pygame", but when I try to instal "pygame_loaders" it writes "Install

Cannot install pygame in Pycharm

心不动则不痛 提交于 2021-01-29 22:11:44
问题 I'm on Windows 10 on an Asus. I'm using python 3.8. I installed successfully pygame on another computer (lenovo yoga, same OS) and worked fine. Then I tried to install the same package on this computer (the Asus) using pip and worked just fine. The issue is that when I try to import pygame in PyCharm the module seems not to exits Traceback (most recent call last): File "C:/Users/nicho/PycharmProjects/test/pygame_/2d pvm game/game.py", line 2, in <module> import pygame ModuleNotFoundError: No

Loop over a list containing path to sound files [duplicate]

試著忘記壹切 提交于 2021-01-29 22:11:42
问题 This question already has answers here : How do I schedule an audio file to play automatically in pygame after the first song ends? (1 answer) Pygame Playlist without while True loop (1 answer) Pygame Music Queue not functioning [closed] (2 answers) Closed 5 months ago . So what I was planning to do was loop over a list which contains path to my sound files and play them using pygame.mixer module in python, but when I did this the problem I encountered was pygame always play the last most

How to run multiple while loops at a time in Python [duplicate]

余生颓废 提交于 2021-01-29 22:11:31
问题 This question already has answers here : How to wait some time in pygame? (3 answers) How to make image stay on screen in pygame? (3 answers) Spawning multiple instances of the same object concurrently in python (1 answer) Closed last month . I'm trying to work on a simple Pygame program for a project that simply displays some faces and talks in a text to speech voice, but there is a while loop at the end that is necessary for the code to run but blocks another while loop that I need for the

Pyinstaller Unable to access Data Folder

帅比萌擦擦* 提交于 2021-01-29 22:10:18
问题 Below is the game.spec file that I have created. When running the below command, the app gets created perfectly pyinstaller --onefile game.spec When operating the game, it is unable to locate any of the datafiles. On further exploration found that it searches for all the datafiles in the directory /Users/username and not from the absolute path the program runs from. Does the spec file need to be written differently? # -*- mode: python ; coding: utf-8 -*- block_cipher = None a = Analysis([

How to simulate Jumping in Pygame for this particular code

百般思念 提交于 2021-01-29 22:10:11
问题 I have been trying to simulate the jump in the Pygame code but haven't been able to successfully implement it. There is a rectangle of dimension 10 by 10 and I want that rectangle to jump when SPACE is press. I am keeping this code independent of gravity for now. import pygame pygame.init() ScreenLenX = 1000 ScreenLenY = 500 win = pygame.display.set_mode((ScreenLenX, ScreenLenY)) pygame.display.set_caption("aman") run = True Xcord = 100 Ycord = 100 length = 10 height = 10 vel = 2 xmove = 1

How to simulate Jumping in Pygame for this particular code

断了今生、忘了曾经 提交于 2021-01-29 21:24:45
问题 I have been trying to simulate the jump in the Pygame code but haven't been able to successfully implement it. There is a rectangle of dimension 10 by 10 and I want that rectangle to jump when SPACE is press. I am keeping this code independent of gravity for now. import pygame pygame.init() ScreenLenX = 1000 ScreenLenY = 500 win = pygame.display.set_mode((ScreenLenX, ScreenLenY)) pygame.display.set_caption("aman") run = True Xcord = 100 Ycord = 100 length = 10 height = 10 vel = 2 xmove = 1

Pyinstaller Unable to access Data Folder

别说谁变了你拦得住时间么 提交于 2021-01-29 21:18:24
问题 Below is the game.spec file that I have created. When running the below command, the app gets created perfectly pyinstaller --onefile game.spec When operating the game, it is unable to locate any of the datafiles. On further exploration found that it searches for all the datafiles in the directory /Users/username and not from the absolute path the program runs from. Does the spec file need to be written differently? # -*- mode: python ; coding: utf-8 -*- block_cipher = None a = Analysis([