0ÿÿÿ±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3= keyboardkey[i].x and mx <= keyboardkey[i].x + 9 and my >= keyboardkey[i].y and my <= keyboardkey[i].y + 11 then --print("pressed " .. keyboardkey[i][1],10,10,1) rect(keyboardkey[i].x,keyboardkey[i].y,10,12,1) --print(keyboardkey[i].x,1,1,1) CheckLetter(keyboardkey[i][1]) sfx(0,"B-7",5) mouseDown = true end end end else mouseDown = false end end function GetKeyboardPos() keyboardkey = {q ={x = firstPixelOfKeyBoardRow1,y = 84,"Q"}, w = {x = firstPixelOfKeyBoardRow1 + 12,y = 84,"W"}, e ={x = firstPixelOfKeyBoardRow1 + (12*2),y = 84,"E"}, r ={x = firstPixelOfKeyBoardRow1 + (12*3),y = 84,"R"}, t ={x = firstPixelOfKeyBoardRow1 + (12*4)+1,y = 84,"T"}, y ={x = firstPixelOfKeyBoardRow1 + (12*5)+1,y = 84,"Y"}, u ={x = firstPixelOfKeyBoardRow1 + (12*6),y = 84,"U"}, i ={x = firstPixelOfKeyBoardRow1 + (12*7) +1,y = 84,"I"}, o ={x = firstPixelOfKeyBoardRow1 + (12*8),y = 84,"O"}, p ={x = firstPixelOfKeyBoardRow1 + (12*9),y = 84,"P"}, a ={x = firstPixelOfKeyBoardRow2,y = 99,"A"}, s ={x = firstPixelOfKeyBoardRow2 + 12,y = 99,"S"}, d ={x = firstPixelOfKeyBoardRow2 + (12*2),y = 99,"D"}, f ={x = firstPixelOfKeyBoardRow2 + (12*3),y = 99,"F"}, g ={x = firstPixelOfKeyBoardRow2 + (12*4),y = 99,"G"}, h ={x = firstPixelOfKeyBoardRow2 + (12*5),y = 99,"H"}, j ={x = firstPixelOfKeyBoardRow2 + (12*6),y = 99,"J"}, k ={x = firstPixelOfKeyBoardRow2 + (12*7),y = 99,"K"}, l ={x = firstPixelOfKeyBoardRow2 + (12*8),y = 99,"L"}, z ={x = firstPixelOfKeyBoardRow3,y = 114,"Z"}, x ={x = firstPixelOfKeyBoardRow3 + 12,y = 114,"X"}, c ={x = firstPixelOfKeyBoardRow3 + (12*2),y = 114,"C"}, v ={x = firstPixelOfKeyBoardRow3 + (12*3),y = 114,"V"}, b ={x = firstPixelOfKeyBoardRow3 + (12*4),y = 114,"B"}, n ={x = firstPixelOfKeyBoardRow3 + (12*5),y = 114,"N"}, m ={x = firstPixelOfKeyBoardRow3 + (12*6),y = 114,"M"} } end function PrintKeyBoxes() for i, v in pairs(keyboardkey) do rectb(keyboardkey[i].x,keyboardkey[i].y,10,12,1) end end function DisplayWord() yinc = 0 xinc = 0 for i =1,#wordselected,1 do --print(wordselected[i],160 + xinc ,50 + yinc,1,0,1) line(160 + xinc -2,58 + yinc,160 + xinc + 6,58 + yinc,1 ) xinc = xinc + 12 end --xinc = 0 end function SelectWord() local randomWord = math.random(1,#Word) wordselected = Word[randomWord] selectedWordIndex = randomWord end function CheckLetter(_letter) local xI = 12 --print(_letter,10,20,1) --checks if has correct letter in the word and displays it for i=1,#wordselected,1 do if _letter == wordselected[i] then if #printedLetters == 0 then table.insert(printedLetters,{wordselected[i],160 + (i*xI ) -12,50}) sfx(1,"A-4",5,1) return end if #printedLetters > 0 then for r=1,#printedLetters,1 do if printedLetters[r][1] == _letter then return end end end sfx(1,"A-4",5,1) table.insert(printedLetters,{wordselected[i],160 + (i*xI) -12,50}) return end --return end sfx(0,"C-2",5,1) error = error + 1 end function DisplayCorrectLetter() if #printedLetters > 0 then for i=1,#printedLetters,1 do print(printedLetters[i][1],printedLetters[i][2],printedLetters[i][3],1,0,1) end end end function CheckIfWordIsComplete() if #printedLetters > 0 then --print(#printedLetters, 120, 80,1,0,4) end if #printedLetters >= #wordselected then wonGame = true print("Win", 120, 60,1,0,4) end end function SelectedKey(_key) rect(_key.x,_key.y,10,12,1) end function ErrorCheck() if error >= 6 then print("Lose", 120, 60,1,0,4) loseGame = true end end function MakeHangMan() if error >= 1 then DrawHead() end if error >= 2 then DrawBody() end if error >= 3 then DrawLeg(150,144,50,56) end if error >= 4 then DrawLeg(150,156,50,56) end if error >= 5 then DrawArm(150,144,45,45) end if error >= 6 then DrawArm(150,156,45,45) end end function table.contains(table, element) for _, value in pairs(table) do if value == element then return true end end return false end function Menu() music() local textW = print("Words Completed",0,-22,1,0,1) print("Words Completed", (239 - textW)//2,10,1,0,1) local textW = print(10 - #Word.."/".."10",0,-22,1,0,1) print(10 - #Word.."/".."10", (239 - textW)//2,20,1,0,1) local textW = print("Hang That Man",0,-22,1,0,2) print("Hang That Man", (239 - textW)//2, 60,1,0,2) local textW = print("Click To Play",0,-22,1,0,1) print("Click To Play", (239 - textW)//2, 120,1,0,1) mx,my,md=mouse() if md then if mouseDown == false then menu = false sfx(3,"C-4",50) mouseDown = true end else mouseDown = false end end winMusic = false function WinScreen() local spacing = 15 local backSpaces = #wordselected * 6 for i =1,#wordselected,1 do line(100 + spacing - backSpaces,35,100 + spacing - backSpaces + 8,35,1) print(wordselected[i],100+spacing - backSpaces,20,1,0,2) spacing = spacing + 15 end local textW = print("Win",0,-22,1,0,4) print("Win", (239 - textW)//2, 60,1,0,4) if winMusic == false then music(0,-1,-1,false) winMusic = true end mx,my,md=mouse() if md then if mouseDown == false then ResetGame() table.remove(Word,selectedWordIndex) table.remove(Hint,selectedWordIndex) if #Word == 0 then finished = true end sfx(3,"C-4",50) mouseDown = true end else mouseDown = false end local textW = print("Click To Restart",0,-22,1,0,1) print("Click To Restart", (239 - textW)//2, 120,1,0,1) end loseMusic = false function LoseScreen() local textW = print("Lose",0,-22,1,0,4) print("Lose", (239 - textW)//2, 100,1,0,4) if loseMusic == false then music(1,-1,-1,false) loseMusic = true end mx,my,md=mouse() if md then if mouseDown == false then ResetGame() -- sfx(3,"C-4",50) mouseDown = true end else mouseDown = false end local textW = print("Click To Restart",0,-22,1,0,1) print("Click To Restart", (239 - textW)//2, 125,1,0,1) end function ResetGame() winMusic = false loseMusic = false endMusic = false menu = true loseGame = false wonGame = false lettersCorrect = {} -- printed letters printedLetters = {} --the selected word for the game wordselected = {} chosenWord = false error = 0 end endMusic = false function End() if endMusic == false then music(2,-1,-1,false) endMusic = true end local textW = print(10 - #Word.."/".."10",0,-22,1,0,1) print(10 - #Word.."/".."10", (239 - textW)//2,20,1,0,1) local textW = print("END",0,-22,1,0,2) print("END", (239 - textW)//2,80,1,0,2) end