Chromebook上没有视频设备。

3

我想用pygame在Google的协作平台上编写游戏。我已经成功地通过运行以下代码添加了pygame:

import os
!git clone https://github.com/ntasfi/PyGame-Learning-Environment.git
os.chdir('PyGame-Learning-Environment')
!pip install -e .
!pip install pygame
os.chdir('/content')

但是当我写下这段代码时:

import pygame
pygame.init()
BLACK = [0,0,0]
size = [100,100]
screen = pygame.display.set_mode((size))
screen.fill(BLACK)
screen.update()

pygame.quit()

我收到了以下错误信息:
Traceback (most recent call last)
<ipython-input-10-b26800e3009a> in <module>()
BLACK = [0,0,0]
size = [100,100]
screen = pygame.display.set_mode((size)) 
screen.fill(BLACK)

错误:没有可用的视频设备

有没有办法让pygame检测到笔记本电脑屏幕?

1个回答

1

first of all try this

import pygame
pygame.init()
BLACK = (0, 0, 0) #dont use []'s
WIDTH = 0 #yourwidth
HEIGHT = 0 #yourheight
screen = pygame.display.set_mode((WIDTH,HEIGHT)) 
screen.fill(BLACK)
running = True
while(running):
 for event in pygame.event.get():
  if event.type == pygame.QUIT:
   running = False

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接