Winter Themed Artwork

My winter-themed artwork is interactive. It gives you a choice to pick from a Christmas themed artwork (spoiler: there is no Christmas artwork) or a New Year themed one (picture shown above). After that, it gives you a choice to draw it or make the computer draw it.

This is the first part of my code. It starts by just importing the random library and the turtle library. After that it asks you which holiday you want. If you choose Christmas it says, “Aww. you already want Christmas,” and then it asks you if you want to draw it or should the computer draw it. If you pick you can draw it, it says Too bad Christmas is done then it feels “guilty” and asks if you still want a picture. If you say yes, it says fine I’ll give you something better than a tree and draws the picture I first showed you (I’ll get to the code for that later).

This part is what happens if you say, “I will draw it.” The same code is used later again. The whole code for this part is in a loop since I don’t know how many times you want to turn or go forward. First, it has an input and asks if you want to go forward, turn right, or turn left. If you choose forward then it asks how much forward do you want to go. If you choose right then it asks how much you want to turn the same for left. After it goes through these if-then statements it asks if you are done yet. If you are, it says it’s so good. If you say no it moves forward a little and continues.

The next part of my code is what happens if you choose New Year. So if you picked New Year, it says the countdown and then asks if you want to draw it or should I, like last time. You already know what happens if you choose I’ll draw it so I won’t explain that again.

Here is the code for the fireworks. It appears if you choose that Christmas one and New Year (Fireworks work for both… I think). It first turns the background black and sets the speed of the turtle high so it goes fast. Then in a loop, it chooses a random integer for x and y then it pulls the pen up and moves to the coordinates it chooses. After it puts the pen down and chooses a random color and size (How much forward should the turtle go). Then it has another loop that goes forward, backward, then turns a little (this makes the actual fireworks). It makes five fireworks then stops.

I think the one thing that was hard for me during this project was making the code that allows you to draw. Otherwise, it was really fun. Also, I was in India when the class did this and I did not attend class so I had to make the code for this really fast. But I am really happy with what it is right now.

Turtle Maze

I did not get so far for this assignment because I was stuck after the first two lines. I probably could do it by bouncing of the walls of the maze but I wanted to challenge myself a little more.

The turtle maze challenge is where you have to get the turtle to go through the maze without crossing any lines. The thing is that the maze always changes. I got through the first two lines and had trouble with the rest.

How far I got

As you can see from the picture above, I got as far as the first two lines and then I could turn but that was it. I had a lot of trouble coming up with the code for the next parts.

This is my code (There are some other parts that are not my code that create the maze in the beginning). My code first starts with the turtle going forward randomr [i] + randomt [i]/2 (this is the first part of the list and it is a part of the code in the beginning, randomr is how far the first line of the maze goes, randomt is 800-randomr/2). It goes this forward because it has to go past randomr and half of the randomt mainly because randomt is repeated twice. The first time randomt is not seen (this forms the opening), the second time finishes of the first line of the maze. Then I make the turtle turn right because no matter what the turtle has to turn right in order for it to go straight into the maze. Next, the turtle goes forward 50 making it enter the maze. Then it has an if-then statement asking if randomr is greater than randomt. If it is then the turtle turns right because after it can go forward to the right to the opening. If it is not it has another if-then statement saying the exact opposite making it turn left. After it has another if-then statement, telling it how much much to go forward. After that is another if-then statement that determines which way to turn like the first two if-then statements. Then finally is a command that makes the turtle go forward. Next is another if-then statement that determines which way to go. That was all of the code I got to do and figured out.

I think what was really hard for me was figuring how much to go in front based on the turtle’s coordinates. Otherwise, it was a really fun project for me.

Turtle Race

My turtle race has two different races within it. The top one in the picture above is a race between a dog (square) and a cat (triangle). The bottom one is based on the story, “The Turtle and The Hare.” The race also features text in the box below.

