Last active
August 29, 2015 14:06
-
-
Save G33kDude/a59195a4fe475c21bb30 to your computer and use it in GitHub Desktop.
/r/DailyProgrammer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Title := "}{FISH}" | |
Stats := {"Hunger": 50, "Drowsy": 80, "Health": 75, "Bowels": 10, "Thirst": 0} | |
Sleeping := False | |
Gui, Add, Text, r6 w75 -VScroll +ReadOnly vScreen | |
GoSub, UpdateStats | |
Gui, Add, Button, vButton1 gFeed ys x+5 w100, Feed | |
Gui, Add, Button, vButton2 gSleep w100, Put to bed | |
Gui, Add, Button, vButton3 gKill w100, Put to sleep | |
Gui, Add, Text, xm w175 Center vTicker, Your fish | |
Gui, Show | |
SetTimer, Tick, 200 | |
return | |
GuiClose: | |
ExitApp | |
return | |
Feed: | |
if Sleeping | |
return | |
SoundBeep | |
GuiControl,, Ticker, You fed your fish | |
Stats.Hunger -= 5 | |
Stats.Bowels += 5 | |
if Stats.Bowels > 100 | |
Stats.Bowels := 100 | |
if Stats.Hunger < 0 | |
Stats.Hunger := 0 | |
GoSub, UpdateStats | |
return | |
Sleep: | |
if Sleeping | |
return ; lol | |
Stats.Drowsy -= 80 | |
if Stats.Drowsy < 0 | |
Stats.Drowsy := 0 | |
GoSub, UpdateStats | |
SoundBeep | |
GuiControl,, Ticker, Your fish is sleeping | |
GuiControl, Disable, Button1 | |
GuiControl, Disable, Button2 | |
GuiControl, Disable, Button3 | |
SetTimer, Tick, Off | |
Sleeping := True | |
SetTimer, Wake, -5000 | |
return | |
Wake: | |
GuiControl, Enable, Button1 | |
GuiControl, Enable, Button2 | |
GuiControl, Enable, Button3 | |
SoundBeep | |
GuiControl,, Ticker, Your fish just woke up | |
Sleeping := False | |
SetTimer, Tick, 200 | |
return | |
Kill: | |
SoundBeep | |
MsgBox, You monster`, you've killed it | |
ExitApp | |
return | |
Relieve: | |
SoundBeep | |
GuiControl,, Ticker, Your fish relieves itself | |
Stats.Bowels := Rand(10, 30) | |
if Stats.Bowls < 0 | |
Stats.Bowels := 0 | |
return | |
Tick: | |
if Sleeping | |
return | |
Rand := Rand(1, 4) | |
if (Rand == 1) | |
{ | |
Stats.Hunger++ | |
if Stats.Hunger > 100 | |
Stats.Hunger := 100 | |
} | |
else if (Rand == 2) | |
{ | |
Stats.Drowsy++ | |
if Stats.Drowsy > 100 | |
Stats.Drowsy := 100 | |
} | |
else if (Rand == 3) | |
{ | |
; As hunger decreases the chances of being under threshold decreases. | |
; When hunger is at 30 there's a 100% chance of health increasing | |
; When hunger is at 60 there's a 50/50 chance of health increasing or decreasing | |
if (Rand(1, Stats.Hunger) < 20) | |
Stats.Health+=3 | |
else | |
Stats.Health-=3 | |
if Stats.Health > 100 | |
Stats.Health := 100 | |
} | |
else if (Rand == 4) | |
{ | |
Stats.Bowels++ | |
if Stats.Bowels > 100 | |
Stats.Bowels := 100 | |
} | |
if (Stats.Drowsy > 90 && !Rand(0, 5)) ; 1/6 chance | |
GoSub, Sleep | |
if (Stats.Bowels > 50 && !Rand(0, 3)) ; 1/4 chance | |
GoSub, Relieve | |
if (Stats.Hunger > 90 && Rand(0, 3)) ; 3/4 chance | |
Health -= 5 | |
if Stats.Health < 0 | |
GoSub, Kill | |
GoSub, UpdateStats | |
return | |
UpdateStats: | |
Screen := "}{FISH}" | |
for Stat, Value in Stats | |
Screen .= "`n" Stat ": " Value | |
GuiControl,, Screen, %Screen% | |
return | |
Rand(Min, Max) | |
{ | |
Random, Rand, Min, Max | |
return Rand | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment