pygame

Blinking rectangle white pygame with specific frequency

眉间皱痕 提交于 2019-12-23 04:45:34
问题 I'm student at university and I have a specific question. Presently I display a white rectangle in center of a window with pygame above a black background. But presently I would like to blinking my white rectangle at a specific frequency, and it's why a I need help. Presently I implement that: import pygame, sys from pygame.locals import * def main(): pygame.init() fenetre = pygame.display.set_mode((500,400),0,32) black=(0,0,0) white=(255,255,255) fenetre.fill(black) pygame.draw.rect(fenetre,

Integrate Pygame window with GUI

懵懂的女人 提交于 2019-12-23 04:44:02
问题 Im using Pyqt4, and I was wondering if it was possible to integrate a Pygame window to a PQT window. Ive been searching the net, and I can only find integration for wxPython, or tkinter. Something like this: Im suing Pygame 3 and Python 3. Thanks in advance! 回答1: The page http://pygame.org/wiki/gui this is difficult and if you can, will have severe limitations. That said, I haven't seen how wx and tkinter do it. But one approach I have seen before is to create two separate applications that

Problems with Cx_freeze

孤街浪徒 提交于 2019-12-23 04:38:19
问题 If I'm actually asking you for help, it's because I spend many hours for nothing into trying to fix my problem: I would like to compile my python script into .exe: (I am using Python 32 bits 3.1.4 and pygame) I have 4 files: Class .pyc, _Class_game.pyc, _ressources.pyc et main.py and a folder @ressources with all images and songs This is my scritp setup.py: import cx_Freeze executables = [cx_Freeze.Executable("main.py"), base = "Win32GUI"] cx_Freeze.setup( name="Strike The square", version =

PyGame Sprites Occasionally Not Drawing

会有一股神秘感。 提交于 2019-12-23 04:37:12
问题 I am trying to make a basic card game using PyGame. I am currently just trying to draw a single card to the screen. The weird thing is, occasionally it will draw and occasionally it won't. Below is my code: import pygame from pygame.locals import * from socket import * import sys import os import math import getopt import random def load_png(name) : # Loads an image and returns the image object fullname = os.path.join('/home/edge/Downloads/Playing Cards/PNG-cards-1.3', name) image = pygame

Pygame through SSH does not register keystrokes (Raspberry Pi 3)

流过昼夜 提交于 2019-12-23 03:51:30
问题 So I got raspi 3 and simple 8x8 LED matrix. After some playing with it I decided to make a simple snake game (displaying on that matrix) with pygame's events, I have no prior experience with pygame. There is no screen/display connected besides the led matrix. So the problem at first was "pygame.error: video system not initialized", though I think i got it fixed by setting an env variable: os.putenv('DISPLAY', ':0.0') Now that I got it working I run it...and nothing happens, like no keystrokes

Pygame through SSH does not register keystrokes (Raspberry Pi 3)

南楼画角 提交于 2019-12-23 03:51:24
问题 So I got raspi 3 and simple 8x8 LED matrix. After some playing with it I decided to make a simple snake game (displaying on that matrix) with pygame's events, I have no prior experience with pygame. There is no screen/display connected besides the led matrix. So the problem at first was "pygame.error: video system not initialized", though I think i got it fixed by setting an env variable: os.putenv('DISPLAY', ':0.0') Now that I got it working I run it...and nothing happens, like no keystrokes

How to get the picture size in pygame (python)

℡╲_俬逩灬. 提交于 2019-12-23 03:28:06
问题 If I'm using an image and I want to know the image's size in the file . There is a function to get the picture's height and width ? EDIT: Of course I loaded the image to the program with pygame.image.load(PATH). 回答1: I believe you need to load the image as a Surface before you can get its width and height. You do that with foo = pygame.image.load(PATHNAME) . Then you can get the width and height by creating a Rectangle with foo.get_rect() and asking the rectangle. 回答2: import pygame foo =

Pip Install EOFError

﹥>﹥吖頭↗ 提交于 2019-12-23 03:11:38
问题 I am using windows 10 and recently updated to python 3.8. I'm trying to install pygame on the new version and tried py -m pip install -U pygame --user but got this error: ERROR: Command errored out with exit status 1: command: 'C:\Users\username\AppData\Local\Programs\Python\Python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\username\\AppData\\Local\\Temp\\pip-install-_e3mjg4_\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\username\\AppData\\Local\

How do I unload images in Pygame?

为君一笑 提交于 2019-12-23 03:02:07
问题 I am trying to rename an image currently being viewed in a PyGame window (same program), and since that isn't really a good idea, I had it rename at the end of the program. However, it still gives me the error: WindowsError: [Error 32] The process cannot access the file because it is being used by another process I tried "quitting" (un-initializing) the PyGame and the display, but it still says that it cannot rename the file with the error above. Is there a way to unload images? Is that what

Pygame, get key object from character

依然范特西╮ 提交于 2019-12-23 01:46:07
问题 I'm making a multiplayer platformer/shooter/brawl game with pygame and I'd like for the players to easily change their keybinds (such as from a config file). I haven't been able to find a way to read a character string and use that as a transition to the pygame.K_xx objects as of now so I ask the community. Any leads ? 回答1: With the constants of this list you can use getattr(pygame, 'K_'+ mychar) to access a constant by name. 来源: https://stackoverflow.com/questions/46714719/pygame-get-key