python运行时黑屏什么原因_pygame 程序未报错却黑屏无法显示 请问有大佬知道解决方法吗...
修改如下, 说明在每行右边的批注
import pygame
import sys
# set everything to where started
pygame.init()
size = width, height = 650, 650
speed = [-2,1]
bg = (255, 255, 255)
# create a window with a determined size
screen = pygame.display.set_mode(size)
# create window title
pygame.display.set_caption("Hello!")
ball = pygame.image.load("D://soccer.jpg")
# position of the image
position = ball.get_rect()
clock = pygame.time.Clock()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit() # quit from pygame
sys.exit()
# move the image # From this line
position = position.move(speed) # should indent
screen.fill(bg) # clear screen
screen.blit(ball, position) # draw ball at position
pygame.display.update() # update screen
clock.tick(100) # 100 frames/second
if position.left < 0 or position.right > height:
# flip image
ball = pygame.transform.flip(ball, True, False) # flip image to ball
# move to the other side
speed[0] = -speed[0] # index 0 for x
if position.top < 0 or position.bottom > height:
speed[1] = -speed[1]
python运行时黑屏什么原因_pygame 程序未报错却黑屏无法显示 请问有大佬知道解决方法吗...相关推荐
- 运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法
运行python脚本时,报错InsecurePlatformWarning: A true SSLContext object is not available,解决方法 参考文章: (1)运行pyt ...
- Python使用pip安装报错ModuleNotFoundError: No module named ‘pip._internal.cli.main‘的解决方法
Python使用pip安装报错ModuleNotFoundError: No module named 'pip._internal.cli.main'的解决方法 大家好,我叫亓官劼(qí guā ...
- Python 使用numpy报错:runtimeError: package fails to pass a sanity check解决方法
Python中使用numpy和pandas时报错:RuntimeError: The current Numpy installation ('...\venv\lib\site-packages\n ...
- python自动发邮件报554错误_python-自动化测试结果发送邮件报错(smtplib.SMTPDataError: (554, b'DT:SPM 163……)解决方法...
先把我的邮件发送脚本粘贴上来吧,再解释下我的报错和解决方法: import smtplib,email,os,time,yagmail from email.mime.multipart import ...
- designer打开报错 qt_无法启动 Maya 集成的 qt designer 的解决方法和原因 以及 中英文切换...
无法启动 Maya 集成的 qt designer 的解决方法和原因 以及 中英文切换 前言: Maya 集成了 PySide,同时集成了qt designer,在 Maya 的安装目录下的 bin ...
- 【Python 脚本报错】AttributeError: 'module 'yyy' has no attribute 'xxx'的解决方法
先参考这篇记录大概理解了原因, 再深入了解下python的import机制, 发现自己的模块之间存在互相import. 比如,A.py中import B,而B.py中也import A了, 现在执行模 ...
- Ubuntu运行roscore时候报错 Unable to contact my own server at xxx的解决方法
在设置环境变量时,输入这两个指令: echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.b ...
- Flutter开发:运行flutter upgrade命令报错Exception:Flutter failed to create a directory at…解决方法
前言 在Flutter开发中,经常会遇到因为更新而引起的报错,而且最近两年Flutter不断完善和更新的速度越来越快,这就需要Flutter相关的开发者时刻保持不断学习的心态,来应对在Flutter开 ...
- camera android 黑屏,Android Camera.startPreview()启动未报错,但SurfaceView无画面输出
问题如标题所示,不知道问题出在那里,能正常出数据,但是画面就是没有,请各位大神指点迷津 代码如下 package com.jiechu.wnd.sl; import android.content.C ...
最新文章
- 人体姿态估计--Learning Feature Pyramids for Human Pose Estimation
- 解除计算机软件开发协议书,计算机软件著作权转让的协议书
- python3各版本区别-Python2 与Python3的版本区别实例分析
- kvm热添加和热迁移
- 基于 Roslyn 实现动态编译
- 代码android点击效果,GitHub - likaiyuan559/TouchEffects: Android View点击特效TouchEffects,几行代码为所有控件添加点击效果...
- 聊聊FilterSecurityInterceptor
- php framework interop group,PHP超全局变量 - 山鹰sniper的个人空间 - OSCHINA - 中文开源技术交流社区...
- dqkg的命令用法_CADk中常用命令使用方法及说明
- eNSP网络类型实验报告
- Git - git push origin master 报错的解决方法 出现[rejected] master -」 master (non-fast-forward)问题解决
- 护理自考本科科目计算机应用基础,护理自考本科考哪些科目
- 互联网金融学习总结(7)——2019年线下大额现金贷产品设计和风控手段
- 灰灰考研机试班 | 基础练习二 问题 B: 日历本 | 入门题-模拟 | 日期、星期相关计算
- PowerShell install 一键部署VMware_Workstation
- pvid与access的关系_关于Trunk、Hybrid、Access、Tag、Untag、Pvid的关系
- MySQL学习记录(11.9更新)
- 特征值和特征向量的理解 浅显易懂 肯定有收获
- 导入semantic-ui-css/semantic.min.css样式失败
- 小区AO 各地小区边界下载
热门文章
- 网上下载的WINRAR文件被锁定了,怎样解锁呢
- 卡尔曼滤波——迭代过程
- Mysql 使用商城表完成对商品信息的多表查询
- python无限循环和遍历循环,python中什么叫遍历
- Sonarqube源码解析
- AM2302+STM32驱动程序
- HTML小游戏17 —— 弗莱迪的物理实验游戏(附完整源码)
- 【WPS表格】给数据透视表分组
- 倚天屠龙记决战光明顶java,新倚天屠龙记张无忌决战光明顶 一人从头打到尾动作满分...
- 组态王使用指南|安装包|快速入门教程|含PLC与组态王网口串口通信|速查命令PDF