【问题标题】:No video device on chromebookchromebook 上没有视频设备
【发布时间】:2020-01-08 07:31:14
【问题描述】:

我正在尝试使用 pygame 在谷歌合作实验室中使用 pygame 编写游戏。我通过运行成功添加了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 检测笔记本电脑屏幕吗?

【问题讨论】:

    标签: python pygame chromebook


    【解决方案1】:

    首先试试这个

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-12-31
      • 1970-01-01
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 2020-06-14
      相关资源
      最近更新 更多