pygame

How to get rid of pygame surfaces?

人盡茶涼 提交于 2020-01-22 12:56:45
问题 In the following code, there is not just one circle on the screen at any given point in time. I want to fix this to make it so that it looks like there is only one circle, instead of leaving a smudge trail where ever the mouse cursor has been. import pygame,sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode((640,400),0,32) radius = 25 circle = pygame.Surface([radius*2]*2,SRCALPHA,32) circle = circle.convert_alpha() pygame.draw.circle(circle,(25,46,100),[radius]*2

How to get rid of pygame surfaces?

六月ゝ 毕业季﹏ 提交于 2020-01-22 12:56:09
问题 In the following code, there is not just one circle on the screen at any given point in time. I want to fix this to make it so that it looks like there is only one circle, instead of leaving a smudge trail where ever the mouse cursor has been. import pygame,sys from pygame.locals import * pygame.init() screen = pygame.display.set_mode((640,400),0,32) radius = 25 circle = pygame.Surface([radius*2]*2,SRCALPHA,32) circle = circle.convert_alpha() pygame.draw.circle(circle,(25,46,100),[radius]*2

Pygame实现鼠标到达的地方出现错误图标

回眸只為那壹抹淺笑 提交于 2020-01-21 19:04:46
Pygame实现鼠标到达的地方出现错误图标 前言 今天突发奇想,做了一个Python3程序,实现了鼠标到达的地方出现错误图标。 凭借"老夫"多月的"经验",我就知道一定不简单! 本想就这么算了,可是实在是太无聊了,想写代码,于是就有了这篇文章。 import pygame import sys # 初始化 pygame . init ( ) size = width , height = 1000 , 600 # 设置屏幕尺寸 screen = pygame . display . set_mode ( size ) # 创建surface对象 pygame . display . set_caption ( '画圆及拖拽' ) # 创建标题 picture = pygame . image . load ( '13.png' ) screen . fill ( WHITE ) # 填充屏幕 while True : for event in pygame . event . get ( ) : if event . type == pygame . QUIT : pygame . quit ( ) sys . exit ( ) x , y = pygame . mouse . get_pos ( ) x -= picture . get_width ( ) / 2 y -=

Python——pygame创建一个窗口

半世苍凉 提交于 2020-01-19 18:35:57
Python——pygame创建一个窗口的方法 下载Python的pygame后复制一下代码。 #导入pygame和sys模块 import pygame , sys from pygame . locals import * #初始化pygame pygame . init ( ) #建立一个600/600大小的窗口 screen = pygame . display . set_mode ( ( 600 , 600 ) ) #命名 pygame . display . set_caption ( "一个小窗口" ) #背景 screen . fill ( ( 255 , 255 , 255 ) ) #管理 while True : #鼠标点击x图标退出 for event in pygame . event . get ( ) : if event . type == QUIT : sys . exit ( ) #加载 pygame . display . update ( ) 流程很简单,自己去研究。 点击下方链接下载pygame pygame下载 pygame下载步骤自己想,right? 来源: CSDN 作者: 顶级程序员07 链接: https://blog.csdn.net/weixin_46140392/article/details/104042748

cmd pip displaying errors whenever I try to install pygame

ぃ、小莉子 提交于 2020-01-19 17:51:08
问题 I am on a windows 10 system, and I recently installed the latest version of python python 3.7.0. I enable the PATH and tried to install pygame through CMD. I first type in pip , that works as normal. I then try pip install pygame Now, this is where the problem arises. CMD comes up with this: Collecting pygame Using cached https://files.pythonhosted.org/packages/b0/30/4df62b0eb0f09a8ad1c329ff5479b3b115e8dce25475fd0c2f73cb790aa4/pygame-1.9.4-cp37-cp37m-win32.whl Installing collected packages:

cmd pip displaying errors whenever I try to install pygame

≯℡__Kan透↙ 提交于 2020-01-19 17:50:46
问题 I am on a windows 10 system, and I recently installed the latest version of python python 3.7.0. I enable the PATH and tried to install pygame through CMD. I first type in pip , that works as normal. I then try pip install pygame Now, this is where the problem arises. CMD comes up with this: Collecting pygame Using cached https://files.pythonhosted.org/packages/b0/30/4df62b0eb0f09a8ad1c329ff5479b3b115e8dce25475fd0c2f73cb790aa4/pygame-1.9.4-cp37-cp37m-win32.whl Installing collected packages:

Trying to make a “solid” block in pygame but it doesnt work

 ̄綄美尐妖づ 提交于 2020-01-17 20:21:33
问题 Hopefully you can help me, i have been struggling with this problem for the last few days. I want to make a "solid" block for my 2d platformer game that i am working on but when i go into that "solid" block i teleport to the other side or to the bottom of the block, i dont know why, hopefully you know why So here is my code: class Block(pygame.sprite.Sprite): def __init__(self, color = blue,widht = 64, height = 64): super(Block, self).__init__() self.image = pygame.Surface((widht, height))

'Player' object has no attribute 'rect [closed]

流过昼夜 提交于 2020-01-17 20:04:03
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 days ago . I have been trying for a while to resolve the following error message: ' ' Player 'object has no attribute' rect '. I have researched here in stack.overflow and see that it may be related to the type of declaration or indentation . But I can't understand where the code fails. The original code is from this

'Player' object has no attribute 'rect [closed]

旧时模样 提交于 2020-01-17 20:03:50
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 days ago . I have been trying for a while to resolve the following error message: ' ' Player 'object has no attribute' rect '. I have researched here in stack.overflow and see that it may be related to the type of declaration or indentation . But I can't understand where the code fails. The original code is from this

Python problems with game

僤鯓⒐⒋嵵緔 提交于 2020-01-17 14:52:10
问题 I'm really close to getting my game done, just add the bullets and destroy enemies when they are shot, however, when I run python, the program complains with this error "\Dodger.py", line 180, in bullets.remove(bullet) NameError: name 'bullet' is not defined." I know what an undefined error is but I don't know what kind of definition should I add to get the program to work, Here's the code: import pygame, random, sys from pygame.locals import * TEXTCOLOR = (0, 0, 0) FPS = 60 BADDIEMINSIZE = 8