diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd20fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +*.pyc diff --git a/Alphaproj.py b/Alphaproj.py deleted file mode 100644 index 32ee658..0000000 --- a/Alphaproj.py +++ /dev/null @@ -1,9 +0,0 @@ -import time -from construct import createRoad, createTurtles, randomTurtles,createRanking - -length = createRoad.create() -t = createTurtles.create() -time.sleep(1) -time_r = randomTurtles.makeItMove(t, length) -createRanking.create(time_r,t) -input() \ No newline at end of file diff --git a/construct/__pycache__/__init__.cpython-37.pyc b/construct/__pycache__/__init__.cpython-37.pyc index f93c9f2..bd433ad 100644 Binary files a/construct/__pycache__/__init__.cpython-37.pyc and b/construct/__pycache__/__init__.cpython-37.pyc differ diff --git a/construct/__pycache__/createRoad.cpython-37.pyc b/construct/__pycache__/createRoad.cpython-37.pyc index cb790e3..f66aa22 100644 Binary files a/construct/__pycache__/createRoad.cpython-37.pyc and b/construct/__pycache__/createRoad.cpython-37.pyc differ diff --git a/construct/__pycache__/createTurtles.cpython-37.pyc b/construct/__pycache__/createTurtles.cpython-37.pyc index de8fab9..87a2afc 100644 Binary files a/construct/__pycache__/createTurtles.cpython-37.pyc and b/construct/__pycache__/createTurtles.cpython-37.pyc differ diff --git a/construct/__pycache__/randomTurtles.cpython-37.pyc b/construct/__pycache__/randomTurtles.cpython-37.pyc index 0c56e7a..09e97e8 100644 Binary files a/construct/__pycache__/randomTurtles.cpython-37.pyc and b/construct/__pycache__/randomTurtles.cpython-37.pyc differ diff --git a/construct/constructWorld.py b/construct/constructWorld.py new file mode 100644 index 0000000..3cbe675 --- /dev/null +++ b/construct/constructWorld.py @@ -0,0 +1,12 @@ +import time +from construct import createRoad, createTurtles, randomTurtles,createRanking + +#n = + +def createtheWorld(length): + createRoad.create(length + 1) + t = createTurtles.create() + time.sleep(1) + time_r = randomTurtles.makeItMove(t, length + 1) + createRanking.create(time_r,t) + \ No newline at end of file diff --git a/construct/createRanking.py b/construct/createRanking.py index 45b6c19..a5c5c76 100644 --- a/construct/createRanking.py +++ b/construct/createRanking.py @@ -2,56 +2,58 @@ def create(timeindex, tur): - # Clear drawer's line and pen-it-up - clear () - pu () - # Clear turtles' lines - for i in range (4): - tur[timeindex[2 * i]].clear () - # Penup turtles - for i in range (4): - tur[timeindex[2 * i]].pu () - # Hide turtles - for i in range (4): - tur[timeindex[2 * i]].ht () - # Draw the ranking - ht () - y = 100 - setpos (-220, y) - pd () - for i in range (3): - forward (480) - pu () - y -= 100 - goto (-220, y) - pd () - pu () - x = -220 - setpos (x, 100) - pd () - right (90) - forward (200) - for i in range (4): - pu () - x += 120 - goto (x, 100) - pd () - forward (200) - # Write something :v - pu () - goto (-280, 40) - write ("Turtle", move=False, align="center", font=("Arial", 15, "normal")) - goto (-280, -60) - write ("Time", move=False, align="center", font=("Arial", 15, "normal")) - # Turtle's rank - x = -160 - for i in range (4): - tur[timeindex[2 * i]].goto (x, 50) - tur[timeindex[2 * i]].left (90) - x += 120 - tur[timeindex[2 * i]].st () - x = -165 - for i in range (4): - goto (x, -55) - x += 120 - write (("%0.2f" % timeindex[2 * i + 1]), move=False, align="center", font=("Arial", 10, "bold")) + # Clear drawer's line and pen-it-up + clear () + pu () + # Clear turtles' lines + for i in range (4): + tur[timeindex[2 * i]].clear () + # Penup turtles + for i in range (4): + tur[timeindex[2 * i]].pu () + # Hide turtles + for i in range (4): + tur[timeindex[2 * i]].ht () + # Draw the ranking + ht () + y = 100 + setpos (-220, y) + pd () + for i in range (3): + forward (480) + pu () + y -= 100 + goto (-220, y) + pd () + pu () + x = -220 + setpos (x, 100) + pd () + right (90) + forward (200) + for i in range (4): + pu () + x += 120 + goto (x, 100) + pd () + forward (200) + # Write something :v + pu () + goto (-280, 40) + write ("Turtle", move=False, align="center", font=("Arial", 15, "normal")) + goto (-280, -60) + write ("Time", move=False, align="center", font=("Arial", 15, "normal")) + # Turtle's rank + x = -160 + for i in range (4): + tur[timeindex[2 * i]].goto (x, 50) + tur[timeindex[2 * i]].left (90) + x += 120 + tur[timeindex[2 * i]].st () + x = -165 + for i in range (4): + goto (x, -55) + x += 120 + write (("%0.2f" % timeindex[2 * i + 1]), move=False, align="center", font=("Arial", 10, "bold")) + #Medals + diff --git a/construct/createRoad.py b/construct/createRoad.py index 0872fc1..c83b19c 100644 --- a/construct/createRoad.py +++ b/construct/createRoad.py @@ -2,43 +2,31 @@ from construct.createTurtles import gencolor -#Create road's length buttons -def makeshort(n): - n = int(10) -def makelong(n): - n = int(20) -def makemedium(n): - n = int(15) - - #Create road of course -def create(): - speed(0) - penup() - goto(-140,140) #Set the default position - n = 0 - bgcolor("white") - # onkey(makeshort(n),"U") - # onkey(makelong(n),"O") - # onkey(makemedium(n),"I") - # listen() - - screensize(480, 360) - - n = int(textinput("Noti from Pornhub ", "Please enter the length of the road: ")) - n = n + 1 - #Draw lines of the road - for step in range(n): - write(step, align = 'center') - right(90) - #Draw dashed lines - for step in range (15): - forward(10) - if (step % 2 == 0): penup() - else: pendown() - #Start drawing the next line - penup() - backward(150) - left(90) - forward(20) - return n +def create(n): + speed(0) + penup() + bgcolor("white") + screensize(360, 100) + #Set the default position + if (n == 13): + startPos = -120 + elif (n == 17): + startPos = -160 + elif(n == 21): + startPos = -200 + goto(startPos,140) + #Draw lines of the road + for step in range(n): + write(step, align = 'center') + right(90) + #Draw dashed lines + for step in range (15): + forward(10) + if (step % 2 == 0): penup() + else: pendown() + #Start drawing the next line + penup() + backward(150) + left(90) + forward(20) diff --git a/construct/createTurtles.py b/construct/createTurtles.py index efbc7c8..f5aa282 100644 --- a/construct/createTurtles.py +++ b/construct/createTurtles.py @@ -10,7 +10,9 @@ def gencolor(): #Create turtles absolutely def create(): - x, y, spin = -150, 100, 0 #Set the default coordinates + #Set the default coordinates + if (n == 13): + x, y, spin = -150, 100, 0 tur = [] for n in (gencolor(),gencolor(),gencolor(),gencolor()): #Create the turtles diff --git a/construct/randomTurtles.py b/construct/randomTurtles.py index 157ae34..a869982 100644 --- a/construct/randomTurtles.py +++ b/construct/randomTurtles.py @@ -61,12 +61,13 @@ def makeItMove(valTurtle, step): flag = [1, 1, 1, 1] SetTurPosition = [100, 70, 40, 10] stunIndex = [0,0,0,0] - stunStep = 6 - revStep = 6 + stunStep = step/4 + revStep = step/4 endPos = -150 + road_l pos0 = [randint(-140,endPos),randint(-140,endPos),randint(-140,endPos),randint(-140,endPos)] pos1 = [randint(-140,endPos),randint(-140,endPos),randint(-140,endPos),randint(-140,endPos)] - pos2 = [randint(-140,endPos),randint(-140,endPos),randint(-140,endPos),randint(-140,endPos)] + pos2 = [randint(-140,endPos/2),randint(-140,endPos/2),randint(-140,endPos/2),randint(-140,endPos/2)] + pos3 = [randint(endPos/2,endPos),randint(endPos/2,endPos),randint(endPos/2,endPos),randint(endPos/2,endPos)] while (flag[0] == 1 or flag[1] == 1 or flag[2] == 1 or flag[3] == 1): speed = [randint (minSpeed, maxSpeed), randint (minSpeed, maxSpeed), randint (minSpeed, maxSpeed), randint (minSpeed, maxSpeed)] turRoadLengh = makeTutlePos (valTurtle, 4) @@ -80,7 +81,7 @@ def makeItMove(valTurtle, step): if (stunIndex[event[i*2]] % stunStep == 0): TurtleEventFlag[event[i * 2]] = 1 #If event is backward - if((event[i*2+1]==2 or event[i*2+1]==3)and(pos2[event[i*2]] - maxSpeed< turRoadLengh[event[i*2]] < pos2[event[i*2]])): + if((event[i*2+1]==2 and(pos2[event[i*2]] - maxSpeed < turRoadLengh[event[i*2]] < pos2[event[i*2]]))or((event[i*2+1]==3)and(pos3[event[i*2]] - maxSpeed < turRoadLengh[event[i*2]] < pos3[event[i*2]]))): TurtleEventFlag[event[i*2]] = -1 ###Make a real move and do event act for j in range (4): @@ -90,7 +91,10 @@ def makeItMove(valTurtle, step): if (TurtleEventFlag[j] == -1): valTurtle[j].left (180) - pos2[j] = pos2[j] - speed[j]*revStep + if (pos2[j] - maxSpeed + #Short + buttonphoto1 = PhotoImage(file = "images/select/ButtonShort.png", master = selectframe) + lengthbutton1 = Button(selectframe, image = buttonphoto1) + lengthbutton1.image = buttonphoto1 + lengthbutton1.bind("", lambda event: makeshort(event, selectframe)) + lengthbutton1.grid(row = 1, column = 0, sticky=N+E+S+W) + #Medium + buttonphoto2 = PhotoImage(file = "images/select/ButtonMedium.png", master = selectframe) + lengthbutton2 = Button(selectframe, image = buttonphoto2) + lengthbutton2.image = buttonphoto2 + lengthbutton2.bind("", lambda event: makemedium(event, selectframe)) + lengthbutton2.grid(row = 1, column = 1, sticky=N+E+S+W) + #Long + buttonphoto3 = PhotoImage(file = "images/select/ButtonLong.png", master = selectframe) + lengthbutton3 = Button(selectframe, image = buttonphoto3) + lengthbutton3.image = buttonphoto3 + lengthbutton3.bind("", lambda event: makelong(event, selectframe)) + lengthbutton3.grid(row = 1, column = 2, sticky=N+E+S+W) + #Deiconify select window + select.deiconify() +#--------------------------------------------------------------------# +#Set background +bgframe = Frame(root) +bgframe.pack(fill = BOTH) +#Background +bgphoto = PhotoImage(file = "images/login/Background.png") +background = Label(bgframe, image = bgphoto) +background.pack() +#Play button +playbutton = PhotoImage(file = "images/login/PlayButton.png") +play = Button(background, image = playbutton) +play.bind("", selectLength) +play.place(x = 135, y = 430) +#Quit button +quitbutton = PhotoImage(file = "images/login/QuitButton.png") +quit = Button(background, image = quitbutton, command = bgframe.quit) +quit.place(x = 245, y = 515) +#--------------------------------------------------------------------# +#Main loop +root.mainloop() diff --git a/images/login/Background.png b/images/login/Background.png new file mode 100644 index 0000000..04b405f Binary files /dev/null and b/images/login/Background.png differ diff --git a/images/login/PlayButton.png b/images/login/PlayButton.png new file mode 100644 index 0000000..de1b949 Binary files /dev/null and b/images/login/PlayButton.png differ diff --git a/images/login/QuitButton.png b/images/login/QuitButton.png new file mode 100644 index 0000000..f261036 Binary files /dev/null and b/images/login/QuitButton.png differ diff --git a/images/reward_medals/1st_Reward.gif b/images/reward_medals/1st_Reward.gif new file mode 100644 index 0000000..6486864 Binary files /dev/null and b/images/reward_medals/1st_Reward.gif differ diff --git a/images/select/ButtonLong.png b/images/select/ButtonLong.png new file mode 100644 index 0000000..2bca6f5 Binary files /dev/null and b/images/select/ButtonLong.png differ diff --git a/images/select/ButtonMedium.png b/images/select/ButtonMedium.png new file mode 100644 index 0000000..d4e9a8e Binary files /dev/null and b/images/select/ButtonMedium.png differ diff --git a/images/select/ButtonShort.png b/images/select/ButtonShort.png new file mode 100644 index 0000000..602530f Binary files /dev/null and b/images/select/ButtonShort.png differ diff --git a/images/select/chooseLength.png b/images/select/chooseLength.png new file mode 100644 index 0000000..cfb4db6 Binary files /dev/null and b/images/select/chooseLength.png differ