Nov-12-2021, 05:00 AM
(This post was last modified: Nov-12-2021, 05:01 AM by CompleteNewb.)
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....
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
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() |