我试图制作一个代码,每次点击鼠标,都会绘制一个圆圈并将其放到底部。我对此有疑问,因为我想不出一个新粒子在下落时如何绘制。我不知道如何编码,因此我至少需要知道如何做到这一点。这就是我所要做的,但我很困惑下一步该做什么。
import pygame, time
class Material(object):
def __init__(self, name, radius, gravity):
self.name = name
self.radius = radius
self.gravity = gravity
sand = Material("Sand", 5, 2)
def game():
pygame.init()
win = pygame.display.set_mode((1000, 650))
pygame.display.set_caption("***Sandbox***")
event = pygame.event.wait()
velocity = 0
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
if pygame.mouse.get_pressed()[0]:
x, y = event.pos
print(event.pos)
pygame.draw.circle(win, (194, 178, 128), (x, y), sand.radius)
pygame.display.update()
while y >= 0 and y < 645:
win.fill((0,0,0,))
y += velocity
velocity += sand.gravity
print(x, y)
if y > 645:
y = 645
velocity = 0
pygame.draw.circle(win, (194, 178, 128), (x, y), sand.radius)
pygame.display.update()
game()
白衣非少年
相关分类