你好,我是一名相当新的程序员,我正在尝试让球从 45 度三角形反弹。这是我的代码:
该程序使球在撞击窗户两侧时弹起,但我不知道如何使其从三角形弹起。
import pygame # importing the pygame
import sys # importing the system libraries
import time # importing timer
import random
from pygame.locals import * # importing the locals functions from the pygame library set
pygame.init() # the function from pygame that initializes all relevant variable
# setting length and width
width = 500
length = 300
# colour variables
WHITE = (255,255,255)
BLUE = (0,0,255)
# importing ball image
ball = pygame.image.load('ball.png')
ballRect = ball.get_rect()
ballRect.left …Run Code Online (Sandbox Code Playgroud)