Skip to content

Instantly share code, notes, and snippets.

@heatblazer
Created March 30, 2018 11:53
Show Gist options
  • Save heatblazer/80929e46d76f8ddb93d3a5a0ef3c2f48 to your computer and use it in GitHub Desktop.
Save heatblazer/80929e46d76f8ddb93d3a5a0ef3c2f48 to your computer and use it in GitHub Desktop.
import pygame, sys
from pygame.locals import *
from pygame import gfxdraw
# set up the window
windowSurface = pygame.display.set_mode((500, 400), 0, 32)
pygame.display.set_caption('Hello world!')
class Position:
def __init__(self, x, y):
self.x = x
self.y = y
isRunning = True
def testDraw(surface, center_x, center_y, rad, coef=1):
x, y = 0, rad
while (x <= y):
gfxdraw.pixel(surface, center_x + x, center_y + y, (255, 255, 0))
gfxdraw.pixel(surface, center_x - x, center_y + y, (255, 255, 0))
gfxdraw.pixel(surface, center_x + x, center_y - y, (255, 255, 0))
gfxdraw.pixel(surface, center_x - x, center_y - y, (255, 255, 0))
gfxdraw.pixel(surface, center_x + y, center_y + x, (255, 255, 0))
gfxdraw.pixel(surface, center_x - y, center_y + x, (255, 255, 0))
gfxdraw.pixel(surface, center_x + y, center_y - x, (255, 255, 0))
gfxdraw.pixel(surface, center_x - y, center_y - x, (255, 255, 0))
x += 1
if ( abs(x * x + y*y -rad*rad) > abs(x*x + (y-coef) * (y-coef) - rad* rad) ):
y -= 1
while isRunning:
for event in pygame.event.get():
keys = pygame.key.get_pressed()
if event.type == pygame.QUIT:
isRunning = False
elif event.type == pygame.KEYDOWN and keys[K_a]:
testDraw(windowSurface, 200, 200, 100)
print("Pressed a key")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment