Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / hamgman again

Author
Message
hangman again
17
Years of Service
User Offline
Joined: 21st Feb 2007
Location: lost with this
Posted: 22nd Feb 2007 23:09
First of all i must say hats off to TDK man. I had problems before and he helped a great deal and provided me the link to this site. I
I am very new to this programming language but a am trying with this hangman game. Yes i saw and read and read every single
post already(more than once). I saw everyone who has a problem is stuck with displaying the body parts. I am also and i have attached the code i am using. In the forum i saw an modified version which incoprorated all the body parts using the select function, where am i going wrong with this version wih regard to displaying the body parts. I have the head displayed with the wrong letter guessed and i am trying to get the body, them hopefully when i take out the remstart and remend command the rest works

startofprogram:
error = 0
yes = 0
rem to clear the screen
cls

rem create a 13 element array to named number
dim words$(12)

rem to load the array elements
words$(0) = "cat"
words$(1) = "bat"
words$(2) = "rat"
words$(3) = "fat"
words$(4) = "come"
words$(5) = "gone"
words$(6) = "fear"
words$(7) = "baby"
words$(8) = "love"
words$(9) = "store"
words$(10) = "score"
words$(11) = "drive"
words$(12) = "blast"

rem to ramdomly select an item from the words$ array
randomize timer()
num = rnd(9)

rem to pass the random number to a variable
gwords$ = words$(num)


rem to get the length of the item selected and pass it to a variable
li = len(gwords$)
if li = 3
threespace()
else
if li = 4
fourspace()
else
if li = 5
fivespace()
else
endif
endif
endif

rem create array to contain letters of word selected and this prints the word selected
dim wordcontent$(li)
for c = 1 to li
wordcontent$(c) = mid$(gwords$,c)
print wordcontent$(c)
next c

rem the functions below will run the program
title()
gallows()

rem set starting point for x coordinate
x = 110

rem text to screen to display how to quit
text 0,440, "Press qq to quit"
rem get input from user
input "Guess",guess$

rem quit the program when qq or more letters are selected
while guess$ <> "qq"


rem start nested for/next loop
rem determine if the letter guessed is in the word
for c = 1 to li
if guess$ = wordcontent$(c) and c = 1
text 120,377,guess$
yes = yes + 1
else
if guess$ = wordcontent$(c) and c = 2
text 220,377,guess$
yes = yes + 1
else
if guess$ = wordcontent$(c) and c = 3
text 320,377,guess$
yes = yes + 1
else
if guess$ = wordcontent$(c) and c = 4
text 420,377,guess$
yes = yes + 1
else
if guess$ = wordcontent$(c) and c = 5
text 520,377,guess$
yes = yes + 1
else
endif
endif
endif
endif
endif
next c


if guess$ <> wordcontent$(c)
head()
else
body()
endif

rem call the appropiate function when the variable equals the guessed word
if yes = li
youwin()
else
endif

rem input another guess word
input "Guess",guess$


endwhile

rem to use command to separate functions from declarations
end


head()
body()
remstart
lreg()
lleg()
rarm()
larm()

remend
threeSpace()
fourSpace()
fiveSpace()

REM TO ASSIGN DECLARATIONS FOR RESPECTIVE FUNCTION
function title()
set text font "Comic Sans Ms"
set text size 40
ink rgb(0,255,0),0
text 120,40, "Welcome to Hang-Man "
ink rgb(255,0,0),0
text 122,42, "Welcome to Hang-Man"
set text size normal
ink rgb(0,255,0),0
endfunction

function gallows()
line 200,100,200,250
line 200,100,300,100
line 300,100,300,125
endfunction


function head()
circle 300,135,10

endfunction

function body()
line 300,146,300, 180

endfunction
remstart
function lreg()
line 300,180,315,200
wait key
endfunction

function lleg()
line 300,180,285,200
wait key
endfunction

function rarm()
line 300,155,310, 170
wait key
endfunction

function larm()
line 300,155,290,170
wait key
endfunction

remend
function threeSpace()
line 100,400,150,400
line 200,400,250,400
line 300,400,350,400
endfunction

function fourSpace()
line 100,400,150,400
line 200,400,250,400
line 300,400,350,400
line 400,400,450,400
endfunction

function fiveSpace()
line 100,400,150,400
line 200,400,250,400
line 300,400,350,400
line 400,400,450,400
line 500,400,550,400
endfunction

rem the win function
function youwin()
cls
for w = 1 to 30
sleep 20
text rnd(400), rnd(400), "This program is getting hard!!!"
next w
endfunction

rem stop the program until a key is pressed
wait key

rem to end the program
end
Silvester
18
Years of Service
User Offline
Joined: 7th Dec 2005
Location: Netherlands
Posted: 23rd Feb 2007 20:03
ever heard of a codebox?

[ code ] code here [ \code]

without the spaces.

Login to post a reply

Server time is: 2024-11-23 00:39:31
Your offset time is: 2024-11-23 00:39:31