
-----------------------------------
magicman
Sat Jul 09, 2005 9:31 am

Monsters
-----------------------------------
ok, so this is what i have for code sofar, with the monsters attacking.

var ans : string
var mhp : int := 25
var hp : int := 100
var lvl1a : int
var att : int
proc lvl1
    randint (lvl1a, 1, 6)
    put "he attacks you for ", lvl1a
    hp := hp - lvl1a
    put "your health is now ", hp
    delay (400)
end lvl1
proc menu
    put "What do you want to do?"
    put "(A)ttack"
    put "(D)efend"
    get ans
end menu
proc attack
    randint (att, 1, 6)
    put "You hit him for ", att
    mhp := mhp - att
    put "The monsters health is now ", mhp
end attack

loop
    menu ()
    if ans = "a"| ans = "A" then
        attack ()
        put "Hit any key to continue..."
        var ch4 : string (1)
        getch (ch4)
        cls
        lvl1 ()
    elsif ans = "d"| ans = "D" then
        put "You defend from the monster."
        put "he attacks you for ", lvl1a - 2
    end if
    if mhp = 0 then
        exit
    end if
end loop


the only problem is when i want the program to exit the loop when "mhp" will equal zero. for some reason, i think this is how you do it, but its not working. am i doing something thats not possible?

-----------------------------------
Bacchus
Sat Jul 09, 2005 10:56 am


-----------------------------------
try:
exit when mhp