Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added y coordinate and increased speed of cars with each level #55

Open
wants to merge 1 commit into
base: bug-beatles
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bug-beatles/modern_chair/chair.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="info-wrap mob-margin">
<p class="title-up">Modern chair</p>
<h2>Telford Kursi</h2>
<h4>$254 <span>$530</span></h4>
<h4>$260 <span>$530</span></h4>
<div class="section-fluid">
<input class="desc-btn" type="radio" id="desc-1" name="desc-btn" checked />
<label for="desc-1">Description</label>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 6 additions & 5 deletions bug-beatles/python-turtle-crossing/cars.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# cars.py
from turtle import Turtle
import random
COLORS = ['blue', 'red', 'yellow', 'purple', 'green']

COLORS = ['blue', 'red', 'yellow', 'purple', 'green']

class Cars(Turtle):

def __init__(self):
def __init__(self, speed):
super().__init__()
self.x_move = 10
self.x_move = speed # Initialize the speed of the cars
self.color(random.choice(COLORS))
self.shape("square")
self.shapesize(1, 2)
Expand All @@ -16,5 +17,5 @@ def __init__(self):

def move(self):
self.goto(self.xcor()-self.x_move, self.ycor())


17 changes: 14 additions & 3 deletions bug-beatles/python-turtle-crossing/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# main.py
import time
from turtle import Turtle, Screen
from cars import Cars
Expand All @@ -11,19 +12,20 @@
scoreboard = Scoreboard()
screen.setup(width=600, height=600)


screen.update()

game_is_on = True
all_cars = []
counter = 0
screen.listen()
finish_line_y = 280
car_speed = 10

screen.listen()
screen.onkeypress(player.up, "Up")

while game_is_on:
if counter % 3 == 0:
car = Cars()
car = Cars(car_speed)
all_cars.append(car)

counter += 1
Expand All @@ -34,6 +36,15 @@
break
car.move()

if player.ycor() > finish_line_y:
for car in all_cars:
car.clear() # Clear the car from the screen
car.hideturtle() # Hide the car turtle
all_cars.clear() # Clear the list of cars
player.goto(0, -270)
scoreboard.update_level()
car_speed += 2

time.sleep(0.1)
screen.update()

Expand Down
2 changes: 1 addition & 1 deletion bug-beatles/python-turtle-crossing/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def __init__(self):
self.setheading(90)

def up(self):
self.forward(20)
self.forward(20)
40 changes: 40 additions & 0 deletions bug-beatles/python-turtle-crossing/tempCodeRunnerFile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import time
from turtle import Turtle, Screen
from cars import Cars
from player import Player
from scoreboard import Scoreboard

screen = Screen()
screen.tracer(0)

player = Player()
scoreboard = Scoreboard()
screen.setup(width=600, height=600)


screen.update()

game_is_on = True
all_cars = []
counter = 0
screen.listen()

screen.onkeypress(player.up, "Up")

while game_is_on:
if counter % 3 == 0:
car = Cars()
all_cars.append(car)

counter += 1
for car in all_cars:
if player.distance(car) < 20:
game_is_on = False
scoreboard.game_over()
break
car.move()

time.sleep(0.1)
screen.update()

screen.exitonclick()