Skip to content
This repository was archived by the owner on Feb 13, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
311db0a
Update Alphaproj.py
t3bol90 Feb 24, 2019
179257b
Update createTurtles.py
t3bol90 Feb 24, 2019
754c60f
Create .gitignore
W4S4P34 Feb 26, 2019
cc5555b
.pyc incoming!
W4S4P34 Feb 26, 2019
b8ee895
Merge branch 't3bol90-patch-1-1'
W4S4P34 Feb 26, 2019
a798acc
Merge branch 'TurtleProjv1.2'
W4S4P34 Feb 26, 2019
ba18a67
Revert "Merge branch 'TurtleProjv1.2'"
W4S4P34 Feb 26, 2019
e7f60a1
Revert "Revert "Merge branch 'TurtleProjv1.2'""
W4S4P34 Feb 26, 2019
0d943d7
.pyc again!
W4S4P34 Mar 1, 2019
e7af461
Merge branch 'modify'
W4S4P34 Mar 1, 2019
5f0c918
New Version!
W4S4P34 Mar 1, 2019
a1e1dc2
Change!
W4S4P34 Mar 1, 2019
cd1d9eb
Merge remote-tracking branch 'upstream/master' into modify
W4S4P34 Mar 1, 2019
9585ec8
Ranking!
W4S4P34 Mar 1, 2019
02cbf4d
Ranking!
W4S4P34 Mar 2, 2019
3400c60
Merge pull request #7 from lathanhthai1905/modify
t3bol90 Mar 2, 2019
bdc8a12
Add files via upload
t3bol90 Mar 3, 2019
e04464a
:>
W4S4P34 Mar 4, 2019
aed3b7b
BugFixed50% :alien:
W4S4P34 Mar 4, 2019
2a8881b
Merge pull request #9 from lathanhthai1905/modify-bugfixed
t3bol90 Mar 4, 2019
6415d2f
Design incoming :>
W4S4P34 Mar 4, 2019
30677f8
Change!
W4S4P34 Mar 5, 2019
ddd5a0a
Commit thử
W4S4P34 Mar 5, 2019
aa79289
Revert "Change!"
W4S4P34 Mar 5, 2019
2d91e44
Revert "Revert "Change!""
W4S4P34 Mar 5, 2019
6659e72
:<
W4S4P34 Mar 5, 2019
e93d285
:<
W4S4P34 Mar 5, 2019
7b5fe3f
Merge remote-tracking branch 'upstream/master' into modify-bugfixed
W4S4P34 Mar 6, 2019
803ac42
GUI
W4S4P34 Mar 6, 2019
c7d4c57
GUI Safer but not Smooth at all!
W4S4P34 Mar 6, 2019
c903045
Arghhh!
W4S4P34 Mar 7, 2019
9aab304
Merge pull request #13 from lathanhthai1905/TurtleProjv1.4
t3bol90 Mar 7, 2019
488f84a
Update randomTurtles.py
t3bol90 Mar 7, 2019
7a094bb
Sth
W4S4P34 Mar 7, 2019
37b8ba5
:-1:
W4S4P34 Mar 7, 2019
ddc256d
Merge pull request #14 from lathanhthai1905/TurtleProjv1.4
t3bol90 Mar 7, 2019
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
9 changes: 0 additions & 9 deletions Alphaproj.py

This file was deleted.

Binary file modified construct/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified construct/__pycache__/createRoad.cpython-37.pyc
Binary file not shown.
Binary file modified construct/__pycache__/createTurtles.cpython-37.pyc
Binary file not shown.
Binary file modified construct/__pycache__/randomTurtles.cpython-37.pyc
Binary file not shown.
12 changes: 12 additions & 0 deletions construct/constructWorld.py
Original file line number Diff line number Diff line change
@@ -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)

108 changes: 55 additions & 53 deletions construct/createRanking.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

66 changes: 27 additions & 39 deletions construct/createRoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 3 additions & 1 deletion construct/createTurtles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions construct/randomTurtles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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<turRoadLengh[j]<pos2[j]):
pos2[j] = pos2[j] - maxSpeed*revStep
if (pos3[j] - maxSpeed<turRoadLengh[j]<pos3[j]):
pos3[j] = pos3[j] - maxSpeed*revStep
else:
valTurtle[j].goto (endPos, SetTurPosition[j])
if (flag[j] == 1):
Expand Down
89 changes: 89 additions & 0 deletions createUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from tkinter import *
from turtle import *
from construct.constructWorld import *

#--------------------------------------------------------------------#
#Set main window
root = Tk()
root.geometry("800x600+300-80")
root.title("Turtle Racing Boiz")
#--------------------------------------------------------------------#
#Set select buttons window
select = Tk()
select.withdraw()
select.geometry("545x115+450-280")
select.title("Road's Length")
#--------------------------------------------------------------------#
#Create road's length buttons
def makeshort(event, frame):
root.withdraw()
select.withdraw()
frame.destroy()
clearscreen()
createtheWorld(12)
root.deiconify()
def makelong(event, frame):
root.withdraw()
select.withdraw()
frame.destroy()
clearscreen()
createtheWorld(20)
root.deiconify()
def makemedium(event, frame):
root.withdraw()
select.withdraw()
frame.destroy()
clearscreen()
createtheWorld(16)
root.deiconify()
#Choose length
def selectLength(event):
#Frame contains select buttons
selectframe = Frame(select, bg = "#f2cf8d")
selectframe.pack(fill = BOTH)
#Select text
selectphoto = PhotoImage(file = "images/select/chooseLength.png", master = selectframe)
text = Label(selectframe, image = selectphoto)
text.image = selectphoto #This is really annoying when Python uses its garbage-collector :<
text.grid(row = 0, columnspan = 3)
#Button Butts :>
#Short
buttonphoto1 = PhotoImage(file = "images/select/ButtonShort.png", master = selectframe)
lengthbutton1 = Button(selectframe, image = buttonphoto1)
lengthbutton1.image = buttonphoto1
lengthbutton1.bind("<Button-1>", 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("<Button-1>", 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("<Button-1>", 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("<Button-1>", 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()
Binary file added images/login/Background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/login/PlayButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/login/QuitButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/reward_medals/1st_Reward.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/select/ButtonLong.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/select/ButtonMedium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/select/ButtonShort.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/select/chooseLength.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.