From 8e06da6a3e3e6ad8014e75b0f2fdebe193b5e201 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 16 Dec 2021 08:40:47 -0800 Subject: [PATCH] code cleanup and new funcs --- CHANGELOG.txt | 5 ++++- dodger.py | 21 +++++++++++++++++---- version.txt | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 67d17ee..30787e4 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -40,4 +40,7 @@ Added install script STABLES v1.0 -Changed fall speed increasing, optimizations, STABLE RELEASE! \ No newline at end of file +Changed fall speed increasing, optimizations, STABLE RELEASE! + +v1.1 +Code clean up, dev tools on "r" and A + D moving support \ No newline at end of file diff --git a/dodger.py b/dodger.py index 080f145..24b1839 100644 --- a/dodger.py +++ b/dodger.py @@ -5,7 +5,6 @@ import time import random TK_SILENCE_DEPRECATION=1 -# fallers = 1 delay = 0.00625 score = 0 score_this_round = 0 @@ -14,7 +13,7 @@ highscore = highscoredoc.read() # Creating a window screen wn = turtle.Screen() -wn.title("Dodger Game v1.0") +wn.title("Dodger Game v1.1") wn.bgcolor("black") wn.setup(width=600, height=600) wn.tracer(0) @@ -45,7 +44,7 @@ def move_down(self): return self def randomize_location(self): - self.xpos = random.randint(-280, 280) + self.xpos = random.randrange(-280, 280, 30) self.ypos = 290 return self # fallers in the game @@ -83,10 +82,25 @@ def move(): if head.direction == "left": x = head.xcor() head.setx(x+3) + +def DEVTOOLRESET(): + head.direction = "Stop" + head.goto(0,-280) + score = 0 + fallspeed = 0 + score_this_round = 0 + time.sleep(2) + fallspeed = 1.5 wn.listen() wn.onkeypress(goright, "Right") wn.onkeypress(goleft, "Left") +wn.onkeypress(goright, "d") +wn.onkeypress(goleft, "a") +wn.onkeypress(goright, "D") +wn.onkeypress(goleft, "A") wn.onkeypress(stop, " ") +wn.onkeypress(DEVTOOLRESET, "r") +wn.onkeypress(DEVTOOLRESET, "R") # main loop while True: wn.update() @@ -150,7 +164,6 @@ def move(): if score_this_round == 5 or score_this_round > 5: score += 1 score_this_round = 0 - fallspeed += 0.075 if int(score) < 0: pen.goto(0, 100) pen.write("GAME OVER!\nrestart game", align="center", font=("helvetica", 20, "bold")) diff --git a/version.txt b/version.txt index dbc9d7d..059c71d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -Version STABLE v1.0.0 +Version STABLE v1.1