pygame

How to save captured image to disk, using Pygame

断了今生、忘了曾经 提交于 2020-01-13 08:30:29
问题 This is my code, which starts the webcam : import pygame.camera import pygame.image import sys pygame.camera.init() cameras = pygame.camera.list_cameras() print "Using camera %s ..." % cameras[0] webcam = pygame.camera.Camera(cameras[0]) webcam.start() # grab first frame img = webcam.get_image() WIDTH = img.get_width() HEIGHT = img.get_height() screen = pygame.display.set_mode( ( WIDTH, HEIGHT ) ) pygame.display.set_caption("pyGame Camera View") while True : for e in pygame.event.get() : if e

Is there a simple way to make and save an animation with Pygame?

让人想犯罪 __ 提交于 2020-01-12 10:51:14
问题 I made a very simple fractal generator that prints out each step; I want to put it in a presentation I made. The tool with which I'm making the presentation obviously doesn't support pygame, is there any way to save it as a video? Preferably as an animated .gif or the like. 回答1: Not directly. But you can save a screencast of your program with one of the many available utilities that do this. I don't know about Windows or OSX, but if you are on Ubuntu or other gnome-based desktop you can

Installing Pygame through Pycharm or System Terminal

雨燕双飞 提交于 2020-01-11 14:17:10
问题 Im currently running Python 3.7.0b4 and attempting to install the Pygame package, however I keep getting the error. Command "python setup.py egg_info" failed with error code 1 in C:\Users\Jack\AppData\Local\Temp\pycharm-packaging\Pygame\ This is the error produced by the system terminal, another distinct error by Pycharm is: TypeError: can only concatenate str (not "NoneType") to str This is for installing Pygame 1.9.3. My pip is up to date and so is my set-up tools. I have no idea how to

How can I make a scrolling background in python with pygame?

孤人 提交于 2020-01-11 14:09:16
问题 I've been trying to make a space shooting game for the past 2 days and I want to make the background scrolling down but i don't know how. Heres my code: import pygame import time pygame.init() width = 800 height = 600 black = (0,0,0) white = (255,255,255) red = (255,0,0) green = (0,255,0) blue = (0,0,255) ship_width = 35 ship_height = 64 disp = pygame.display.set_mode((width,height)) pygame.display.set_caption("Space Jump") clock = pygame.time.Clock() background = pygame.image.load("Space.png

How can I make a scrolling background in python with pygame?

别说谁变了你拦得住时间么 提交于 2020-01-11 14:05:32
问题 I've been trying to make a space shooting game for the past 2 days and I want to make the background scrolling down but i don't know how. Heres my code: import pygame import time pygame.init() width = 800 height = 600 black = (0,0,0) white = (255,255,255) red = (255,0,0) green = (0,255,0) blue = (0,0,255) ship_width = 35 ship_height = 64 disp = pygame.display.set_mode((width,height)) pygame.display.set_caption("Space Jump") clock = pygame.time.Clock() background = pygame.image.load("Space.png

Pygame Scrolling

我们两清 提交于 2020-01-11 14:02:25
问题 I am currently taking an A level computer science course in which I have to create a game for a project. I know this code is probably not efficient but I am trying to keep it to my own work and would like a hand with one bit that I am confused on. I am trying to scroll the screen right and left which i know is done by moving every object on the screen in the relevant direction. I have created boundaries for which the screen should start to move when the robot is within them. But for the code

How do I get my object in pygame to move by holding the button?

浪子不回头ぞ 提交于 2020-01-11 12:02:29
问题 I tried using something like this but it did not work. while running: keys = pygame.key.get_pressed() #checking pressed keys if keys[pygame.K_UP]: y1 -= 1 if keys[pygame.K_DOWN]: y1 += 1 Here is the code I have at the moment. I tried using a different method because the above method did not work for me. It moves it one button tap at a time. import pygame spaceX = 100 spaceY = 100 pygame.init black = (0,0,0) size = (800, 800) screen = pygame.display.set_mode(size) def game(spaceX, spaceY):

How to implement a timeout/cooldown after collision

怎甘沉沦 提交于 2020-01-11 10:38:15
问题 I have been making a pygame game where two players try and hit a ball into a net. I have a boost feature in my game, however, I want some boost pads where when they are collected, I get +3 boost. In my code below, there is a huge yellow one, when someone hovers over it, they get the boost but they can stay on it forever and get lots of boost. I would like a way where the boost pad becomes inactive for 3 seconds once it has been collected, and turns grey. Is there any way for this? import

Screen only updates when I check for user input pygame

无人久伴 提交于 2020-01-11 10:32:34
问题 I'm using pygame and updating to the screen every loop of the main loop. What I don't understand is nothing will update until I add a for loop looking for events, then suddenly all the updating does occur. Why is this? def run(self): two_pm = get_stand_up_timestamp() pygame.init() font = pygame.font.Font(None, 72) screen = pygame.display.set_mode(self._dimensions) before_two = True while before_two: # Blit the time to the window. # Update Screen. current_time = datetime.datetime.now() text =

Screen only updates when I check for user input pygame

最后都变了- 提交于 2020-01-11 10:32:22
问题 I'm using pygame and updating to the screen every loop of the main loop. What I don't understand is nothing will update until I add a for loop looking for events, then suddenly all the updating does occur. Why is this? def run(self): two_pm = get_stand_up_timestamp() pygame.init() font = pygame.font.Font(None, 72) screen = pygame.display.set_mode(self._dimensions) before_two = True while before_two: # Blit the time to the window. # Update Screen. current_time = datetime.datetime.now() text =