from pygame import *
screen = display.set_mode((800,600)) #(800,600) is a tuple,
#a tuple is a list that cant change
running = True
while running:
# event loop
for e in event.get():
print(e)
if e.type == QUIT:
running = False
#-----------------------------------------
# colour (x1,y1) (x2,y2) thick
draw.line(screen, (255,255,0),(100,0), (400,300),30)
# top-left x y w h
draw.rect(screen, (0, 255, 0), (400,20, 100, 400), 10)
draw.rect(screen, (0, 255, 0), (600,20, 100, 200))
# x y radius
draw.circle(screen,(0,255,255), (100,400),50,2)
#
draw.ellipse(screen,(111,111,111), (300, 20, 100,50))
draw.ellipse(screen,(200,200,200), (300, 120, 100,50))
#----------------------------------------
display.flip()
quit()
from pygame import *
screen = display.set_mode((800,600)) #(800,600) is a tuple,
#a tuple is a list that cant change
running = True
while running:
# event loop
for e in event.get():
print(e)
if e.type == QUIT:
running = False
#-----------------------------------------
mx,my= mouse.get_pos()
mb = mouse.get_pressed() # (True, False, False)
if mb[0]:
draw.circle(screen,(0,255,0), (mx,my), 10)
if mb[2]:
draw.circle(screen,(0,0,0), (mx,my), 20)
#----------------------------------------
display.flip()
quit()
from pygame import *
screen = display.set_mode((800,600)) #(800,600) is a tuple,
#a tuple is a list that cant change
running = True
while running:
# event loop
for e in event.get():
print(e)
if e.type == QUIT:
running = False
#-----------------------------------------
screen.fill((55,111,222))
for x in range(0,800,10):
draw.line(screen,(0,255,0),(x,0),(x,600))
for y in range(0,600,10):
draw.line(screen,(0,255,0),(0,y),(800,y))
#----------------------------------------
display.flip()
#time.wait(50)
quit()
from pygame import *
from random import *
screen = display.set_mode((800,600)) #(800,600) is a tuple,
# a tuple is a list that cant change
running = True
while running:
# event loop
for e in event.get():
print(e)
if e.type == QUIT:
running = False
#-----------------------------------------
x = randint(0,800)
y= randint(0,600)
col = (randint(0,255),randint(0,255),randint(0,255))
draw.line(screen, col, (x,y), (x2,y2),2)
#----------------------------------------
display.flip()
#time.wait(50)
quit()
# graphics practice 13
from pygame import *
from math import *
screen = display.set_mode((800,600))
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0, 255, 0)
BLACK = (0,0,0)
WHITE =(255, 255, 255)
dy = 0
direct = -1
running = True
while running:
for e in event.get():
if e.type == MOUSEBUTTONDOWN:
back = screen.copy()
if e.type == QUIT:
running = False
mx,my= mouse.get_pos()
mb = mouse.get_pressed()
screen.fill(0)
dy += direct #will happen in other questions
if abs(dy) == 20:
direct *= -1
for x in range (0, 801, 40):
for y in range (40, 561, 20):
draw.line(screen, GREEN, (x,y), (x+20 , y + dy))
draw.line(screen, GREEN, (x+40,y), (x+20 , y + dy))
display.flip()
time.wait(20)
quit()