This time as well, I made it with a lot of questions from my juniors, so I will write it with explanations.
sketch.py
y = 600
count = 0
def setup():
size(800,600)
def stack_plates(n):
global y,count
if count <= n: #Ends when count exceeds the specified n
ellipse(width/2,y,100,10) #Draw a plate
y -= 5 #Shift the coordinates to draw the plate
count += 1 #Increase the value after each process!
def draw():
stack_plates(10)
sketch.py
def setup():
size(800,600)
x = [200,300,550]
y = [100,400,300]
d = [50,180,100]
for i in range( len(x) ): #len()Move with the length in x
ellipse(x[i],y[i],d[i],d[i])
sketch.py
def setup():
size(800,600)
pic = int(random(10)) #The number of cars to put!
for i in range(pic):
x = random(800) #Car x coordinate
y = random(600) #Car y coordinate
sketch_car(x,y) #X in function,Give the coordinates of y!
def sketch_car(x,y): #A function to draw a car!
fill(128,249,251)
rect(x,y,50,25)
fill(244,201,70)
rect(x-25,y+25,100,25)
fill(60,63,55)
ellipse(x,y+50,25,25)
ellipse(x+50,y+50,25,25)
There are less explanations than last time, but I intended to write it so that it can be read by looking at the program while looking at the contents of consciousness! If you can't do it without knowing it, I think it's worth seeing!
Recommended Posts