' HANGMAN
'
' Johnno56 15-Dec-16
' (sdlbasic version)
'
' 07-Oct-20 QB64 w/mouse bplus cut some lines of code
'
xmax = 1024
ymax = 768
words = 295
'DIM SHARED choose AS INTEGER
a$ = ""
'
' Load graphics
'
gallowsbase
= _LOADIMAGE("assets/base-closed.png")
'
' Load audio
'
ropestretch
= _SNDOPEN("assets/rope.wav")
music
= _SNDOPEN("assets/goodbadugly.wav")
'
' Load Fonts
'
font35
= _LOADFONT("assets/rubicmono.ttf", 35)font50
= _LOADFONT("assets/rubicmono.ttf", 50)
' select word from array (or external file?)
filename$ = "assets/words.txt"
count = 1
INPUT #1, wordlist$
(count
) count = count + 1
again = 1
i = 0.1
'
' Title screen - here
'
'
' Start game loop here
'
wordtoguess$
= wordlist$
(INT(RND * (count
- 1))) 'print wordtoguess$
numberoftries = 0
letter(x) = 0
'
' Display empty word and letter grid
'
LINE (460 + (dash
* 50), 380)-STEP(40, 4), black
, BF
counter = 0
'
' Letter guess routine - try for mouse input?
'
' Clear "chosen" array
'
chosen(x) = 0
foundletter = 0
'
' Keyboard (or mouse) selection of letters to guess
'
'_MOUSESHOW
choose = 0
'
' Mouse "cursor"?
'BEEP
test
= INT((mx
- 44) / 36) + 1 'LOCATE 11, 5: PRINT test
'_DISPLAY
choose = 96 + test
' Check Keypress if not mouse
' Handle choose
IF chosen
(choose
- 96) = 0 THEN chosen(choose - 96) = 1
_PUTIMAGE ((choose
- 96) * 36 + 8, 700), guessed
' Escape to quit?
'
' Correct letter routine
'
counter = counter + 1
foundletter = 1
'
' Not so correct letter routine
'
numberoftries = numberoftries + 1
'
' Build gallows routine?
'
letter
(ASC(a$
) - 64) = -1
'
' Check for finished game?
'
IF counter
= LEN(wordtoguess$
) OR numberoftries
= 10 THEN
'
' Winner routine
'
playagain
a$ = ""
a$ = ""
'
' Loser routine
'
playagain
a$ = ""
a$ = ""
a$ = ""
yn = 0
' LOCATE 1, 1: PRINT mx
' LOCATE 2, 1: PRINT my
' LOCATE 3, 1: PRINT mb
'_PRINTSTRING (250, 650), "Again Y or N"
a$ = "Y"
chosen(x) = 0
choose = 0
a$ = "N"