TGC Codebase Backup



HangMan by Cerberus

27th Jan 2004 20:31
Summary

A hangman program with a few diferences



Description

Instead of having a hanged man the main screen shows 10 shields, when these are all gone the game is over.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    set display mode 1024,768,32
cls 0

randomize rnd(10000)
name=20
dim letter$(40)
dim Ltr$(40)
dim name$(name)
set text size 48
load bitmap "front.bmp",1
load bitmap "win.bmp",2
load bitmap "lose.bmp",3
copy bitmap 1,0
ok:
set text size 48
set current bitmap 0
check=1
for f=0 to 40
letter$(f)=""
ltr$(f)=""
next f
l=0
ink rgb(255,255,0),0
m=0
restore

for f=0 to name-1
read name$(f)
next f

sc=0
x=20:y=600
goes=0
ll:
aa$=""
nme=name-1
nm=rnd(nme)
nme$=lower$(name$(nm))
lname=len(nme$)
 for f=1 to lname
letter$(f-1)=mid$(nme$,f)
ltr$(f-1)="*"
next f
set text size 48
hide mouse
goes=0
xx=0
for p=1 to lname
aa$=aa$+upper$(ltr$(p-1))
`center text x,y,upper$(ltr$(p-1))
`x=x+20
next p
text x,y,aa$


do
set cursor 10,320
input "Type in a letter and press enter - ";a$
aa$=""
check=1
inc goes
if a$<>""
ink rgb(0,0,0),0
box 10,315,410,345
ink rgb(255,255,0),0
endif

for f=1 to lname
if a$=letter$(f-1)
ltr$(f-1)=a$
letter$(f-1)="*"
ink rgb(0,0,00),0
box 0,590,600,640
ink rgb(255,255,0),0
aa$=""
for p=1 to lname
aa$=aa$+upper$(ltr$(p-1))
next p

text x,y,aa$+" "
inc l

if check>0
if goes>0
dec goes
dec check
endif
endif

endif
next f

if l=lname
gosub welldone
wait key
copy bitmap 1,0
ink rgb(0,0,00),0
box 0,590,600,640
ink rgb(255,255,0),0
goto ok
endif
gosub draw
loop

welldone:
cls 0
copy bitmap 2,0

r=255
g=0
b=0
ink rgb(r,g,b),0
set text size 220
center text 512,10,"WELL DONE"
set text size 148
center text 512,260,upper$(nme$)

set text size 120
center text 512,500,"PRESS A KEY"
set text size 48
return

draw:

if goes=1
ink rgb(0,0,0),0
box 130,30,195,100
ink rgb(255,255,0),0
endif

if goes=2
ink rgb(0,0,0),0
box 200,30,260,100
ink rgb(255,255,0),0
endif

if goes=3
ink rgb(0,0,0),0
box 265,30,325,100
ink rgb(255,255,0),0
endif

if goes=4
ink rgb(0,0,0),0
box 330,30,390,100
ink rgb(255,255,0),0
endif

if goes=5
ink rgb(0,0,0),0
box 395,30,455,100
ink rgb(255,255,0),0
endif

if goes=6
ink rgb(0,0,0),0
box 130,105,195,170
ink rgb(255,255,0),0
endif

if goes=7
ink rgb(0,0,0),0
box 200,105,260,170
ink rgb(255,255,0),0
endif

if goes=8
ink rgb(0,0,0),0
box 265,105,325,170
ink rgb(255,255,0),0
endif

if goes=9
ink rgb(0,0,0),0
box 330,105,390,170
ink rgb(255,255,0),0
endif

if goes=10
ink rgb(0,0,0),0
box 395,105,455,170
ink rgb(255,255,0),0

ink rgb(0,0,0),0
box 0,300,1023,768
copy bitmap 3,0

r=255
g=0
b=0
ink rgb(r,g,b),0
set text size 240
CENTER text 512,10,"HANG MAN"

set text size 148
center text 512,600,"PRESS A KEY"
wait key
cls 0
copy bitmap 1,0
goto ok
endif
return
` first ten
data "Elephant"
data "Rhinosaurus"
data "Giraffe"
data "Hippopotamus"
data "Lioness"
data "Leopard"
data "Gazelle"
data "Antelope"
data "Anteater"
data "Anaconda"
` second ten
data "Molecule"
data "Radiation"
data "Atomic"
data "Nucleus"
data "Ionization"
data "Reaction"
data "Osmosis"
data "Conduction"
data "Convection"
data "Transference"