I was playing around with Python's turtle module and thought why not make a simple character from a famous game "AMONG US"! And that's how it started. Today I will be talking a bit about the Turtel module and how to make this character with that. Let's get started.
Step1: Install python (Ignore if you have it)To install python go to python.org/downloads and download the latest stable version of python3. It will take around 25MB. After that open the downloaded file and click install. Don't forget to check the button that says 'add path to environment variable'.
Once you did that, check if python was installed successfully. To do that go to Terminal/cmd/Command prompt > type python > hit 'enter'
If no error message came then good, you have it installed successfully on your system.
Step2: Install TurtleTo install that we need to type
pip install turtle
On our command prompt/terminal/cmd.
It will take some seconds or minutes, depending on your net speed.
Step3: Writing the code to draw the characterWe start by importing turtle module. A little basic - Turtle is like a pen, you can control how much further to go forward, backward and which way to turn (left, right) with certain angle (degrees). It can also fill colors, change speed, and make circles or portion of circle, the way you want.
This is the basic code that will show the window with turtle in it -
import turtle
s = turtle.getscreen() # screen name
t = turtle.Turtle() # turtle pen object (name)
t.screen.exitonclick() # shows the screen until we exit
We can make the turtle go some places like this -
t.right(90) # take a 90 degree right turn
t.forward(50) # go 10 pixels forward
And to make a circle or portion of it -
t.circle(40) # circle with radius 40
t.circle(20, 180) # circle with radius 20, and 180 degree
#(not full 360)
So I used these techniques to make the code that draw the among us character. All you need to do is, code a bit, watch what it does, and make necessary edits. That's it.
The full code can be downloaded from here. Or copy from below. Although I recommend downloading.
import turtle
BODY_COLOR = 'skyblue'
BODY_SHADOW = ''
GLASS_COLOR = '#9acedc'
GLASS_SHADOW = ''
s = turtle.getscreen()
t = turtle.Turtle()
# it can move forward backward left right
def body():
""" draws the body """
t.pensize(20)
#t.speed(15)
t.fillcolor(BODY_COLOR)
t.begin_fill()
# right side
t.right(90)
t.forward(50)
t.right(180)
t.circle(40, -180)
t.right(180)
t.forward(200)
# head curve
t.right(180)
t.circle(100, -180)
# left side
t.backward(20)
t.left(15)
t.circle(500, -20)
t.backward(20)
#t.backward(200)
t.circle(40, -180)
#t.right(90)
t.left(7)
t.backward(50)
# hip
t.up()
t.left(90)
t.forward(10)
t.right(90)
t.down()
#t.right(180)
#t.circle(25, -180)
t.right(240)
t.circle(50, -70)
t.end_fill()
def glass():
t.up()
#t.right(180)
t.right(230)
t.forward(100)
t.left(90)
t.forward(20)
t.right(90)
t.down()
t.fillcolor(GLASS_COLOR)
t.begin_fill()
t.right(150)
t.circle(90, -55)
t.right(180)
t.forward(1)
t.right(180)
t.circle(10, -65)
t.right(180)
t.forward(110)
t.right(180)
#t.right(180)
t.circle(50, -190)
t.right(170)
t.forward(80)
t.right(180)
t.circle(45, -30)
t.end_fill()
def backpack():
t.up()
t.right(60)
t.forward(100)
t.right(90)
t.forward(75)
t.fillcolor(BODY_COLOR)
t.begin_fill()
t.down()
t.forward(30)
t.right(255)
t.circle(300, -30)
t.right(260)
t.forward(30)
t.end_fill()
body()
glass()
backpack()
t.screen.exitonclick()
That's it. Now run the code and have fun.
Comments