The code first starts by setting up the characters and the board. As always the first two lines of code import different libraries (turtle and the random library). Next, I named different turtles so I could control the characters. Then, I gave different speeds to them all. The dog got a speed of 5, the cat got a speed of 2, the hare got a speed of 10, while the turtle got a speed of 1. Unfair right? After, I made the person set up the race board at a speed of 100. I changed the shape and the colors of the characters. In my code (but not in the picture of the code above) I also have code to position the characters) and that’s basically the first part of my code.

The first race

The second part of my race is the cat and the dog race. It starts with it printing, “Race one at ready,” then it prints 3, 2, 1… go in the text place under the race board. Then, in a repeat loop, I coded it to make the dog go forward a random integer from 3 to 5 then the cat goes a random integer from 2 to 5. The loop breaks if either the dog or cat passes the finish line. If one of them does, it says something like (*insert character who wins) wins RACE #1.

The third part of my code is the Turtle and the Hare race. This part follows the plot of the actual story. Like the other one, it starts with the text Race Two at Ready then it says 3,2,1, Go. Next, it starts with the regular loop where the turtle goes forward 2 while the hare goes forward a random number between 2 and 5. But this time, when the hare reaches x coordinate, 0, the loop breaks and it prints the text: Hare: ZZZ. Then the turtle moves forward 2 until it reaches the finish line and the loop breaks. Then it prints: “Turtle wins RACE 2”, “Referee: Ha, I guess the turtle was right… slow and steady does win the race”, “3 hours later…” After that text, the hare starts going forward until the finish line and figures out that he lost and yells no.

Race #2

I had a lot of fun doing this, I got to experience doing it the regular way and recreating a story using coding. The only thing that was hard was figuring out how to break the loops when the hare reaches a certain point and when the race ends. The text part was just extra but I am glad I added that, it mad the races so much more real.

Turtle Art ~ Rose Inspiration

In this project, we were supposed to pick a code and take inspiration from it. I used the Palm code from Book 1. If you scroll down you can see the flower I made using turtle art. I wanted to make something using nature because the code I took inspiration from was from nature so I made a rose. You can also see the whole code here.

Rose

Before I started the actual code, I wanted to understand the Palm code. So, I experimented with it and made a globe.

Globe

After I understood the code, I wanted to in cooperate it in the actual code that I would make. So instead of making it circles that were big I used the same code and made it bumpy.

Whole Code

This is the start block. First, I put a fill block to turn the background black. After I used action block “flower” and repeated that 14 times to give it that rose type look.

This is the flower action block, it just makes sets the color, shade, and pen size for the rose. So, basically it just sets up the materials for the actual rose. Like I said, it first sets the color to an aqua color, then it sets the shade, after it sets the pen size. Then in a repeat block it has the “swirl” action block and then subtracts 0.3 and the current pen size.

The “swirl” action bloc makes the actual petals for the rose. It starts by telling the computer what each box is. Box three has a value of 1, box one has a value of 10, and box two has a value of 200. Next, it turns right box 3 (1 degree) Then, it tells the turtle where to start making the actual drawing and that starts at the middle which is (0,0). After, it has a repeat block for 40. This part of the code is the petals and leaves for the rose. It starts with an arc block, the angle is box 2 (200 degrees) and the radius is box 1 (10). After, it turns left 100 degrees. Then, it adds a value of 10 to box 1 and subtracts a value of 10 out of box 2. Next, it turns right 10 degrees and adds 1.8 to the shade. Then, it has an if then block with if the shade is greater then 60 then set the shade back to 50. Then it adds 0.08 to the current color. After it has another if then block with if the color is greater then 75 then set the color back to 55.

I am satisfied with what I’ve done. I really like it. One of the main things I had trouble with was making the correct colors and shades for the rose. It may seem easy to do that but I also had to add more shade and color to change the colors. Then I also had to put an if then statement to make sure the flower didn’t get to vibrant and too colorful. One thing I learned from this assignment was how to use boxes. I was kind of confused on which one was the greater than and which one was the less than block but, I got the hang of it in the end. But, overall I really like what I’ve done and think its a really good piece of artwork.

