pygame

Any way to speed up Python and Pygame?

做~自己de王妃 提交于 2019-12-18 11:53:24
问题 I am writing a simple top down rpg in Pygame, and I have found that it is quite slow.... Although I am not expecting python or pygame to match the FPS of games made with compiled languages like C/C++ or event Byte Compiled ones like Java, But still the current FPS of pygame is like 15. I tried rendering 16-color Bitmaps instead of PNGs or 24 Bitmaps, which slightly boosted the speed, then in desperation , I switched everything to black and white monochrome bitmaps and that made the FPS go to

Allowing resizing window pyGame

≡放荡痞女 提交于 2019-12-18 11:52:54
问题 I am trying to allow resizing for this app, I put the RESIZABLE flag, but when I try to resize, it messes up! Try my code. It is a grid program, when the window resizes I want the grid to also resize/shrink. import pygame,math from pygame.locals import * # Define some colors black = ( 0, 0, 0) white = ( 255, 255, 255) green = ( 0, 255, 0) red = ( 255, 0, 0) # This sets the width and height of each grid location width=50 height=20 size=[500,500] # This sets the margin between each cell margin

Creating a board game simulator (Python?) (Pygame?)

两盒软妹~` 提交于 2019-12-18 11:09:39
问题 I've decided to start working on programming an old favorite of mine. I've never done a game before and also never done a large project in Python. The game is the old Avalon Hill game Russian Campaign I've been playing with PyGame a little bit and was wondering if there were reasons not to try to do this with PyGame and go after some other engine/language. What would be the disadvantages of using Pygame to build this? I'm not worried about AI, primarily I'd just love to get a minimal two

第420期 Python 周刊

江枫思渺然 提交于 2019-12-18 10:37:12
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 文章、教程或讲座 Python 数据科学教程:分析 Stack Overflow 2019 年开发者调查表** https://www.youtube.com/watch?v=_P7X8tMplsw 在此 Python 编程视频中,我们将从 Stack Overflow 2019 年的开发者调查中学习如何下载和分析这些数据。对于任何想入门数据科学领域的人来说这都是非常好的实践。你将学到用不同方法分析这些数据。 大规模部署 Python 代码 https://instagram-engineering.com/python-at-scale-strict-modules-c0bb9245c834 这是我们发布的关于在 Instagram 大规模部署 Python 代码的第三篇文章!正如我们第一篇文章中所提到的,Instagram 服务器是数百万行 Python 代码的集合:每天数百次提交,每隔几分钟部署到生产环境中。以这种规模和速度使用 Python 时,我们遇到了一些痛点。 通过深度学习寻找受欢迎的菜肴 https://engineeringblog.yelp.com/2019/10/discovering-popular-dishes-with-deep-learning.html Yelp 拥有近 2

how to get pygame button to register only one click?

空扰寡人 提交于 2019-12-18 09:41:59
问题 I'm making a game in pygame with a pressable button, but I want it to do only one thing when clicked. The code below prints "button pressed" for as long as you hold it down. What's an elegant way to change this code to make it only print that once per click? import pygame import sys pygame.init() screen = pygame.display.set_mode((640, 480),0,32) clock = pygame.time.Clock() def makeButton(x,y,width,height): if x + width > cur[0] > x and y + height > cur[1] > y: if click == (1,0,0): print

Pygame-Two display updates at the same time with a pygame.time.wait() function between

我的未来我决定 提交于 2019-12-18 09:37:57
问题 I add a pygame.time.wait(2000) function between two display updates expecting that after a keydown, it will first show up one text, then after 2 seconds, the second one. But it end up showing up the two texts simultaneously two seconds after the trigger. How should I correctly use the function to reach my goal? import pygame from pygame.locals import * from sys import exit SCREEN_WIDTH = 448 SCREEN_HEIGHT = 384 pygame.init() screen = pygame.display.set_mode([SCREEN_WIDTH, SCREEN_HEIGHT]) my

Pygame: Unable to open .mp3 file

时光总嘲笑我的痴心妄想 提交于 2019-12-18 09:33:54
问题 So... Whenever I try to run this block of code: import pygame, sys, time from pygame.locals import * pygame.init() DISPLAYSURF = pygame.display.set_mode((400, 300)) pygame.display.set_caption('Memes.') meme = pygame.mixer.Sound('JUST DO IT.mp3') meme.play() time.sleep(2) meme.stop() while True: # Main Loop for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update() I get this error: Traceback (most recent call last): File "C:\Users\Slay-Slay

Running a if statement only once in pygame

☆樱花仙子☆ 提交于 2019-12-18 09:21:19
问题 I have a running game where you can move and collect coins. For each coin I have a if statement: if cn1+25 < x and cn1 + 50 > x: cn1 = -1000 if cn1 < -3: coincount += 1 textObj = INVFONT.render(str(coincount+1), True, WHITE, BLACK) This if statement keeps happening over and over again, adding hundreds of coins to the variable coincount . Later in my code I blit the number of coins in coincount on to the screen. Is there a way to make sure this only runs once? (Here's the rest of my code, ut

Pygame.movie missing

我与影子孤独终老i 提交于 2019-12-18 09:01:25
问题 I am currently working with a RPi 3B (latest Raspbian Jessie) on a little project which involves playing a short .mp4 file. As Pygame seemed to support playing .mpg files, so I converted my video into that format. When I tried to import the movie module however, I get the common python import error: Traceback (most recent call last): File "film_app.py", line 3, in <module> import pygame.movie ImportError: No module named movie After some research, I figured others had the same issue as

Imports failing in VScode for pylint when importing pygame

元气小坏坏 提交于 2019-12-18 07:23:55
问题 When importing pygame pylint is going crazy: E1101:Module 'pygame' has no 'init' member E1101:Module 'pygame' has no 'QUIT' member I have searched the net and I have found this: "python.linting.pylintArgs": ["--ignored-modules=pygame"] It solves the problem with pygame, but now pylint is going crazy in other way: crazy_pylint.png. Then I have found "python.linting.pylintArgs": ["--ignored-files=pygame"] , but what it does is completely disabling pylint for the whole directory I am working in.