©2019 by TurtleGaming. Proudly created with Wix.com

|SQUARE_HUNTER|

Code For |SQUARE_HUNTER|

# 1. Create a screen 500 by 500.
# 2. Make the screen green. # 3. Make arrow shaped turtle. # 4. Make arrow shaped turtle spin left. # 5. Let arrow shoot when you press space. # 6. Make a square shaped turtle that relocates after you pop it. # 7. Has reload time. # 8. Finish game. import turtle import random import time Player_turtle = turtle.Turtle() Target_Turtle = turtle.Turtle() bullet = turtle.Turtle() text_turtle = turtle.Turtle() window = turtle.Screen() window.bgcolor('green') window.tracer(0) length = 600 width = 600 bullet.shape('circle') bullet.penup() bullet.in_motion = False bullet_speed = 10 Target_Turtle.penup() Player_turtle.shape('triangle') Player_turtle.shapesize(1, 2) Target_Turtle.shape('square') Player_turtle.color('black') Player_turtle.penup() spin_speed = 1000 window = turtle.Screen() window.bgcolor('green') bullet.hideturtle() def game(): target_counter = 0 text_turtle.clear() start_time = time.time() time_left = max_time while time_left >= 0: text_turtle.write('Time left: {} seconds'.format(int(time_left)), font=('Courier', 20, 'bold italic')) time_left = max_time - (time.time() - start_time) text_turtle.clear() Player_turtle.left(5) if bullet.in_motion: bullet.forward(bullet_speed) if bullet.distance(Target_Turtle) < 20: Target_Turtle.hideturtle() reload() set_target() target_counter = target_counter + 1 if bullet.xcor() < -width / 2 or bullet.xcor() > width / 2: bullet.hideturtle() reload() if bullet.ycor() < -length / 2 or bullet.ycor() > length / 2: reload() bullet.hideturtle() window.update() window.update() text_turtle.write('You popped:{} bubbles,\npress r to retry Square_Hunter.io,'.format(int(target_counter)), font=('Courier', 20, 'bold italic'), align='center') def set_target(): randomx = random.randint(-width/2, width/2) randomy = random.randint(-length/2, length/2) Target_Turtle.setposition(randomx, randomy) Target_Turtle.showturtle() def shoot(): bullet.in_motion = True bullet.setheading(Player_turtle.heading()) window.onkeypress(None,'space') bullet.showturtle() window.onkeypress(game, 'r') window.onkeypress(shoot,'space') window.listen() bullet.showturtle() def reload(): bullet.hideturtle() bullet.setposition(Player_turtle.position()) bullet.in_motion = False window.onkeypress(shoot, 'space') set_target() max_time = 120 target_counter = 0 start_time = time.time() time_left = max_time while time_left >= 0: text_turtle.write('Time left: {} seconds'.format(int(time_left)), font=('Courier', 20, 'bold italic')) time_left = max_time - (time.time() - start_time) text_turtle.clear() Player_turtle.left(5) if bullet.in_motion: bullet.forward(bullet_speed) if bullet.distance(Target_Turtle) < 20: Target_Turtle.hideturtle() reload() set_target() target_counter = target_counter + 1 if bullet.xcor() < -width/2 or bullet.xcor() > width/2: bullet.hideturtle() reload() if bullet.ycor() < -length/2 or bullet.ycor() > length/2: reload() bullet.hideturtle() window.update() window.update() text_turtle.write('You popped:{} bubbles,\npress r to retry Square_Hunter.io,'.format(int(target_counter)), font=('Courier', 20, 'bold italic'), align='center')

Code for |GOBLIN_HUNT|

import random print('|GOBLIN_HUNT|') print("\nAre you scared of goblins?\n") # Grab input for the user user_name = input("Enter your name: ") print(user_name + ", can you find the scary goblin hiding in the kitchen cupboards?\n") number_of_doors=5 #print goblin doors print("|_||_||_||_||_|") # part 1: Decide which door goblin behind goblin_door = random.randint(1, number_of_doors) play_game = True #part 2: asking the user to guess while play_game: user_guess = input("Guess a door(using a number from 1 to 5):") user_guess_as_int = int(user_guess) #part 3: checking if the user is correct if goblin_door == int(user_guess): print("\nWell done! You have found the goblin") play_game = False else: print("\n Incorrect guess!") #part 4: continue game if the user guesses wrong

Code for |TURTLE_RUN|

