Nov-12-2021, 05:00 AM
I'm exploring the pixelarray in pygame. I started by drawing a white circle with a pixelarray and then i thought it might be fun to animate it and make it gradually appear and disappear so i thought that those lines of codes would work but....
import pygame, math, sys, time from pygame.locals import * white = (255, 255, 255) black = (0,0,0) pygame.init() DISPLAYSURF = pygame.display.set_mode((1200,900)) FPS = 30 fpsclock = pygame.time.Clock() #degree ang = 0 hyp = 100 x = 0 y = 0 conti = True while conti == True: for f in range(1, 100): for d in range(0, 360): pixObj = pygame.PixelArray(DISPLAYSURF) x = 100*math.cos(math.radians(d)) + 600 y = 100*math.sin(math.radians(d)) + 450 x = int(x) y = int(y) pixObj[x][y] = white del pixObj for d in range(0, 360): pixObj = pygame.PixelArray(DISPLAYSURF) x = 100*math.cos(math.radians(d)) + 600 y = 100*math.sin(math.radians(d)) + 450 x = int(x) y = int(y) pixObj[x][y] = black del pixObj conti = False while True: for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() pygame.display.update()Keep in mind that I am new at programming and I know they are better ways to do it, but I want to do it with pixelarrays in pygame to understand their possibilities. So if you can help me understand it would be really appreciated