One-Half Whack
' One-Half Whack

' One-Half Whack is a stupid game where you go toe to toe with a slime.
' The name of the game is revealing because you only have 50-50 chance
' at beating the slime. This game only exists as a very simple example
' of a battle engine.

' Initialization

randomize

dim playerHP
dim slimeHP
dim action
dim damage 

playerHP = 25
slimeHP = 25
gameOver = false

console.Initialize

console.WriteLine "You are a level 1 Warrior who has met a slime in the"
console.WriteLine "Woods. It's your first battle and you're not backing"
console.WriteLine "down."

system.Pause 4000

' Game Loop

do while not gameOver
    console.Clear 
    console.WriteLine "You have " & playerHP & " hit points."
    console.WriteLine "The slime has " & slimeHP & " hit points."
    console.WriteLine
    console.WriteLine "A slime looks at you with it's .... eye."
    console.WriteLine
    console.WriteLine "Choose :"
    console.WriteLine "    1.) Attack"
    console.WriteLine "    2.) Guard" 
    console.WriteLine
    action = console.ReadLine

    system.Pause 1000
    console.WriteLine
    if action = "1" then
        if rnd > .5 then
            damage = int(rnd(1)*5)+1
            console.WriteLine "You hit the slime for " & damage & " damage."
            slimeHP = slimeHP - damage
        else
            console.WriteLine "You missed!"
        end if
        if rnd > .5 then 
            system.Pause 1000
            damage = int(rnd(1)*5)+1
            console.WriteLine "The slime hits you for " & damage & " damage."
            playerHP = playerHP - damage
        else
            system.Pause 1000
            console.WriteLine "The slime misses... but still slimes you."
        end if
    elseif action = "2" then
        if rnd > .5 then
            system.Pause 1000
            damage = int(rnd(1)*2)+1
            console.WriteLine "The slime hits you for " & damage & " damage." 
            playerHP = playerHP - damage
        else
            system.Pause 1000
            console.WriteLine "The slimes ... thing.... bounces off your shield."
        end if
    else
        damage = int(rnd(1)*10)+1
        console.WriteLine "The slime whacks you while you were not looking!"
        console.WriteLine "It does 10 damage."
        playerHP = playerHP - 10
    end if

    system.Pause 2000
    console.WriteLine
    if playerHP < 1 then
        console.WriteLine "You are dead. You have been beaten by a slime. Oh, the"
        console.WriteLine "embarrassment."
        gameOver = true
    elseif slimeHP < 1 then
        console.WriteLine "The slime lays dead at your feet. You savor your first"
        console.WriteLine "victory, even if it was a slimy one."
        gameOver = true
    end if

loop    

console.Wait

' Termination

console.Terminate
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.