pygame

Pyinstaller pygame window closes with no error message [duplicate]

微笑、不失礼 提交于 2021-01-07 02:21:34
问题 This question already has answers here : PyInstaller, spec file, ImportError: No module named 'blah' (3 answers) Pyinstaller Unable to access Data Folder (1 answer) Python - pygame error when executing exe file (3 answers) Closed 6 days ago . I have been at this for about 2 hours now and I am getting quite frustrated, I have created a pygame file which doesn't use any external fonts or images (which i know is the main issue on why the game screen usually crashes) however I run mine and in the

Importing Pygame, ModuleNotFoundError: No module named 'pygame.base'

别说谁变了你拦得住时间么 提交于 2021-01-07 01:35:35
问题 I’m having trouble importing the Pygame module. I installed pygame using the following command in the terminal: pip install pygame When I enter import pygame and run the script, I get the following error: Traceback (most recent call last): File "C:\Users\Pruthvi\.spyder-py3\temp.py", line 1, in <module> import pygame File "C:\Users\Pruthvi\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pygame\__init__.py", line 130, in <module> from pygame.base import * ModuleNotFoundError: No

python音乐播放器第二版

寵の児 提交于 2021-01-07 00:56:15
此代码是上一期的改版 需要用到的 Python库有 1 . pygame 2 . time 3 .xmusic(我自己写的用来做音乐索引) 4 .colorama(美观) 推荐使用pip安装 方法: pip install 库 1 # -* encoding:utf-8 *- 2 import xmusic 3 import colorama 4 from colorama import Fore 5 # 音乐库 6 # Music 7 while True: 8 colorama.init() 9 text = ''' 10 ----↓歌曲列表↓---- 11 12 1.02的爱恋 13 2.奇迹再现 14 3.花降 15 4.布鲁克的心跳 16 17 ''' 18 print (Fore.RED + text) 19 20 M_1 = { ' 02的爱恋 ' } 21 M_2 = { ' 奇迹再现 ' } 22 M_3 = { ' 花降 ' } 23 M_4 = { ' 布鲁克的心跳 ' } 24 # 要查的歌名 25 name_m = input( ' 输入要搜索的歌名: ' ) 26 request = input( " 点击任意键播放... " ) 27 print ( ' —————————————————————————— ' ) 28 if name_m in M

python 模拟(简易)音乐播放器

和自甴很熟 提交于 2021-01-06 22:55:40
模拟一个在线音乐播放程序 # 1, 使用C/S架构来进行设计,分别写出客户端和服务器程序 # 2,客户端链接服务器之后,服务器向用户提示可以选择的歌曲列表,用户选择后开始播放(音频文件存放在本地即可) #思路是通过socketserver ,客户端发送指令到服务端,服务端连接数据库查到歌曲名字路径返回给客户端,客户端通过pygame模块查找到歌曲路径 播放歌曲 #创建数据表,插入歌曲名字和路径 CREATE TABLE t_music( id INT PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR(32), path VARCHAR(32) ) SELECT * FROM t_music INSERT INTO t_music(NAME,path) VALUE("味道","D:\\\\老男孩\\\\味道.mp3"),("世间美好与你环环相扣","D:\\\\老男孩\\\\世间美好与你环环相扣.mp3") 服务端: import pymysql import json import socketserver class MyServer(socketserver.BaseRequestHandler): @classmethod def conn(cls,name): conn = pymysql.connect(host="localhost",

Python - [Errno 10054] An existing connection was forcibly closed by the remote host - sending pickled data issues

主宰稳场 提交于 2021-01-06 05:51:47
问题 I followed an online tutorial that showed how to make a rock paper scissors game that can handle multiple clients connecting to a server, allowing multiplayer. The game works so I tried to use the same network logic for a different game but I ran into some errors there. Particularly when using the send function: Using the send function I get an EOFError: Ran out of input error. In this post Online game give the error "("ConnectionAbortedError: [WinError 10053] " I found a supposed fix where

Python - [Errno 10054] An existing connection was forcibly closed by the remote host - sending pickled data issues

时间秒杀一切 提交于 2021-01-06 05:49:49
问题 I followed an online tutorial that showed how to make a rock paper scissors game that can handle multiple clients connecting to a server, allowing multiplayer. The game works so I tried to use the same network logic for a different game but I ran into some errors there. Particularly when using the send function: Using the send function I get an EOFError: Ran out of input error. In this post Online game give the error "("ConnectionAbortedError: [WinError 10053] " I found a supposed fix where

Pygame - number of sprites in a group

时光毁灭记忆、已成空白 提交于 2021-01-06 04:12:49
问题 How do I determine how many sprites are in a group? len() should work, but just... doesn't. Code: print(len(sprites)) print('sprites',sprites) Output: 0 ('sprites', <Group(1 sprites)>) (Yes, I did make a group called 'sprites') EDIT: I renamed "sprites" to "aliveSprites", just in case that was the issue. No luck. Here's the code: print(len(aliveSprites.sprites())) if len(aliveSprites.sprites()) == 0: thing = test() aliveSprites.add(thing) thing.rect.x = 100 thing.rect.y = 300 print('sprites'

Collision detection between a polygon and a circle

谁都会走 提交于 2021-01-05 12:32:28
问题 I was wondering how collision detection worked in pygame, between a polygon and a circle, for a football game. What I am trying to do, is make a ball move in the direction that the car hit it in. Please can somebody fix my code, I'm very stuck!!. If you run the following code, two cars will move, but nothing will happen if they hit the ball, and no error messages(Line 26 for my attempt at making it work). For starters, I just want it to print("Hello"). I would really appreciate if someone

Pygame: Centering text system font text

风流意气都作罢 提交于 2021-01-05 11:24:25
问题 I have read this post about centering text: python library pygame: centering text However instead of importing text from a file: font = pygame.font.Font("example_font.tff", 25) I want to use a font from the users system font = pygame.freetype.SysFont("comicsansms", 0) using the freetype module as I think makes rendering to various sizes easier (like when the user resizes the window) font.render_to(surface, pos, ..., size=int(surface.get_height()/2)) Im not sure how to set a value for pos

Pygame window crashing and sprite sheet issue

流过昼夜 提交于 2021-01-05 09:38:46
问题 So I've been testing out this code, I found a tutorial on how I can add spritesheets in pygame and decided to try this one: https://www.spriters-resource.com/3ds/dragonballzextremebutoden/sheet/67257/ I did as the video said and counted the columns and rows, this is my code: pygame.init() CLOCK = pygame.time.Clock() DS = pygame.display.set_mode((W, H)) FPS = 60 class spritesheet: def __init__(self, filename, cols, rows): self.sheet = pygame.image.load(filename).convert_alpha() self.cols =