pygame

如何在Windows上使用Python进行开发

隐身守侯 提交于 2019-12-29 18:59:37
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本文由葡萄城技术团队于原创并首发 转载请注明出处: 葡萄城官网 ,葡萄城为开发者提供专业的开发工具、解决方案和服务,赋能开发者。 一直以来C#都是微软在编程语言方面最为显著的Tag,但时至今日Python已经从一个小众语言,变成了世界编程语言排行榜排名前列的语言了。 Python也在Web开发、网络爬虫、数据分析、大数据处理、机器学习、科学计算及绘图等领域有着不错的天然优势和不俗的表现。微软再从收购了Github后,在开源社区投入的力度越来越大,所以对于Python的支持,和为Python社区提供更多的贡献,微软本身也承担起了更多的责任。 所以近日,微软上线了一套Python教程《Develp with Python on Windows》,文档内容包括设置Python开发环境、在Windows与WSL子系统中安装相应开发工具,以及如何集成VS Code与Git工具并进行开发等。下来也让我们先来看看如何配置Python开发环境以及Hello World教程。 设置开发环境 对于不熟悉 Python 的新手, 我们建议 从 Microsoft Store 安装 Python 。 通过 Microsoft Store 安装将使用 basic Python3 解释器, 但会为当前用户 (避免需要管理员访问权限)

Python - Livewires console error

我只是一个虾纸丫 提交于 2019-12-29 09:30:09
问题 This is the third time pygame/livewires has led me to this website, and let it be the last! After installing 'Python 3.1.1' for the book, 'Python Programming for the Absolute Beginner', I installed pygame and then livewires. I tested Pygame by entering import pygame And it worked by properly running it. However, when I tested livewires with ' from livewires import games, colors it produced no errors in IDLE, but did produce an error when I properly ran it. The error flicked away so quick I

Pygame - Compiling to exe with Cx_Freeze

随声附和 提交于 2019-12-29 09:19:08
问题 I'm trying to convert my pygame game to exe with Cx_freeze; It works fine when I run it from a script, but when I run it as an exe, it crashes with a: Traceback (most recent call last): File "C:\Python32\lib\site-packages\pygame\__init__.py", line 122, in <module> try: import pygame.display File "ExtensionLoader_pygame_display.py", line 12, in <module> File "ExtensionLoader_pygame_surface.py", line 12, in <module> ImportError: No module named _view During handling of the above exception,

Rendering text with multiple lines in pygame

本小妞迷上赌 提交于 2019-12-29 07:39:11
问题 I am trying to make a game and I am trying to render a lot of text. When the text renders, the rest of the text goes off the screen. Is there any easy way to make the text go to the next line of the pygame window? helpT = sys_font.render \ ("This game is a combination of all of the trends\n of 2016. When you press 'Start Game,' a menu will pop up. In order to beat the game, you must get a perfect score on every single one of these games.",0,(hecolor)) screen.blit(helpT,(0, 0)) 回答1: As I said

Where can I find and install the dependencies for pygame?

拜拜、爱过 提交于 2019-12-29 06:38:27
问题 I am relatively new to linux and am trying to install the pygame dev environment for python. When I run the setup.py it says that I need to install the following dependencies, one of which I found and installed (SDL). However, the others have been more elusive. Hunting dependencies... sh: smpeg-config: command not found WARNING: "smpeg-config" failed! SDL : found 1.2.14 FONT : not found IMAGE : not found MIXER : not found SMPEG : not found PNG : not found JPEG : not found SCRAP : found

Where can I find and install the dependencies for pygame?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-29 06:38:20
问题 I am relatively new to linux and am trying to install the pygame dev environment for python. When I run the setup.py it says that I need to install the following dependencies, one of which I found and installed (SDL). However, the others have been more elusive. Hunting dependencies... sh: smpeg-config: command not found WARNING: "smpeg-config" failed! SDL : found 1.2.14 FONT : not found IMAGE : not found MIXER : not found SMPEG : not found PNG : not found JPEG : not found SCRAP : found

What is a good way to draw images using pygame?

一曲冷凌霜 提交于 2019-12-29 06:14:52
问题 I would like to know how to draw images using pygame. I know how to load them. I have made a blank window. When I use screen.blit(blank, (10,10)) , it does not draw the image and instead leaves the screen blank. 回答1: This is a typical layout: myimage = pygame.image.load("myimage.bmp") imagerect = myimage.get_rect() while 1: your_code_here screen.fill(black) screen.blit(myimage, imagerect) pygame.display.flip() 回答2: import pygame, sys, os from pygame.locals import * pygame.init() screen =

Pygame attribute, init()

↘锁芯ラ 提交于 2019-12-29 01:49:06
问题 I'm trying to use Pygame with Python 3.3 on my windows 8 laptop. Pygame installed fine and when I import pygame it imports fine as well. Although when I try to execute this small code: import pygame pygame.init() size=[700,500] screen=pygame.display.set_mode(size) I get this error: Traceback (most recent call last): File "C:\Users\name\documents\python\pygame_example.py", line 3, in <module> pygame.init() AttributeError: 'module' object has no attribute 'init' I used pygame-1.9.2a0-hg

Pygame- window and sprite class - python

為{幸葍}努か 提交于 2019-12-28 07:08:36
问题 Im trying to build a window class which resembles a class which sprites live in. In the window class i want to have the following things: set_background() set_size() add_sprite() remove_sprite() In the sprite class i want the following methods: draw_sprite() For now i will have one sprite, but i would eventually like to have a list of sprites. I've tried running what I have in a main class by calling these methods on its instances. window = Window(200,200) sprite = Sprite(Window) window.set

How can I detect if the user has double-clicked in pygame?

耗尽温柔 提交于 2019-12-28 06:34:12
问题 I know I can check if there was a left click event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT but how can I check if they double clicked? Also is there any way to check if the user moved the scroll wheel forward or backwards? 回答1: I've never used pygame - but: Detecting double clicks: at a guess, instead of processing each click immediately, apply a 50ms delay and see if you get another click event in that time. The user probably won't notice the 50ms delay. Distinguishing