Skip to content

Commit

Permalink
fix windows launching error
Browse files Browse the repository at this point in the history
  • Loading branch information
AviationSFO committed Jul 17, 2022
1 parent 435339f commit e26b6ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 10 additions & 1 deletion prefs.json
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
{"highscore": 0, "bgcolor": "dark green", "foodcolor": "navy", "foodshape": "square", "foodnum": 2, "mutesound": true, "headcolor": "white", "tailcolor": "blue"}
{
"highscore": 0,
"bgcolor": "dark green",
"foodcolor": "navy",
"foodshape": "square",
"foodnum": 2,
"mutesound": true,
"headcolor": "white",
"tailcolor": "blue"
}
11 changes: 4 additions & 7 deletions turtlesnake.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
noplaysound = True
global high_score
global mutesound
with open(path.expanduser(
"~/Desktop/SnakeGame/prefs.json"), "r") as read_file:
with open("prefs.json", "r") as read_file:
prefs = json.load(read_file)
high_score = prefs["highscore"]
bgcolor = prefs["bgcolor"]
Expand All @@ -66,8 +65,7 @@
score = 0
APIon = False
# opening files
datadoc = open(path.expanduser(
"~/Desktop/SnakeGame/data.txt"), "a")
datadoc = open("data.txt", "a")
foodnum = int(foodnum)

if foodnum == 2:
Expand All @@ -83,7 +81,7 @@
print("Error: last highscore is not an integer.")

wn = turtle.Screen()
wn.title("Snake Game Project v1.13.0")
wn.title("Snake Game Project DEVELOPMENT")
wn.bgcolor(bgcolor)
# the width and height can be put as user's choice
wn.setup(width=600, height=600)
Expand Down Expand Up @@ -436,8 +434,7 @@ def exit():
}

if changedcolor == False:
with open(path.expanduser(
"~/Desktop/SnakeGame/prefs.json"), "w") as write_file:
with open("prefs.json", "w") as write_file:
json.dump(prefs, write_file)
else:
quit()
Expand Down

0 comments on commit e26b6ef

Please sign in to comment.