diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..c7dcb25
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,5 @@
+/venv/
+/build/
+/dist/
+/Hangman.spec
+/venv/
\ No newline at end of file
diff --git a/.gitpod.yml b/.gitpod.yml
index b405d59..c139aec 100644
--- a/.gitpod.yml
+++ b/.gitpod.yml
@@ -6,4 +6,4 @@ ports:
onOpen: open-preview
tasks:
- init: pip3 install -r requirements.txt
- command: python3 hangman.py
+ command: python3 __init__.py
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/Hangman.iml b/.idea/Hangman.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/.idea/Hangman.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..caf84e0
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ad267ff
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CLI.py b/CLI.py
new file mode 100644
index 0000000..cfec9ce
--- /dev/null
+++ b/CLI.py
@@ -0,0 +1,4 @@
+from __init__ import main
+
+if __name__ == '__main__':
+ main()
diff --git a/Hangman.ico b/Hangman.ico
new file mode 100644
index 0000000..368d1ea
Binary files /dev/null and b/Hangman.ico differ
diff --git a/hangman.py b/__init__.py
similarity index 79%
rename from hangman.py
rename to __init__.py
index b47fd06..4cef041 100644
--- a/hangman.py
+++ b/__init__.py
@@ -1,186 +1,188 @@
-#########################################################
-## File Name: hangman.py ##
-## Description: Starter for Hangman project - ICS3U ##
-#########################################################
-import pygame
-import random
-
-pygame.init()
-winHeight = 480
-winWidth = 700
-win=pygame.display.set_mode((winWidth,winHeight))
-#---------------------------------------#
-# initialize global variables/constants #
-#---------------------------------------#
-BLACK = (0,0, 0)
-WHITE = (255,255,255)
-RED = (255,0, 0)
-GREEN = (0,255,0)
-BLUE = (0,0,255)
-LIGHT_BLUE = (102,255,255)
-
-btn_font = pygame.font.SysFont("arial", 20)
-guess_font = pygame.font.SysFont("monospace", 24)
-lost_font = pygame.font.SysFont('arial', 45)
-word = ''
-buttons = []
-guessed = []
-hangmanPics = [pygame.image.load('hangman0.png'), pygame.image.load('hangman1.png'), pygame.image.load('hangman2.png'), pygame.image.load('hangman3.png'), pygame.image.load('hangman4.png'), pygame.image.load('hangman5.png'), pygame.image.load('hangman6.png')]
-
-limbs = 0
-
-
-def redraw_game_window():
- global guessed
- global hangmanPics
- global limbs
- win.fill(GREEN)
- # Buttons
- for i in range(len(buttons)):
- if buttons[i][4]:
- pygame.draw.circle(win, BLACK, (buttons[i][1], buttons[i][2]), buttons[i][3])
- pygame.draw.circle(win, buttons[i][0], (buttons[i][1], buttons[i][2]), buttons[i][3] - 2
- )
- label = btn_font.render(chr(buttons[i][5]), 1, BLACK)
- win.blit(label, (buttons[i][1] - (label.get_width() / 2), buttons[i][2] - (label.get_height() / 2)))
-
- spaced = spacedOut(word, guessed)
- label1 = guess_font.render(spaced, 1, BLACK)
- rect = label1.get_rect()
- length = rect[2]
-
- win.blit(label1,(winWidth/2 - length/2, 400))
-
- pic = hangmanPics[limbs]
- win.blit(pic, (winWidth/2 - pic.get_width()/2 + 20, 150))
- pygame.display.update()
-
-
-def randomWord():
- file = open('words.txt')
- f = file.readlines()
- i = random.randrange(0, len(f) - 1)
-
- return f[i][:-1]
-
-
-def hang(guess):
- global word
- if guess.lower() not in word.lower():
- return True
- else:
- return False
-
-
-def spacedOut(word, guessed=[]):
- spacedWord = ''
- guessedLetters = guessed
- for x in range(len(word)):
- if word[x] != ' ':
- spacedWord += '_ '
- for i in range(len(guessedLetters)):
- if word[x].upper() == guessedLetters[i]:
- spacedWord = spacedWord[:-2]
- spacedWord += word[x].upper() + ' '
- elif word[x] == ' ':
- spacedWord += ' '
- return spacedWord
-
-
-def buttonHit(x, y):
- for i in range(len(buttons)):
- if x < buttons[i][1] + 20 and x > buttons[i][1] - 20:
- if y < buttons[i][2] + 20 and y > buttons[i][2] - 20:
- return buttons[i][5]
- return None
-
-
-def end(winner=False):
- global limbs
- lostTxt = 'You Lost, press any key to play again...'
- winTxt = 'WINNER!, press any key to play again...'
- redraw_game_window()
- pygame.time.delay(1000)
- win.fill(GREEN)
-
- if winner == True:
- label = lost_font.render(winTxt, 1, BLACK)
- else:
- label = lost_font.render(lostTxt, 1, BLACK)
-
- wordTxt = lost_font.render(word.upper(), 1, BLACK)
- wordWas = lost_font.render('The phrase was: ', 1, BLACK)
-
- win.blit(wordTxt, (winWidth/2 - wordTxt.get_width()/2, 295))
- win.blit(wordWas, (winWidth/2 - wordWas.get_width()/2, 245))
- win.blit(label, (winWidth / 2 - label.get_width() / 2, 140))
- pygame.display.update()
- again = True
- while again:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- if event.type == pygame.KEYDOWN:
- again = False
- reset()
-
-
-def reset():
- global limbs
- global guessed
- global buttons
- global word
- for i in range(len(buttons)):
- buttons[i][4] = True
-
- limbs = 0
- guessed = []
- word = randomWord()
-
-#MAINLINE
-
-
-# Setup buttons
-increase = round(winWidth / 13)
-for i in range(26):
- if i < 13:
- y = 40
- x = 25 + (increase * i)
- else:
- x = 25 + (increase * (i - 13))
- y = 85
- buttons.append([LIGHT_BLUE, x, y, 20, True, 65 + i])
- # buttons.append([color, x_pos, y_pos, radius, visible, char])
-
-word = randomWord()
-inPlay = True
-
-while inPlay:
- redraw_game_window()
- pygame.time.delay(10)
-
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- inPlay = False
- if event.type == pygame.KEYDOWN:
- if event.key == pygame.K_ESCAPE:
- inPlay = False
- if event.type == pygame.MOUSEBUTTONDOWN:
- clickPos = pygame.mouse.get_pos()
- letter = buttonHit(clickPos[0], clickPos[1])
- if letter != None:
- guessed.append(chr(letter))
- buttons[letter - 65][4] = False
- if hang(chr(letter)):
- if limbs != 5:
- limbs += 1
- else:
- end()
- else:
- print(spacedOut(word, guessed))
- if spacedOut(word, guessed).count('_') == 0:
- end(True)
-
-pygame.quit()
-
-# always quit pygame when done!
+#########################################################
+## File Name: __init__.py ##
+## Description: Starter for Hangman project - ICS3U ##
+#########################################################
+import pygame
+import random
+
+pygame.init()
+winHeight = 480
+winWidth = 700
+win=pygame.display.set_mode((winWidth,winHeight))
+#---------------------------------------#
+# initialize global variables/constants #
+#---------------------------------------#
+BLACK = (0,0, 0)
+WHITE = (255,255,255)
+RED = (255,0, 0)
+GREEN = (0,255,0)
+BLUE = (0,0,255)
+LIGHT_BLUE = (102,255,255)
+
+btn_font = pygame.font.SysFont("arial", 20)
+guess_font = pygame.font.SysFont("monospace", 24)
+lost_font = pygame.font.SysFont('arial', 45)
+word = ''
+buttons = []
+guessed = []
+hangmanPics = [pygame.image.load('hangman0.png'), pygame.image.load('hangman1.png'), pygame.image.load('hangman2.png'), pygame.image.load('hangman3.png'), pygame.image.load('hangman4.png'), pygame.image.load('hangman5.png'), pygame.image.load('hangman6.png')]
+
+limbs = 0
+
+
+def redraw_game_window():
+ global guessed
+ global hangmanPics
+ global limbs
+ win.fill(GREEN)
+ # Buttons
+ for i in range(len(buttons)):
+ if buttons[i][4]:
+ pygame.draw.circle(win, BLACK, (buttons[i][1], buttons[i][2]), buttons[i][3])
+ pygame.draw.circle(win, buttons[i][0], (buttons[i][1], buttons[i][2]), buttons[i][3] - 2
+ )
+ label = btn_font.render(chr(buttons[i][5]), 1, BLACK)
+ win.blit(label, (buttons[i][1] - (label.get_width() / 2), buttons[i][2] - (label.get_height() / 2)))
+
+ spaced = spacedOut(word, guessed)
+ label1 = guess_font.render(spaced, 1, BLACK)
+ rect = label1.get_rect()
+ length = rect[2]
+
+ win.blit(label1,(winWidth/2 - length/2, 400))
+
+ pic = hangmanPics[limbs]
+ win.blit(pic, (winWidth/2 - pic.get_width()/2 + 20, 150))
+ pygame.display.update()
+
+
+def randomWord():
+ file = open('words.txt')
+ f = file.readlines()
+ i = random.randrange(0, len(f) - 1)
+
+ return f[i][:-1]
+
+
+def hang(guess):
+ global word
+ if guess.lower() not in word.lower():
+ return True
+ else:
+ return False
+
+
+def spacedOut(word, guessed=[]):
+ spacedWord = ''
+ guessedLetters = guessed
+ for x in range(len(word)):
+ if word[x] != ' ':
+ spacedWord += '_ '
+ for i in range(len(guessedLetters)):
+ if word[x].upper() == guessedLetters[i]:
+ spacedWord = spacedWord[:-2]
+ spacedWord += word[x].upper() + ' '
+ elif word[x] == ' ':
+ spacedWord += ' '
+ return spacedWord
+
+
+def buttonHit(x, y):
+ for i in range(len(buttons)):
+ if x < buttons[i][1] + 20 and x > buttons[i][1] - 20:
+ if y < buttons[i][2] + 20 and y > buttons[i][2] - 20:
+ return buttons[i][5]
+ return None
+
+
+def end(winner=False):
+ global limbs
+ lostTxt = 'You Lost, press any key to play again...'
+ winTxt = 'WINNER!, press any key to play again...'
+ redraw_game_window()
+ pygame.time.delay(1000)
+ win.fill(GREEN)
+
+ if winner == True:
+ label = lost_font.render(winTxt, 1, BLACK)
+ else:
+ label = lost_font.render(lostTxt, 1, BLACK)
+
+ wordTxt = lost_font.render(word.upper(), 1, BLACK)
+ wordWas = lost_font.render('The phrase was: ', 1, BLACK)
+
+ win.blit(wordTxt, (winWidth/2 - wordTxt.get_width()/2, 295))
+ win.blit(wordWas, (winWidth/2 - wordWas.get_width()/2, 245))
+ win.blit(label, (winWidth / 2 - label.get_width() / 2, 140))
+ pygame.display.update()
+ again = True
+ while again:
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ pygame.quit()
+ if event.type == pygame.KEYDOWN:
+ again = False
+ reset()
+
+
+def reset():
+ global limbs
+ global guessed
+ global buttons
+ global word
+ for i in range(len(buttons)):
+ buttons[i][4] = True
+
+ limbs = 0
+ guessed = []
+ word = randomWord()
+
+#MAINLINE
+
+
+# Setup buttons
+increase = round(winWidth / 13)
+for i in range(26):
+ if i < 13:
+ y = 40
+ x = 25 + (increase * i)
+ else:
+ x = 25 + (increase * (i - 13))
+ y = 85
+ buttons.append([LIGHT_BLUE, x, y, 20, True, 65 + i])
+ # buttons.append([color, x_pos, y_pos, radius, visible, char])
+
+def main():
+ global limbs
+ word = randomWord()
+ inPlay = True
+
+ while inPlay:
+ redraw_game_window()
+ pygame.time.delay(10)
+
+ for event in pygame.event.get():
+ if event.type == pygame.QUIT:
+ inPlay = False
+ if event.type == pygame.KEYDOWN:
+ if event.key == pygame.K_ESCAPE:
+ inPlay = False
+ if event.type == pygame.MOUSEBUTTONDOWN:
+ clickPos = pygame.mouse.get_pos()
+ letter = buttonHit(clickPos[0], clickPos[1])
+ if letter is not None:
+ guessed.append(chr(letter))
+ buttons[letter - 65][4] = False
+ if hang(chr(letter)):
+ if limbs != 5:
+ limbs += 1
+ else:
+ end()
+ else:
+ print(spacedOut(word, guessed))
+ if spacedOut(word, guessed).count('_') == 0:
+ end(True)
+
+ pygame.quit()
+
+# always quit pygame when done!
diff --git a/__pycache__/CLI.cpython-39.pyc b/__pycache__/CLI.cpython-39.pyc
new file mode 100644
index 0000000..32aeabc
Binary files /dev/null and b/__pycache__/CLI.cpython-39.pyc differ
diff --git a/__pycache__/__init__.cpython-39.pyc b/__pycache__/__init__.cpython-39.pyc
new file mode 100644
index 0000000..4fc0a90
Binary files /dev/null and b/__pycache__/__init__.cpython-39.pyc differ
diff --git a/words.txt b/words.txt
index 882e17e..6a1aa64 100644
--- a/words.txt
+++ b/words.txt
@@ -1,4 +1,3 @@
-the big bang
the pillow feels soft
odd one out
press conference
@@ -8,4 +7,866 @@ that was easy
hangman is cool
zoologist
quadruplets
-the sky is blue
\ No newline at end of file
+the sky is blue
+payday
+goat
+fracking
+car
+save a horse ride a cowboy
+home sweet home
+weed is bad
+dont do drugs kidsthe big bang
+able
+about
+account
+acid
+across
+act
+addition
+adjustment
+advertisement
+after
+again
+against
+agreement
+air
+all
+almost
+among
+amount
+amusement
+and
+angle
+angry
+animal
+answer
+ant
+any
+apparatus
+apple
+approval
+arch
+argument
+arm
+army
+art
+as
+at
+attack
+attempt
+attention
+attraction
+authority
+automatic
+awake
+baby
+back
+bad
+bag
+balance
+ball
+band
+base
+basin
+basket
+bath
+be
+beautiful
+because
+bed
+bee
+before
+behaviour
+belief
+bell
+bent
+berry
+between
+bird
+birth
+bit
+bite
+bitter
+black
+blade
+blood
+blow
+blue
+board
+boat
+body
+boiling
+bone
+book
+boot
+bottle
+box
+boy
+brain
+brake
+branch
+brass
+bread
+breath
+brick
+bridge
+bright
+broken
+brother
+brown
+brush
+bucket
+building
+bulb
+burn
+burst
+business
+but
+butter
+button
+by
+cake
+camera
+canvas
+card
+care
+carriage
+cart
+cat
+cause
+certain
+chain
+chalk
+chance
+change
+cheap
+cheese
+chemical
+chest
+chief
+chin
+church
+circle
+clean
+clear
+clock
+cloth
+cloud
+coal
+coat
+cold
+collar
+colour
+comb
+come
+comfort
+committee
+common
+company
+comparison
+competition
+complete
+complex
+condition
+connection
+conscious
+control
+cook
+copper
+copy
+cord
+cork
+cotton
+cough
+country
+cover
+cow
+crack
+credit
+crime
+cruel
+crush
+cry
+cup
+cup
+current
+curtain
+curve
+cushion
+damage
+danger
+dark
+daughter
+day
+dead
+dear
+death
+debt
+decision
+deep
+degree
+delicate
+dependent
+design
+desire
+destruction
+detail
+development
+different
+digestion
+direction
+dirty
+discovery
+discussion
+disease
+disgust
+distance
+distribution
+division
+do
+dog
+door
+doubt
+down
+drain
+drawer
+dress
+drink
+driving
+drop
+dry
+dust
+ear
+early
+earth
+east
+edge
+education
+effect
+egg
+elastic
+electric
+end
+engine
+enough
+equal
+error
+even
+event
+ever
+every
+example
+exchange
+existence
+expansion
+experience
+expert
+eye
+face
+fact
+fall
+false
+family
+far
+farm
+fat
+father
+fear
+feather
+feeble
+feeling
+female
+fertile
+fiction
+field
+fight
+finger
+fire
+first
+fish
+fixed
+flag
+flame
+flat
+flight
+floor
+flower
+fly
+fold
+food
+foolish
+foot
+for
+force
+fork
+form
+forward
+fowl
+frame
+free
+frequent
+friend
+from
+front
+fruit
+full
+future
+garden
+general
+get
+girl
+give
+glass
+glove
+go
+goat
+gold
+good
+government
+grain
+grass
+great
+green
+grey
+grip
+group
+growth
+guide
+gun
+hair
+hammer
+hand
+hanging
+happy
+harbour
+hard
+harmony
+hat
+hate
+have
+he
+head
+healthy
+hear
+hearing
+heart
+heat
+help
+high
+history
+hole
+hollow
+hook
+hope
+horn
+horse
+hospital
+hour
+house
+how
+humour
+I
+ice
+idea
+if
+ill
+important
+impulse
+in
+increase
+industry
+ink
+insect
+instrument
+insurance
+interest
+invention
+iron
+island
+jelly
+jewel
+join
+journey
+judge
+jump
+keep
+kettle
+key
+kick
+kind
+kiss
+knee
+knife
+knot
+knowledge
+land
+language
+last
+late
+laugh
+law
+lead
+leaf
+learning
+leather
+left
+leg
+let
+letter
+level
+library
+lift
+light
+like
+limit
+line
+linen
+lip
+liquid
+list
+little
+living
+lock
+long
+look
+loose
+loss
+loud
+love
+low
+machine
+make
+male
+man
+manager
+map
+mark
+market
+married
+mass
+match
+material
+may
+meal
+measure
+meat
+medical
+meeting
+memory
+metal
+middle
+military
+milk
+mind
+mine
+minute
+mist
+mixed
+money
+monkey
+month
+moon
+morning
+mother
+motion
+mountain
+mouth
+move
+much
+muscle
+music
+nail
+name
+narrow
+nation
+natural
+near
+necessary
+neck
+need
+needle
+nerve
+net
+new
+news
+night
+no
+noise
+normal
+north
+nose
+not
+note
+now
+number
+nut
+observation
+of
+off
+offer
+office
+oil
+old
+on
+only
+open
+operation
+opinion
+opposite
+or
+orange
+order
+organization
+ornament
+other
+out
+oven
+over
+owner
+page
+pain
+paint
+paper
+parallel
+parcel
+part
+past
+paste
+payment
+peace
+pen
+pencil
+person
+physical
+picture
+pig
+pin
+pipe
+place
+plane
+plant
+plate
+play
+please
+pleasure
+plough
+pocket
+point
+poison
+polish
+political
+poor
+porter
+position
+possible
+pot
+potato
+powder
+power
+present
+price
+print
+prison
+private
+probable
+process
+produce
+profit
+property
+prose
+protest
+public
+pull
+pump
+punishment
+purpose
+push
+put
+quality
+question
+quick
+quiet
+quite
+rail
+rain
+range
+rat
+rate
+ray
+reaction
+reading
+ready
+reason
+receipt
+record
+red
+regret
+regular
+relation
+religion
+representative
+request
+respect
+responsible
+rest
+reward
+rhythm
+rice
+right
+ring
+river
+road
+rod
+roll
+roof
+room
+root
+rough
+round
+rub
+rule
+run
+sad
+safe
+sail
+salt
+same
+sand
+say
+scale
+school
+science
+scissors
+screw
+sea
+seat
+second
+secret
+secretary
+see
+seed
+seem
+selection
+self
+send
+sense
+separate
+serious
+servant
+sex
+shade
+shake
+shame
+sharp
+sheep
+shelf
+ship
+shirt
+shock
+shoe
+short
+shut
+side
+sign
+silk
+silver
+simple
+sister
+size
+skin
+
+skirt
+sky
+sleep
+slip
+slope
+slow
+small
+smash
+smell
+smile
+smoke
+smooth
+snake
+sneeze
+snow
+so
+soap
+society
+sock
+soft
+solid
+some
+
+son
+song
+sort
+sound
+soup
+south
+space
+spade
+special
+sponge
+spoon
+spring
+square
+stage
+stamp
+star
+start
+statement
+station
+steam
+steel
+stem
+step
+stick
+sticky
+stiff
+still
+stitch
+stocking
+stomach
+stone
+stop
+store
+story
+straight
+strange
+street
+stretch
+strong
+structure
+substance
+such
+sudden
+sugar
+suggestion
+summer
+sun
+support
+surprise
+sweet
+swim
+system
+table
+tail
+take
+talk
+tall
+taste
+tax
+teaching
+tendency
+test
+than
+that
+the
+then
+theory
+there
+thick
+thin
+thing
+this
+thought
+thread
+throat
+through
+through
+thumb
+thunder
+ticket
+tight
+till
+time
+tin
+tired
+to
+toe
+together
+tomorrow
+tongue
+tooth
+top
+touch
+town
+trade
+train
+transport
+tray
+tree
+trick
+trouble
+trousers
+true
+turn
+twist
+umbrella
+under
+unit
+up
+use
+value
+verse
+very
+vessel
+view
+violent
+voice
+waiting
+walk
+wall
+war
+warm
+wash
+waste
+watch
+water
+wave
+wax
+way
+weather
+week
+weight
+well
+west
+wet
+wheel
+when
+where
+while
+whip
+whistle
+white
+who
+why
+wide
+will
+wind
+window
+wine
+wing
+winter
+wire
+wise
+with
+woman
+wood
+wool
+word
+work
+worm
+wound
+writing
+wrong
+year
+yellow
+yes
+yesterday
+you
+young
+Bernhard
+Breytenbach
+Android
\ No newline at end of file