我正在制作乒乓球游戏。当任何一个分数达到 10 时,它应该在屏幕上放一些文字,并说右边的玩家赢了或左边的玩家赢了。但是,在我的程序中,它不起作用。当它必须显示左右玩家获胜的文本时,它不会显示。但它适用于其他一切。这是代码:
# Importing libraries
import pygame
import random
import time
# Initializing PyGame
pygame.init()
# Setting a window name
pygame.display.set_caption("Ping Pong")
# Creating a font
pygame.font.init()
font = pygame.font.SysFont(None, 30)
pong_font = pygame.font.SysFont("comicsansms", 75)
# Set the height and width of the screen
window_width = 700
window_height = 500
size = [window_width, window_height]
game_win = pygame.display.set_mode(size)
game_win2 = pygame.display.set_mode(size)
# Creating a messaging system
def message(sentence, color, x, y, font_type, display):
sentence = font_type.render(sentence, True, color)
display.blit(sentence, [x, …Run Code Online (Sandbox Code Playgroud) 我正在编写一个需要实时日期的程序(意思是当前日期)。这是代码。
from datetime import date
today_date = date.today()
print(list(today_date))
Run Code Online (Sandbox Code Playgroud)
现在我想将此日期转换为列表。但它给了我一个错误,因为使用获得的元素date.today()不是“可迭代的”。那么我如何将日期转换为列表呢?
我正在用 PyGame 用 python 开发一个乒乓球游戏,我想学习如何制作一个弹力球。我做了很多研究并观看了 YouTube,但没有取得任何进展。了解如何使球从用某些形状pygame.draw.rect()和许多其他形状绘制的形状上弹起将很有用。但请不要提供制作 Pong 游戏的实际代码。