Can it let us make entire games by the way?I know that some versions of Logo can, but I think Logo's mostly meant for pretty graphics.
@Darl, Michael
Why not give me the logo code, I'll try it on my calculator :D
from turtle import *
from math import *
def main():
# Setting up a screen 1000 by 1000 pixels
setup(1000, 1000)
hideturtle()
penup()
# This code is designed so that you simply call the functions
# you want to use down below to draw the appropriate figure.
setheading(270)
drawStellarFigure(5, 5, write_total=False)
return
def drawTriNum(side_length, tilt=60, distance=10, dot_size=5, write_total=True):
"""Draws a triangular number (1, 3, 6, 10, etc...)
side_length = the length of a single side.
1 -> Triangle with area of 1
2 -> Triangle with area of 3
3 -> Triangle with area of 6
tilt = The way the triangle is angled.
distance = The distance (in pixels) between each dot
dot_size = The size of each dot (in pixels)
write_total = Disregard this, don't bother translating.
"""
start_position = position()
start_heading = heading()
penup()
tracer(False)
total_dots = 0
for i in range(side_length):
setheading(tilt)
for j in range(i):
forward(distance)
setheading(0)
for k in range(side_length - i):
dot(dot_size, "black")
total_dots += 1
forward(distance)
goto(start_position)
# Don't bother translating anything from here to the Return.
if write_total:
goto(start_position)
setheading(0)
forward((side_length - 1) * distance / 2 + 1)
setheading(270)
forward(30)
write(str(total_dots), move=False, align="center",
font=("Times New Roman", 12, "normal"))
goto(start_position)
setheading(start_heading)
tracer(True)
return total_dots
def drawStellarFigure(vertex_num, shell_num, warp=1, distance=10, dot_size=5, write_total=True):
"""Draws a stellar figure (like a star).
vertex_num = the number of vertexes
shell_num = how many layers there are
warp = The higher the warp, the more angular the figure.
distance = Sort of like the distance between dots
dot_size = The size of each dot (in pixels)
"""
shell_num -= 1
start_position = position()
start_heading = heading()
penup()
tracer(False)
dot(dot_size, "black")
total_dots = 1
shell = []
for i in range(shell_num):
for j in range(vertex_num):
for k in range(2):
if k:
forward(distance * (i + 1) * warp)
else:
forward(distance * (i + 1))
dot(dot_size, "black")
temp1 = radians(180/vertex_num)
temp2 = acos(sin(temp1/warp))
right(90 - degrees(temp2) + 180/vertex_num)
total_dots += 1
shell.append(position())
goto(start_position)
setheading(start_heading - 360/vertex_num*(j+1))
goto(shell[-1])
pendown()
for pos in shell:
goto(pos)
penup()
goto(start_position)
setheading(start_heading)
shell = []
# Don't translate this 'if' statement
if write_total:
forward(distance * (shell_num + 3))
setheading(0)
forward(1)
write(str(total_dots), move=False, align="center", font=("Times New Roman", 12, "normal"))
goto(start_position)
setheading(start_heading)
tracer(True)
return total_dots
if __name__ == "__main__":
main()
mainloop() # This runs the actual program
Can it let us make entire games by the way?
@Darl, MichaelSure, why not.
Why not give me the logo code, I'll try it on my calculator :D