Skip to content

Commit

Permalink
packaged script into standalone executable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nytra committed Apr 25, 2020
1 parent f374e48 commit f6a6904
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions turtle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import string, pygame, sys, os, time, random
from pygame.locals import *
pygame.init()
#pygame.init()

WHITE = 255, 255, 255
GREY = 64, 64, 64
Expand All @@ -14,7 +14,7 @@
SCREEN_HEIGHT = 600
TURTLE_ACTION_INTERVAL = 0 # time in ms between actions
TURTLE_PEN_COLOURS = RED, GREEN, BLUE
TURTLE_SIZE_DEFAULT = 20
TURTLE_SIZE_DEFAULT = 10
TURTLE_MOVE_SPEED_DEFAULT = TURTLE_SIZE_DEFAULT
TURTLE_PERFORM_CURRENT_DIRECTORY = True # perform all TurtleScript files in the current (relative) directory
TURTLE_RANDOM_DIST_MAX = 10
Expand Down Expand Up @@ -236,7 +236,7 @@ def display():
FPS = 24
pygameQuit = False
timerStart = pygame.time.get_ticks()
hasDoneInitialPause = False
hasDoneInitialPause = True
#initialDelay = 1000 # specify delay to add when program starts. before turtle starts performing actions

while not pygameQuit:
Expand Down Expand Up @@ -266,6 +266,8 @@ def display():
clock.tick(FPS)

pygame.quit()
#screen.quit()
#screen.close()

def _generateTurtleScriptFile(numActions):
fileName = "gen" + str(int(time.time())) + ".tsf"
Expand Down Expand Up @@ -304,7 +306,6 @@ def waitForValidFileName():
print("error: that file does not exist in the current directory")
return inp

pygame.display.set_caption("TurtleScript Drawing Program")

flags = HWSURFACE | DOUBLEBUF
bpp = 16
Expand All @@ -317,16 +318,19 @@ def waitForValidFileName():
"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",
"Quit"
]

screen = None
choice = None
quitGame = 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 choice == None:
while not quitGame:
choice = waitForValidIntInput("Choose an option: ")

if choice != None and choice in list(range(1, len(options) + 1)):
Expand Down Expand Up @@ -357,7 +361,15 @@ def waitForValidFileName():
turtles = [Turtle(genFile),]
elif choice == 4:
turtles = [Turtle(), ]
elif choice == 5:
pygame.quit()
#sys.exit()
quitGame = True

if not quitGame:
pygame.init()
pygame.display.set_caption("TurtleScript Drawing Program")
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), flags, bpp)
screenBuffer = []

screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), flags, bpp)

display()
display()

0 comments on commit f6a6904

Please sign in to comment.