1
我想在pygame畫一個拋物線。我製作了一個pixelarray物體並通過它循環來確定像素是否在拋物線上。我似乎得到了一個有點差距的圖像。我如何使它成爲一條連續的線?用Pygame畫一個拋物線
import pygame
import sys
from pygame.locals import *
import math
WIDTH = 640
HEIGHT = 480
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT), 0, 32)
pxarray = pygame.PixelArray(screen)
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
screen.fill((0,0,0))
for y, py in enumerate(pxarray):
for x, px in enumerate(py):
if int(x) == (int(y)*int(y)) - 30*int(y) + 450:
pxarray[y][x] = 0xFFFFFF
pygame.display.update()