Skip to content

Commit

Permalink
added options for setting turtle size and game frame-rate
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra committed Apr 25, 2020
1 parent e8ed967 commit 9b8723a
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ def doNext(self):


def display():
FPS = 24
pygameQuit = False
timerStart = pygame.time.get_ticks()
hasDoneInitialPause = True
Expand Down Expand Up @@ -273,7 +272,7 @@ def display():

pygame.display.update()

clock.tick(FPS)
clock.tick(frameRate)

pygame.quit()
#screen.quit()
Expand Down Expand Up @@ -321,26 +320,31 @@ def waitForValidFileName():
bpp = 16

clock = pygame.time.Clock()
frameRate = 120

turtles = []
screenBuffer = []
options = [
"Perform a specific TurtleScript file",
"Perform all TurtleScript files in the current directory (simultaneously)",
"Generate a random TurtleScript file",
"Endless random Turtle",
"Endless random turtle",
"Set frame-rate",
"Set turtle size",
"Quit"
]

screen = None
choice = None
quitGame = False
start = False
print("Welcome to TurtleScript Drawing Program!")
print("\nWhat would you like to do?")
for i in range(len(options)):
print(i+1, ")", options[i])

while not quitGame:
start = True
choice = waitForValidIntInput("Choose an option: ")

if choice != None and choice in list(range(1, len(options) + 1)):
Expand All @@ -355,20 +359,23 @@ def waitForValidFileName():
if not os.path.exists(fileName):
print("error: that file does not exist")
fileName = None
else:
turtles.append(Turtle(fileName))
else:
turtles.append(Turtle(fileName))

elif choice == 2:
fileNames = os.listdir(os.path.abspath(""))
for fileName in fileNames:
if fileName.endswith(".tsf"):
turtles.append(Turtle(fileName))

elif choice == 3:
numActions = waitForValidIntInput("How many actions?: ")
if numActions <= 0:
print("error: please enter a positive number")
else:
genFile = _generateTurtleScriptFile(numActions)
turtles = [Turtle(genFile),]

elif choice == 4:
turtles = [Turtle(), ]
changeColourOnCollision = None
Expand All @@ -389,11 +396,20 @@ def waitForValidFileName():
turtles[0].changeColourOnCollisionMode = mode

elif choice == 5:
# set fps
frameRate = waitForValidIntInput("Frame-rate: ", forcePositive=True)
start = False
elif choice == 6:
# set size
TURTLE_SIZE_DEFAULT = waitForValidIntInput("Turtle size: ", forcePositive=True)
#TURTLE_MOVE_SPEED_DEFAULT = TURTLE_SIZE_DEFAULT
start = False
elif choice == 7:
pygame.quit()
#sys.exit()
quitGame = True

if not quitGame:
if not quitGame and start == True:
pygame.init()
pygame.display.set_caption("TurtleScript Drawing Program")
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), flags, bpp)
Expand Down

0 comments on commit 9b8723a

Please sign in to comment.