For this project, we had to design something using OnShape, so I decided to create a simple water bottle. For this project, I did not use AI to help me.
This water bottle is a simple hollow cylinder with a more complex lid. The lid is designed to fit on top of the cylinder in a way that prevents it from falling off to the side as well as preventing spillage while attached.
One of the first things I did for this assignment was to sketch out the radius of the cylinder, as well as the inner circle that is going to be hollow. Above that, where the end of the cylinder would be, I added a small ring for the lid to fit around.The next step for the cylinder was to extrude it. First, I extruded the ring that formed the cylinder and adjusted the depth of the extrusion. Then, I added a base by extruding the inner hollow circle of the cylinder about 1/15th the depth of the original cylinder. Finally, I extruded the small ring at the top by 1/10th of the original cylinder’s length.For the lid, I followed the same steps, creating a sketch, extruding it, and creating more sketches and extrusions as I went along to create a more complex shape.Once both parts were complete, I opened an assembly and placed both parts together. I used a mate connector to see if they fit, and then set up an animated mate that shows how the lid goes on.Once this was done, I created a drawing in OnShape and inserted various angles and views of the two parts into it. I used the measurement tool to show the exact measurements required to recreate the parts.
In this drawing, I added a BOM, or Bill Of Materials. For this, I decided to make both parts out of stainless steel, due to its durability and lack of microplastics.
For our first project, we had to build something in Python using our coding skills. For my project, I created a text-based adventure game. That means that it is essentially a video game that is played by reading the sentences on the screen, and inputting some text to decide your actions.
The code is split into two main parts, which work together to create the game. For a simple explanation of how the code operates, view this flowchart: The first section is made up of a lot of text, which is used to describe the locations to the computer, including things like what it should say when the player arrives there, the directions the player is able to travel from where they are and where they lead, and any items the player can pick up in that location. This information is used in the next section, which is the main loop.
locations = {
"forest": {
"description": "You are in a large, expansive forest. As you walk, you can hear the sounds of animals that live here.",
"options": {
"north": "lake",
"west": "village"
}
},
"village": {
"description": {
"default": "You arrive at a quiet village, populated by the locals of this land. Leaning against a nearby fence is a cluster of unlit torches.",
"torch": "At the village, a person approaches you. 'Hello there. I lost my ring over by the lake. If you find it, could you bring it back to me? I'll reward you greatly.'",
"ring": "At the village, a person approaches you. 'Ah, I see you have my ring. If you return it to me, I will give you this treasure map.'",
"quest_ring": "Returning to the village, you walk around for a bit. You see various people going about their jobs, and chatting with other locals."
},
"options": {
"east": "forest",
"north": "mountain"
},
"item": "torch"
},
"lake": {
"description": {
"default": "You come upon a serene lake. You notice a ring sitting by the shore.",
"ring": "You come upon a serene lake."
},
"options": {
"south": "forest",
"west": "mountain",
"east": "river"
},
"item": "ring"
},
"mountain": {
"description": "The ground begins to slope upward, and as the trees start to open up, you see that you are on located partway up a large mountain.",
"options": {
"south": "village",
"east": "lake",
"up": "mountain_peak"
}
},
"mountain_peak": {
"description": "You continue to climb up the mountain, and the ground begins to flatten out beneath your feet. Looking out towards the horizon, you see the wide expanse of land spread out before you.",
"options": {
"down": "mountain"
}
},
"river": {
"description": "As you follow the river, you see a school of fish struggling to swim through a small section of rapids.",
"options": {
"west": "lake",
"east": "cave_mouth"
}
},
"cave_mouth": {
"description": "Still following the river, you come across large boulders forming a cave mouth on the south side of the river.",
"options": {
"west": "river",
"in": "cave"
}
},
"cave": {
"description": {
"default": "Inside the cave, it is almost impossible to see. You stumble forward in darkness.",
"torch": "You light your torch and enter the cave. Looking around, it is difficult to see, but you can make out the shape of the cave wall by the light of your torch."
},
"options": {
"out": "cave_mouth"
}
}
}
The second section makes up the core loop that runs the actual game. This loop includes printing the description of the location the player is in, listing the directions the player can travel, and asking what the player would like to do. If the location includes it, this section of the code also tells the player if there is an item that is nearby that they can pick up, then ask if they want to grab it.
inventory = []
current_location = "forest"
# Functions for code
def lake_ring():
print(locations["lake"]["description"]["default"])
if "ring" not in inventory:
take_ring = input("Do you want to pick up the ring? (y/n) ").lower()
if take_ring == "y":
inventory.append("ring")
print("you picked up: ring")
def village_ring():
print(locations["village"]["description"]["ring"])
return_item = input("Do you give the ring back? (y/n) ").lower()
if return_item == "y":
inventory.append("treasure_map")
inventory.append("quest_ring")
inventory.remove("ring")
print("You handed over the ring.")
print("You received the treasure map.")
if "torch" not in inventory:
print("Leaning against a nearby fence is a cluster of unlit torches.")
take = input("Do you want to pick up the torch? (y/n) ").lower()
if take == "y":
inventory.append("torch")
print("you picked up:")
print(item)
def ask_direction():
global current_location
print("You can go: ", ", ".join(locations[current_location]["options"].keys()))
choice = input("Which direction do you want to go?: ").lower()
if choice in locations[current_location]["options"]:
current_location = locations[current_location]["options"][choice]
print()
else:
print("You can't go that way. That direction either doesn't exist, or is still in development.")
while True:
if "item" in locations[current_location]:
item = locations[current_location]["item"]
# dealing with locations having multiple descriptions
if current_location == "cave":
if "torch" in inventory:
print(locations["cave"]["description"]["torch"])
else:
print(locations["cave"]["description"]["default"])
else:
if current_location == "village":
if "ring" in inventory:
village_ring()
if "torch" in inventory:
if "quest_ring" in inventory:
print(locations["village"]["description"]["quest_ring"])
else:
print(locations["village"]["description"]["torch"])
else:
print(locations["village"]["description"]["default"])
if "torch" not in inventory:
print("Leaning against a nearby fence is a cluster of unlit torches.")
take_torch = input("Do you want to pick up the torch? (y/n) ").lower()
if take_torch == "y":
inventory.append("torch")
print("you picked up: torch")
else:
if current_location == "lake":
if "ring" in inventory or "quest_ring" in inventory:
print(locations["lake"]["description"]["ring"])
else:
lake_ring()
else:
print(locations[current_location]["description"])
ask_direction()
If you want to try it for yourself, the complete code is found here. I used CodeHS to run this code, but other programs will work, too.
locations = {
"forest": {
"description": "You are in a large, expansive forest. As you walk, you can hear the sounds of animals that live here.",
"options": {
"north": "lake",
"west": "village"
}
},
"village": {
"description": {
"default": "You arrive at a quiet village, populated by the locals of this land. Leaning against a nearby fence is a cluster of unlit torches.",
"torch": "At the village, a person approaches you. 'Hello there. I lost my ring over by the lake. If you find it, could you bring it back to me? I'll reward you greatly.'",
"ring": "At the village, a person approaches you. 'Ah, I see you have my ring. If you return it to me, I will give you this treasure map.'",
"quest_ring": "Returning to the village, you walk around for a bit. You see various people going about their jobs, and chatting with other locals."
},
"options": {
"east": "forest",
"north": "mountain"
},
"item": "torch"
},
"lake": {
"description": {
"default": "You come upon a serene lake. You notice a ring sitting by the shore.",
"ring": "You come upon a serene lake."
},
"options": {
"south": "forest",
"west": "mountain",
"east": "river"
},
"item": "ring"
},
"mountain": {
"description": "The ground begins to slope upward, and as the trees start to open up, you see that you are on located partway up a large mountain.",
"options": {
"south": "village",
"east": "lake",
"up": "mountain_peak"
}
},
"mountain_peak": {
"description": "You continue to climb up the mountain, and the ground begins to flatten out beneath your feet. Looking out towards the horizon, you see the wide expanse of land spread out before you.",
"options": {
"down": "mountain"
}
},
"river": {
"description": "As you follow the river, you see a school of fish struggling to swim through a small section of rapids.",
"options": {
"west": "lake",
"east": "cave_mouth"
}
},
"cave_mouth": {
"description": "Still following the river, you come across large boulders forming a cave mouth on the south side of the river.",
"options": {
"west": "river",
"in": "cave"
}
},
"cave": {
"description": {
"default": "Inside the cave, it is almost impossible to see. You stumble forward in darkness.",
"torch": "You light your torch and enter the cave. Looking around, it is difficult to see, but you can make out the shape of the cave wall by the light of your torch."
},
"options": {
"out": "cave_mouth"
}
}
}
print("Welcome to my text-based adventure game! In this game, you are given a description of where you are and what you can do. You are also given a list of locations you can go to from your current location, given to you as directions. When given directions that you can travel in, you have to type in your chosen direction, only including the name of that direction as given to you. Have fun!")
print()
inventory = []
current_location = "forest"
# Functions for code
def lake_ring():
print(locations["lake"]["description"]["default"])
if "ring" not in inventory:
take_ring = input("Do you want to pick up the ring? (y/n) ").lower()
if take_ring == "y":
inventory.append("ring")
print("you picked up: ring")
def village_ring():
print(locations["village"]["description"]["ring"])
return_item = input("Do you give the ring back? (y/n) ").lower()
if return_item == "y":
inventory.append("treasure_map")
inventory.append("quest_ring")
inventory.remove("ring")
print("You handed over the ring.")
print("You received the treasure map.")
if "torch" not in inventory:
print("Leaning against a nearby fence is a cluster of unlit torches.")
take = input("Do you want to pick up the torch? (y/n) ").lower()
if take == "y":
inventory.append("torch")
print("you picked up:")
print(item)
def ask_direction():
global current_location
print("You can go: ", ", ".join(locations[current_location]["options"].keys()))
choice = input("Which direction do you want to go?: ").lower()
if choice in locations[current_location]["options"]:
current_location = locations[current_location]["options"][choice]
print()
else:
print("You can't go that way. That direction either doesn't exist, or is still in development.")
while True:
if "item" in locations[current_location]:
item = locations[current_location]["item"]
# dealing with locations having multiple descriptions
if current_location == "cave":
if "torch" in inventory:
print(locations["cave"]["description"]["torch"])
else:
print(locations["cave"]["description"]["default"])
else:
if current_location == "village":
if "ring" in inventory:
village_ring()
if "torch" in inventory:
if "quest_ring" in inventory:
print(locations["village"]["description"]["quest_ring"])
else:
print(locations["village"]["description"]["torch"])
else:
print(locations["village"]["description"]["default"])
if "torch" not in inventory:
print("Leaning against a nearby fence is a cluster of unlit torches.")
take_torch = input("Do you want to pick up the torch? (y/n) ").lower()
if take_torch == "y":
inventory.append("torch")
print("you picked up: torch")
else:
if current_location == "lake":
if "ring" in inventory or "quest_ring" in inventory:
print(locations["lake"]["description"]["ring"])
else:
lake_ring()
else:
print(locations[current_location]["description"])
ask_direction()
AI was utilized in the creation of this project. To see how I incorporated AI into creating this project, click this link to see the full transcript.