test practice (1).zip

YELLOW = (255,255,0)

PURPLE = (255,0,255)


# EZ TEST A
from pygame import *

screen = display.set_mode((800,600))

GREEN = (0,255,0)
RED = (255,0,0)
BLUE = (0,0,255)

running = True
while running:
    for e in event.get():
        print(e)
        if e.type == QUIT:
            running = False
    
    mx,my = mouse.get_pos()
    mb = mouse.get_pressed()

    if mb[0]:
        draw.line(screen,GREEN,(mx, my+40),(mx+40,my),1)
        draw.line(screen,GREEN,(mx-40, my),(mx,my-40),1)
        draw.line(screen,GREEN,(mx-40, my),(mx,my+40),1)
        draw.line(screen,GREEN,(mx+40, my),(mx,my-40),1)
        
    elif mb[2]:
        screen.fill(0,0,0)

    display.flip()
quit()

image.png

# A - HARD TEST

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)
GRAY = (111,255,111)

running = True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mx,my= mouse.get_pos()
    mb = mouse.get_pressed()

    screen.fill(GRAY)

    for x in range (10,800,20):
        for y in range (0, 600, 20):
            size = dist((x,y),(mx,my)) /40  
           draw.circle(screen,GREEN,(x,y),size)
            
       
    display.flip()
quit()

# second attempt

from pygame import *
from math import *

screen = display.set_mode((800,600))

GREY = (111,111,111)
GREEN = (111,255,111)

running = True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mx,my= mouse.get_pos()
    mb = mouse.get_pressed()

    screen.fill(GREEN)
    d = hypot(400-mx, 300-my)/8

    #for x in range (0,801,40):
    #for y in range (0, 601,40):
    circle = 3.14 * 400**2
    for x in range(0, int(circle), 40):
        for y in range(0,int(circle), 40):
            draw.circle(screen, GREY,(x,y),d) 
       
    display.flip()
quit()

image.png

# EZ test B

from pygame import *

screen = display.set_mode((800,600))

GREEN = (0,255,0)
RED = (255,0,0)
BLUE = (0,0,255)

running = True
while running:
    for e in event.get():
        print(e)
        if e.type == QUIT:
            running = False
    
    mx,my = mouse.get_pos()
    mb = mouse.get_pressed()

    if mb[0]:           #right
        if mx > 400:
            draw.circle(screen,RED,(mx-300,my),10)
        if mx < 400:    #left
            draw.circle(screen,RED,(mx+300,my),10)
        
    elif mb[2]:
        screen.fill((0,0,0))

    display.flip()
quit()
# HARD test B

from pygame import *

screen = display.set_mode((800,600))

r = 0
g = 0
b = 0

screen.fill((222,222,222))

running = True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mx, my = mouse.get_pos()
    mb = mouse.get_pressed()

    if mb[0]:
        if r < 255:
            r += 15
        else:
            r = 255

        draw.circle(screen, (r, g, b), (mx, my), 15)

    elif mb[1]:
        if g < 255:
            g += 15
        else:
            g = 255
        draw.circle(screen, (r, g, b), (mx, my), 15)
        
    elif mb[2]:
        if b < 255:
            b += 15
        else:
            b = 255
        draw.circle(screen, (r, g, b), (mx, my), 15)

    display.flip()

quit()

image.png

# HARD test B

from pygame import *

screen = display.set_mode((800,600))

r = 0
g = 0
b = 0

screen.fill((222,222,222))

running = True
while running:
    for e in event.get():
        if e.type == QUIT:
            running = False

    mx, my = mouse.get_pos()
    mb = mouse.get_pressed()

    if mb[0]:
        if r < 255:
            r += 1
            draw.circle(screen, (r, g, b), (mx, my),20)
    else:
        if r > 0:
            r -= 1
        
    if mb[1]:
        if g < 255:
            g += 1
            draw.circle(screen, (r, g, b), (mx, my), 20)
    else:
        if g > 0:
            g -= 1

        
    if mb[2]:
        if b < 255:
            b += 1
            draw.circle(screen, (r, g, b), (mx, my), 20)

        else:
            if b > 0:
                b -= 1

    draw.rect(screen, (r, 0, 0), (0, 0, 50,50))
    draw.rect(screen, (0, g, 0), (60, 0, 50,50))
    draw.rect(screen, (0, 0, b), (120, 0, 50,50))
    draw.rect(screen, (r, g, b), (180, 0, 50,50))

    display.flip()
    time.wait(5)

quit()

RED LINE THINGY

image.png

Screenshot 2024-10-16 123923.png

from pygame import *
from random import *

screen = display.set_mode((800,600))

pts = []
rad = 20
direct = 1
running = True
while running:
for evt in event.get():
if evt.type == QUIT:
            running = False

    mx,my = mouse.get_pos()
    mb = mouse.get_pressed()

    rad += direct
if rad == 10 or rad == 40:
        direct *= -1

if mb[0]:
        pts.append((mx,my))

    screen.fill(0xffffff)
for p in pts:
        draw.circle(screen, 0x0000ff, p, rad, 1)
    display.flip()
    time.wait(20)
quit()

image.png

from pygame import *
from random import *
from math import *
screen = display.set_mode((800,600))

RED = (255, 0, 0)    # ALL CAPS is used for constants
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
screen.fill((255,255,255))
running = True
while running:
    for evt in event.get():
        if evt.type == QUIT:
            running = False

    mx, my = mouse.get_pos()
    mb = mouse.get_pressed()
    # ----------------------------------
    dx=randint(-600,600)
    dy=randint(-400,400)
    col = (randint(0,255),randint(0,255),randint(0,255))
    if mb[0]:
       draw.line(screen,col,(mx,my),(mx+dx,my+dy),2)
    if mb[2]:
        screen.fill((255,255,255))
    
    # ----------------------------------
    display.flip()

quit()

image.png

from pygame import *
from random import *
from math import *
screen = display.set_mode((800,600))
colmb = [(126,111,246),(166,98,178),(234,134,50),(51,19,115),(61,45,137)]
colours = []
for i in range(20):
    c = (randint(0,255),randint(0,255),randint(0,255))
    colours.append(c)
running = True
while running:
    for evt in event.get():
        if evt.type == QUIT:
            running = False

    mx, my = mouse.get_pos()
    mb = mouse.get_pressed()
    # ----------------------------------
    dx=(randint(-40,40))
    dy=(randint(-40,40))
    i=0
    if mb[0]:
        draw.line(screen,colmb[i],(mx,my),(mx+dx,my+dy))
        i+=1
    if mb[2]:
        screen.fill((0,0,0))
    pos=0
    for x in range(0,800,40):
        draw.rect(screen,colours[pos],(x,280,40,40))
        pos+1
    dx=(randint(-40,40))
    dy=(randint(-40,40))
    
    
    # ----------------------------------
    display.flip()

quit()