Turtle Art – Name Art

In this project, I am supposed to use my name to make some type of artwork. I originally was just going to make a background with my name tilted a little bit. But, that was really basic so I took the game where’s waldo and was going to make you find my name in a huge picture. But that was really easy to make so I switched it and I am going to make you find a stick human in my name repeated a bunch of times. The best part of this code is you can use it a bunch of times and the human and the background will always go into another area.

Try to find sticky the stick human!!!

In the code for the picture above I used action blocks and arch blocks. I used arch blocks for the human, the D, and the S. First I made each letter in my name and put them in separate action blocks. Then I made my name in an action block. In another action block, I took the X Y block and put two randomize blocks in it. Then put my name under it so it makes the turtle draw my name in random places. After I made the code for the human which was also in an action block. Then I made the word FIND which is also in an action block. Then in a start block I put the find… action block, random human action block, then the random name block. This way the names cover Sticky the Stick human it’s hard for you. Here’s the code:

This code wasn’t too hard since I used the X Y block and set heading block. It was a lot of code to do though. I took me some time to figure out but in the end I really liked it. Have you found where sticky the stick human is yet? Well if you haven’t keep on trying, if you give up (that sucks) but here’s the answer:

He’s kind of hard to find

Turtle Art – Cat

This post is about my first turtle art project. In this project, I created a cat and made it a colorful background, by changing the color each time.

Here’s a picture:

First, I made the ear codes for the cat. I used an action block for both of the ears. I made the right ear. It goes forward 100, right 130, then forward 50. Then I made the left ear. It goes forward 50, right 130, then forward 100. Second, I made a code of the basic cat shape. I used an action block for this and called it Basic Face. I used the set gray block to make the cat gray. Then I used the arc block and put the angle on 360 and the radius on 88. Then I used the action block I made for the right ear, called ear. After it went left 40, forward 95, then left 40. Then I used the left ear action block, Ear1. After it went back 25, right 90, then forward 40. And I put the Basic Face shape into a fill block so the cat is colored. After, I made the Eyes which is also in an action block that’s in a fill block. First, I set the color to 60. Then I set the arc block. Which the angle is 360 and the radius is 10. Then I put the pen up, forward 75, pen down, angle 360 and radius 10 in the arch block. Then I made the mouth which is also an action block. So first I did pen up, back 32.5, left 90, forward 33, pen down. Then I put a fill block and inside the fill block I put a set color block at 0, right 90, forward 10, left 115, forward 20, left 115, forward 20, left 115, forward 10. Then after the fill block, I put left 105, forward 40, right 40, arch block (angle 90, radius 10), pen up, left 40, back 20, pen down, right 205, arch block (angle -90, radius -10), pen up, left 100, forward 500, left 90, forward 400, pen down. Then I did the background which is also in an action block. The code is in a repeat block that repeats 35 times. It goes right 180, forward 100, right 170, and forward 100. Then we do the whole background which is also in an action block. It’s in a repeat block that repeats 4 times. It starts with pen up, left 150, pen down, set color 10, background action block, pen up, forward 200, pen down, set color 60, background action block, pen up forward 250, pen down, set color 0, background action block. Then inside a start block, I put a Basic Face block, an Eyes block, Mouth Block, then a Background Full block.

Some things that were hard for me to do while I was making the code was finding the correct angle for each part of the cat. It was a really fun project although it took me a few hours to do.

About Me

My name is Sanvi, usually, I will post about CSAI but this post is for you to understand me. I like the color aqua and I like dogs. I have a dog named Spyro and he’s an Australian Labradoodle (He turns two in December). I also have a little sister named Sirah.

Picture of Spyro
Sirah’s in the corner

I like sports, math, choir, and art. I recently started Jui Jitsu which is a Brazilian martial art. It’s like wrestling and the best part of it, is you get to flip people over (Last time, I flipped my sister over multiple times). Here’s a video of what Jui Jitsu is.