-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpygameStrap.py
58 lines (47 loc) · 1.32 KB
/
pygameStrap.py
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
49
50
51
52
53
54
55
56
57
58
#This is a pyOpenGL+pygame code template
#importing stuff
#pygame imports
import pygame
from pygame.locals import *
#opengl imports
from OpenGL.GL import *
from OpenGL.GLU import *
#other imports
import math
#defing functions for basic shapes
def drawPixel(x,y):
glBegin(GL_POINTS)
glVertex2f(x,y)
glEnd()
def drawLine(a,b,c,d):
glBegin(GL_LINES)
glVertex2f(a,b)
glVertex2f(c,d)
glEnd()
def drawCircle(x,y,r=50):
toRad = (math.pi/180)
for i in range (0,360):
drawPixel(x+(r*math.cos(toRad*i)),y+(r*math.sin(toRad*i)))
#main drawing logic
def draw():
#coding logic here
drawCircle(0,0)
#main function
def main():
#boiler-plate setup code
pygame.init()
display = (800,600) #the pygame windows resolution
pygame.display.set_mode(display, DOUBLEBUF|OPENGL)
gluOrtho2D(0,800,600,0) #defining drawing limits
#the main loop
while True:
#event hadling loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) #clear the frame
draw() #calling the function with drawing logic
pygame.display.flip() #bring up the updated screen
#calling main()
main()