import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) screen.title("Turtle Crossing") screen.listen() scoreboard= Scoreboard() car_manager= CarManager() player=Player((0, -100)) screen.onkey(player.move, "w") game_is_on = True while game_is_on == True: time.sleep(0.1) car_manager.create_cars() car_manager.move() scoreboard.update() screen.update()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard # screen setup screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) screen.title("Crossing Busy Road!") # generate game objects turtle = Player() cars = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkeypress(turtle.move_forward, "Up") # game start game_is_on = True while game_is_on: time.sleep(0.1) screen.update() cars.create_car() cars.move_left() # detect the turtle has reached the top edge of the screen successfully if turtle.at_finish_line(): turtle.to_start()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.bgcolor("grey") screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.go_up, "Up") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() car_manager.create_car() car_manager.move() #detect collision with car for car in car_manager.all_cars: if car.distance(player) < 20: game_is_on = False scoreboard.game_over()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() score = Scoreboard() cars = CarManager() # Event keys screen.listen() screen.onkey(fun=player.move, key="Up") # Game on game_is_on = True counter = 6 while game_is_on: counter += 1 time.sleep(0.1) screen.update() # Generate cars every 6th time the loop runs if counter % 6 == 0: cars.new_car() # Move the cars to the left cars.move()
import time import random from turtle import Screen from player import Player, FINISH_LINE_Y from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.move, "Up") game_is_on = True generate_loops = 10 while game_is_on: time.sleep(0.05) if random.randint(0, generate_loops) == 0: car_manager.generate_car() loop_count = 0 car_manager.move_cars() if car_manager.detect_collision(player): game_is_on = False scoreboard.game_over() if player.ycor() > FINISH_LINE_Y: player.restart()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) sleep_time = 0.1 scoreboard = Scoreboard() number = 10 while number > 0: screen.clear() scoreboard.increase_score() screen.tracer(0) car = CarManager() player = Player() screen.listen() screen.onkey(fun=player.up, key="Up") screen.onkey(fun=player.down, key="Down") screen.onkey(fun=player.l_left, key="Left") screen.onkey(fun=player.r_right, key="Right") game_is_on = True while game_is_on: time.sleep(sleep_time) screen.update() car.move() car.new_position() if player.ycor() > 280:
# Turtle Crossing Game import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.title("Turtle Crossing") screen.tracer(0) turt = Player() score = Scoreboard() car_manager = CarManager() screen.listen() screen.onkey(turt.move_up, "Up") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() car_manager.drive() car_manager.create_car() # detect car collision for car in car_manager.all_cars: if car.distance(turt) < 17:
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.move, "Up") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() car_manager.add_car() car_manager.move() if player.ycor() > player.finish_line: scoreboard.increase_level() player.reset() car_manager.level_up() for car in car_manager.cars: if car.distance(player) < 20: game_is_on = False
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.move, "Up") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() car_manager.spawn_car() car_manager.drive() for car in car_manager.all_cars: if car.distance(player) < 20: game_is_on = False scoreboard.game_over()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.bgcolor('white') screen.tracer(0) player = Player() scoreboard = Scoreboard() car = CarManager() screen.listen() screen.onkey(player.move, 'Up') game_is_on = True current_level = 1 speed = 0.1 while game_is_on: time.sleep(speed) screen.update() car.move_car() #check collision for dummy_car in car.cars: if dummy_car.distance(player) < 25:
from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard level = 1 screen = Screen() screen.setup(width=600, height=600) screen.title('Frogger') screen.bgcolor('white') screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() scoreboard.draw(level) screen.listen() screen.onkey(player.go_up, "Up") game_is_on = True while game_is_on: if player.crossed_finish_line(): player.reset_position() level += 1 car_manager.increase_speed() car_manager.move_cars() if car_manager.check_collision(player):
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard STARTING_SPEED = 0.1 screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) score = Scoreboard() my_turt = Player() garage = CarManager() screen.listen() screen.onkey(my_turt.go_turtle_go, 'Up') game_is_on = True while game_is_on: time.sleep(STARTING_SPEED) screen.update() garage.new_car() garage.drive_cars() for car in garage.all_cars: if my_turt.distance(car) <= 20: score.game_over() game_is_on = False if my_turt.is_at_finish_line():
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() cars = CarManager() screen.onkey(player.moveForward, "Up") screen.listen() scoreboard = Scoreboard() game_is_on = True while game_is_on: # time.sleep(0.1) screen.update() cars.createNewCars() cars.moveCars() for car in cars.allCars: if car.distance(player) < 20: game_is_on = False scoreboard.gameOver()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() cars = CarManager() score = Scoreboard() screen.listen() screen.onkey(player.move, 'Up') game_is_on = True while game_is_on: time.sleep(0.1) cars.move_cars() screen.update() if cars.hit(player): score.game_over() game_is_on = False if player.score(): score.scored() cars.move_distance += 2 cars.change_position()
from player import Player from scoreboard import ScoreBoard import time STARTING_CAR_SPEED = 5 screen = Screen() screen.bgcolor("white") screen.title("Turtle Crossing Start") screen.setup(width=600, height=600) screen.tracer(0) player = Player() screen.listen() screen.onkeypress(fun=player.move_up, key="Up") scoreboard = ScoreBoard() car_manager = CarManager() game_on = True i = 0 car_speed = STARTING_CAR_SPEED while game_on: time.sleep(0.1) screen.update() car_manager.move_cars(car_speed) car_manager.remove_cars_finishing_track() if i % 6 == 0: car_manager.create_random_car() i = 0 # Detect Player Collision with car for car in car_manager.cars:
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(key="Up", fun=player.move) loop_count = 0 game_is_on = True while game_is_on: # generate cars if loop_count % 6 == 0: car_manager.create_car() # move cars car_manager.move() # detect collision with car for car in car_manager.all_cars: if player.distance(car) < 20:
import time cars = [] print(cars) # TODO: Create screen screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) # TODO: Create player, cars and scoreboard player = Player() scoreboard = Scoreboard() for car in range(0, 30): new_car = CarManager() cars.append(new_car) # TODO:Get screen to listen when forward key is clicked screen.listen() screen.onkey(fun=player.move_forward, key="Up") game_is_on = True while game_is_on: time.sleep(player.game_speed) screen.update() #TODO: Get cars to move for car in cars: car.move() if car.xcor() < -300:
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() carManager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.move_up, "Up") screen.onkey(player.move_down, "Down") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() carManager.createCar() carManager.moveCars() # Detect collision with cars for car in carManager.all_cars: if car.distance(player) < 20: game_is_on = False scoreboard.gameOver()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.title("Crossy Road") screen.setup(width=600, height=600) screen.tracer(0) screen.listen() player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.onkey(player.up,'Up') game_is_on = True while game_is_on: time.sleep(player.pace) screen.update() # Create new car car_manager.create_car() # Car starts motion car_manager.move() # Car leaving screen # car_manager.redirect()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() cars = CarManager() screen.listen() screen.onkey(player.up, "Up") screen.onkey(player.down, "Down") scoreboard = Scoreboard() game_is_on = True count = 0 while game_is_on: time.sleep(0.1) screen.update() cars.move_car() if count < 6: count += 1 else: count = 0 cars.new_car()
# Constants SCREEN_UPDATE = 0.1 # Screen setup for the game screen = tt.Screen() screen.setup(width=600, height=600) screen.title(" Crossy road DeepFake") screen.tracer(0) screen.listen() # Creating the instances of the required game elements (player, cars, scoreboard) player = Player() screen.onkey(player.move, "Up") scoreboard = Scoreboard() car = CarManager() # Driver code to run the game game_is_on = True while game_is_on: time.sleep(SCREEN_UPDATE) screen.update() # Generating the cars on the screen car.crate_car() car.move_cars() # checking for when the Turtle Reaches the finish line if player.ycor() > 280: player.refresh() scoreboard.levelupdate()
from car_manager import CarManager if __name__ == '__main__': # car_manager = CarManager(socket_host='192.168.1.104', debug=True) car_manager = CarManager(socket_host='172.18.22.12', debug=False) car_manager.run()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard BACKGROUND_COLORS = ['#B5CF49', '#A3BF45', '#81A140', '#74923A', '#617B30'] screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) screen.bgcolor(BACKGROUND_COLORS[0]) player = Player() car = CarManager() scoreboard = Scoreboard() screen.listen() if -300 < player.xcor() < 300 and player.ycor() > -300: screen.onkey(player.upMove, "Up") screen.onkey(player.downMove, "Down") screen.onkey(player.leftMove, "Left") screen.onkey(player.rightMove, "Right") gameRun = False def gameRunTrue(x, y): global gameRun gameRun = True scoreboard.clear()
from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() scoreboard = Scoreboard() screen.listen() screen.onkeypress(player.move, 'Up') game_is_on = True count = 0 car_manager = CarManager() while game_is_on: count += 1 if count % 6 == 0: car_manager.create_car() car_manager.move_cars() time.sleep(0.1) screen.update() random.shuffle(car_manager.all_cars) if player.end_line(): scoreboard.update_level() player.goto_beginning() car_manager.update_level() if car_manager.check_collision(player):
import turtle import time from player import Player from car_manager import CarManager from scoreboard import Scoreboard # screen setup screen = turtle.Screen() screen.setup(width=800, height=600) screen.tracer(0) # player, etc. setup player = Player() car_manager = CarManager() scoreboard = Scoreboard() # controls setup screen.listen() screen.onkey(player.move_up, "Up") game_is_over = False while not game_is_over: time.sleep(0.1) screen.update() car_manager.move_cars() # check for level up condition if player.reached_finish(): scoreboard.increase_level()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() screen.listen() screen.onkey(player.move, 'space') scoreboard = Scoreboard() cars = CarManager() game_is_on = True while game_is_on: time.sleep(0.1) screen.update() cars.create_car() cars.move_all() if player.ycor() >= 300: scoreboard.level_up() cars.level_up() player.refresh() for i in cars.all_cars: if i.distance(player) < 20: game_is_on = False scoreboard.game_over() screen.exitonclick()
import time from turtle import Screen from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.tracer(0) player = Player() car_manager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.go_up, 'Up') screen.onkey(player.go_down, 'Down') screen.onkey(player.go_left, 'Left') screen.onkey(player.go_right, 'Right') game_is_on = True counter = 0 while game_is_on: time.sleep(0.1) screen.update() car_manager.move_cars() counter += 1 if counter % 6 == 0: car_manager.generate_car()
DIFFICULTIES = {"easy": 10, "medium": 15, "hard": 20, "impossible": 40} # initialize screen screen = Screen() screen.title("Turtle") screen.setup(width=600, height=600) screen.tracer(0) player_choice = screen.textinput( "Welcome to Turtle!", "Which difficulty? (easy/medium/hard/impossible") #initialize player, scoreboard and car manager player = Player() scoreboard = Scoreboard(player=player) car_manager = CarManager(number=DIFFICULTIES[player_choice], grid=GRID, player=player) # main loop while player.is_alive: # listen to key presses screen.listen() screen.onkeypress(fun=player.move, key="Up") screen.onkey(fun=screen.bye, key="Escape") # updates player.update() car_manager.update() scoreboard.update() time.sleep(0.1)
import time from turtle import Screen, Turtle from player import Player from car_manager import CarManager from scoreboard import Scoreboard screen = Screen() screen.setup(width=600, height=600) screen.title("Crossy Road") screen.tracer(0) player = Player() carmanager = CarManager() scoreboard = Scoreboard() screen.listen() screen.onkey(player.starter,"Up") game_is_on = True while game_is_on: time.sleep(0.1) screen.update() carmanager.creator() carmanager.move() # Detecting collisiontwith the cars for car in carmanager.all_cars: if car.distance(player) < 20: game_is_on = False scoreboard.game_over()
from player import Player from car_manager import CarManager from scoreboard import Scoreboard from random import randint difficulty = {"easy": 5, "medium": 20, "hard": 50} screen = Screen() screen.tracer(0) screen.setup(height=600, width=600) diff = screen.textinput( "Choose Difficulty", "Which difficulty do you want? easy, medium or hard" ) player = Player() level = Scoreboard() cars = CarManager() screen.listen() screen.onkey(player.move_forward, "Up") game_is_on = True while game_is_on: time.sleep(cars.car_speed) if randint(1, 100) < difficulty[diff]: cars.generate_car() cars.move() for car in cars.cars: car_bottom = car.ycor() - 20 car_top = car.ycor() + 20 if player.distance(car) <= 50 and car_bottom < player.ycor() < car_top: game_is_on = False