import turtle import random import time width = 600 length = 600 player_turtle = turtle.Turtle() player_turtle.penup() player_turtle.shape('turtle') player_turtle.color('orange') bubble_turtle = turtle.Turtle() text_turtle = turtle.Turtle() text_turtle.hideturtle() bubble_turtle.penup() bubble_turtle.hideturtle() # Instruction screen code window = turtle.Screen() window.bgcolor('green') window.setup(width, length) window.tracer(0) text_turtle.write('Press Right arrow and Left arrow to turn the turtle,\npress space to start Turtle.io', font=('Courier', 20, 'bold italic'), align='center',) # Instruction screen code player_turtle.hideturtle() window.tracer(0) def make_bubble(): randomx = random.randint(-300, 300) randomy = random.randint(-300, 300) bubble_turtle.setx(randomy) bubble_turtle.sety(randomx) bubble_turtle.dot(20) def move_left(): player_turtle.left(90) def move_right(): player_turtle.right(90) max_time=20 def game(): bubble_counter = 0 text_turtle.clear() make_bubble() start_time=time.time() time_left = max_time while time_left >= 0: text_turtle.write('Time left: {} seconds'.format(int(time_left)), font=('Courier', 20, 'bold italic')) time_left = max_time - (time.time() - start_time) text_turtle.clear() player_turtle.showturtle() player_turtle.forward(5) if player_turtle.xcor() > width/2 or player_turtle.xcor() < -width/2: player_turtle.setx(-player_turtle.xcor()) if player_turtle.ycor() > length/2 or player_turtle.ycor() < -length/2: player_turtle.sety(-player_turtle.ycor()) if player_turtle.distance(bubble_turtle) < 20: bubble_turtle.clear() make_bubble() bubble_counter = bubble_counter + 1 window.update() text_turtle.write('You popped: {} bubbles,\npress space to retry Turtle.io,\nExtra Rule:\nyou can only pop the new bubble on a new try.'.format(int(bubble_counter)), font=('Courier', 20, 'bold italic'), align='center') window.onkeypress(game,'space') window.onkeypress(move_left,'Left') window.onkeypress(move_right,'Right') window.listen() turtle.done() import turtle import random import time width = 700 length = 700 player_turtle = turtle.Turtle() player_turtle.penup() player_turtle.shape('turtle') player_turtle.color('orange') bubble_turtle = turtle.Turtle() text_turtle = turtle.Turtle() text_turtle.hideturtle() bubble_turtle.penup() bubble_turtle.hideturtle() # Instruction screen code window = turtle.Screen() window.bgcolor('green') window.setup(width, length) window.tracer() text_turtle.write('Press Right arrow and Left arrow to turn the turtle,\npress space to start Turtle.io', font=('Courier', 20, 'bold italic'), align='center',) # Instruction screen code player_turtle.hideturtle() window.tracer(0) def make_bubble(): randomx = random.randint(-300, 300) randomy = random.randint(-300, 300) bubble_turtle.setx(randomy) bubble_turtle.sety(randomx) bubble_turtle.dot(20) def move_left(): player_turtle.left(90) def move_right(): player_turtle.right(90) max_time=20 def game(): bubble_counter = 0 text_turtle.clear() make_bubble() start_time = time.time() time_left = max_time while time_left >= 0: text_turtle.write('Time left: {} seconds'.format(int(time_left)), font=('Courier', 20, 'bold italic')) time_left = max_time - (time.time() - start_time) text_turtle.clear() player_turtle.showturtle() player_turtle.forward(5) if player_turtle.xcor() > width/2 or player_turtle.xcor() < -width/2: player_turtle.setx(-player_turtle.xcor()) if player_turtle.ycor() > length/2 or player_turtle.ycor() < -length/2: player_turtle.sety(-player_turtle.ycor()) if player_turtle.distance(bubble_turtle) < 20: bubble_turtle.clear() make_bubble() bubble_counter = bubble_counter + 1 window.update() text_turtle.write('You popped: {} bubbles,\npress space to retry Turtle.io,\nExtra Challenge:\nyou can only pop the new bubble on a new try.'.format(int(bubble_counter)), font=('Courier', 20, 'bold italic'), align='center') window.onkeypress(game,'space') window.onkeypress(move_left,'Left') window.onkeypress(move_right,'Right') window.listen() turtle.done()

 
This site was designed with the
.com
website builder. Create your website today.
Start Now