Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 hang man..
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DragonSlayer




PostPosted: Fri Feb 13, 2004 12:02 pm   Post subject: hang man..

code:

%HANG THE MAN
var word : array 1 .. 12 of string := init ("photosynthesis", "dictionary", "language", "obstreperous", "zeitgeist", "ersatz", "dour", "serendipity", "sycophant", "lucre", "introspection",
    "etymologically")
var chars, random, count, space : int := 0
var letter : string

colourback (91)
cls
%begging
locate (1, 1)
put "please enter a letter"


%base graphic
locate (5, 1)
drawbox (300, 200, 400, 210, 4)
drawbox (345, 210, 355, 320, 4)
drawbox (355, 318, 435, 310, 4)

%random words
randint (random, 1, 12)
var dash : array 1 .. length (word (random)) of string
for a : 1 .. length (word (random))
    dash (a) := "_"
end for

%word
loop
    locate (2, 5)
    %draw dash
    for a : 1 .. length (word (random))
        put dash (a) : 3, " " ..
    end for

    %chech for letters
    loop
        locate (4, 1)
        put "" : 10
        locate (4, 1)
        get letter

        if length (letter) > 1 then
            locate (20, 1)
            put " "
        end if
        exit when length (letter) = 1
    end loop

    if index (word (random), letter) >= 0 then
        locate (14, 5 + chars)
        put letter
        chars := chars + 2
    end if
    count := count + 1
    %graphics
    %head
    if count > 1 then
        drawline (432, 310, 432, 290, 7)
    end if
    if count > 2 then
        Draw.Oval (432, 280, 10, 10, 1)
    end if
    if count > 3 then
        drawoval (428, 282, 2, 2, 7)
    end if
    if count > 4 then
        drawoval (436, 282, 2, 2, 7)
    end if
    if count > 5 then
        drawline (430, 275, 434, 275, 7)
    end if
    %body parts
    if count > 6 then
        drawline (432, 270, 432, 240, 1)
    end if
    if count > 7 then
        drawline (432, 240, 418, 220, 1)
    end if
    if count > 8 then
        drawline (432, 240, 446, 220, 1)
    end if
    if count > 9 then
        drawline (432, 255, 422, 265, 1)
    end if
    if count > 10 then
        drawline (432, 255, 442, 265, 1)

    end if

   

    put letter
    space := 3

    for b : 1 .. length (word (random))
        if letter = word (random) (b) then
            dash (b) := letter
        end if
    end for
    %win condition



    %lose condition
    if count = 12 then
        cls
        var font : int
        font := Font.New ("serif:20")
        Draw.Text ("YOU LOSE", maxx div 2 - 60, maxy div 2, font, red)
        Font.Free (font)
        put word (random)
        exit when count = 12
    end if
end loop
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Fri Feb 13, 2004 12:10 pm   Post subject: (No subject)

I like it, but you could do with more colors. I like the background color though. +BITS
DragonSlayer




PostPosted: Fri Feb 13, 2004 12:25 pm   Post subject: (No subject)

thnx, it's my first post... ill ttry to make the program more colourful just for you Wink
GUI.GetScrollBarWidth : i




PostPosted: Fri Feb 13, 2004 5:26 pm   Post subject: (No subject)

yeah that program was realy cool, but more colour couldn't hurt
recneps




PostPosted: Sun Feb 15, 2004 1:33 pm   Post subject: (No subject)

Not baad Smile (Like i could do better :\) lol, Nice job!
Delos




PostPosted: Sun Feb 15, 2004 4:10 pm   Post subject: (No subject)

Hmm...I played against the word "ersatz" and I couldn't win! I got the word (checked, of course), but it wouldn't recognize it as being complete!
Maverick




PostPosted: Sun Feb 15, 2004 4:24 pm   Post subject: (No subject)

Uh thats not how u play hangman. When u guess a letter u dont get a body part up.
Cervantes




PostPosted: Sun Feb 15, 2004 5:12 pm   Post subject: (No subject)

indeed, the scoring system is rather messed up Confused
also you should add some more error proofing in there. make it so they can't enter the same letter twice .

and what is ersatz ?!??!?

you've a good program there, just a few things to make it great!
Sponsor
Sponsor
Sponsor
sponsor
shorthair




PostPosted: Sun Feb 15, 2004 5:14 pm   Post subject: (No subject)

Nice job , ofr a new programmer , i like how its done ( same deal with hte color though ) but when you learn some more you will be able to write it so that a retarded user couldnt crash it ( seriously ) error handling is really good hen a user is right in hte middle of a game or somthingand it crashes NOT COOL , so always asume hte user will make every mistake
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: