Microsoft Small Basic

Program Listing: GBN831
'Author: Jamie Randle'
'Cookie Clicker in Small Basic'

'================================================'
'TO DO LIST'
'================================================'
'Add upgrades which change cookies per click and CpS'
'================================================'
'NEXT'
'Button where you can sell buildings next to buy buttons OR insert images for the cookie and possibly the buildings'


'Sets up the graphics window'
Sub GraphicsWindowSetup
GraphicsWindow.Title = "Click the button"
GraphicsWindow.CanResize = "True"
GraphicsWindow.Height = 780
GraphicsWindow.Width = 1360
EndSub

'Sets up the cookie'
Sub CookieSetup
Cookie = Controls.AddButton("Click Me", 555, 225)
Controls.SetSize(Cookie, 250, 250)
EndSub

'Sets up the images'
'Sub ImageSetup
' CookieImage = ImageList.LoadImage("C:\Users\Jammy\Desktop\Small Basic Programs\Cookie Clicker\Images\Cookie.jpg")
' GraphicsWindow.DrawImage(CookieImage, 555, 255)
'EndSub

'Sets up the scoring'
Sub ScoreSetup
ScoreText = Controls.AddTextBox(10,10)
Score = 0
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetSize(ScoreText, 250, 25)
EndSub

'Sets up the CpS'
Sub CpSSetup
CpSText = Controls.AddTextBox(10,40)
CpS = 0
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetSize(CpSText, 250, 25)
EndSub

'Sets up the CpS timer
Sub CpSTimerSetup
Timer.Interval = 1000 'One tick per second'
Timer.Tick = CpSTimerTick
EndSub

'Makes the timer do something every time it ticks'
Sub CpSTimerTick
Score = Score + CpS
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
EndSub

'Displays the amount of cursors the player has'
Sub CursorNumberSetup
CursorNumberText = Controls.AddTextBox(10,70)
Controls.SetTextBoxText(CursorNumberText, "Number of cursors = " + CursorNumber)
Controls.SetSize(CursorNumberText, 250, 25)
EndSub

'Displays the amount of grandmas the player has'
Sub GrandmaNumberSetup
GrandmaNumberText = Controls.AddTextBox(10,100)
Controls.SetTextBoxText(GrandmaNumberText, "Number of grandmas = " + GrandmaNumber)
Controls.SetSize(GrandmaNumberText, 250, 25)
EndSub

'Displays the amount of farms the player has'
Sub FarmNumberSetup
FarmNumberText = Controls.AddTextBox(10,130)
Controls.SetTextBoxText(FarmNumberText, "Number of farms = " + FarmNumber)
Controls.SetSize(FarmNumberText, 250, 25)
EndSub

'Displays the amount of factories the player has'
Sub FactoryNumberSetup
FactoryNumberText = Controls.AddTextBox(10,160)
Controls.SetTextBoxText(FactoryNumberText, "Number of factories = " + FactoryNumber)
Controls.SetSize(FactoryNumberText, 250, 25)
EndSub

'Displays the amount of mines the player has'
Sub MineNumberSetup
MineNumberText = Controls.AddTextBox(10,190)
Controls.SetTextBoxText(MineNumberText, "Number of mines = " + MineNumber)
Controls.SetSize(MineNumberText, 250, 25)
EndSub

'Displays the amount of shipments the player has'
Sub ShipmentNumberSetup
ShipmentNumberText = Controls.AddTextBox(10,220)
Controls.SetTextBoxText(ShipmentNumberText, "Number of shipments = " + ShipmentNumber)
Controls.SetSize(ShipmentNumberText, 250, 25)
EndSub

'Displays the amount of alchemy labs the player has'
Sub AlchemyLabNumberSetup
AlchemyLabNumberText = Controls.AddTextBox(10,250)
Controls.SetTextBoxText(AlchemyLabNumberText, "Number of alchemy labs = " + AlchemyLabNumber)
Controls.SetSize(AlchemyLabNumberText, 250, 25)
EndSub

'Displays the amount of portals the player has'
Sub PortalNumberSetup
PortalNumberText = Controls.AddTextBox(10,280)
Controls.SetTextBoxText(PortalNumberText, "Number of portals = " + PortalNumber)
Controls.SetSize(PortalNumberText, 250, 25)
EndSub

'Displays the amount of time machines the player has'
Sub TimeMachineNumberSetup
TimeMachineNumberText = Controls.AddTextBox(10,310)
Controls.SetTextBoxText(TimeMachineNumberText, "Number of time machines = " + TimeMachineNumber)
Controls.SetSize(TimeMachineNumberText, 250, 25)
EndSub

'Displays the amount of antimatter condensers the player has'
Sub AntimatterCondenserNumberSetup
AntimatterCondenserNumberText = Controls.AddTextBox(10,340)
Controls.SetTextBoxText(AntimatterCondenserNumberText, "Number of antimatter condensers = " + AntimatterCondenserNumber)
Controls.SetSize(AntimatterCondenserNumberText, 250, 25)
EndSub

'Displays the amount of prisms the player has'
Sub PrismNumberSetup
PrismNumberText = Controls.AddTextBox(10,370)
Controls.SetTextBoxText(PrismNumberText, "Number of prisms = " + PrismNumber)
Controls.SetSize(PrismNumberText, 250, 25)
EndSub

'Sets up the cursors'
Sub CursorSetup
BuyCursor = Controls.AddButton("Buy a cursor", 1150, 10)
Controls.SetSize(BuyCursor, 200, 35)
CursorPrice = 15
CursorNumber = 0
EndSub

'Sets up the grandmas'
Sub GrandmaSetup
BuyGrandma = Controls.AddButton("Buy a grandma", 1150, 50)
Controls.SetSize(BuyGrandma, 200, 35)
GrandmaPrice = 100
GrandmaNumber = 0
EndSub

'Sets up the farms'
Sub FarmSetup
BuyFarm = Controls.AddButton("Buy a Farm", 1150, 90)
Controls.SetSize(BuyFarm, 200, 35)
FarmPrice = 500
FarmNumber = 0
EndSub

'Sets up the factories'
Sub FactorySetup
BuyFactory = Controls.AddButton("Buy a Factory", 1150, 130)
Controls.SetSize(BuyFactory, 200, 35)
FactoryPrice = 3000
FactoryNumber = 0
EndSub

'Sets up the mines'
Sub MineSetup
BuyMine = Controls.AddButton("Buy a Mine", 1150, 170)
Controls.SetSize(BuyMine, 200, 35)
MinePrice = 10000
MineNumber = 0
EndSub

'Sets up the shipments'
Sub ShipmentSetup
BuyShipment = Controls.AddButton("Buy a Shipment", 1150, 210)
Controls.SetSize(BuyShipment, 200, 35)
ShipmentPrice = 40000
ShipmentNumber = 0
EndSub

'Sets up the alchemy labs'
Sub AlchemyLabSetup
BuyAlchemyLab = Controls.AddButton("Buy an Alchemy Lab", 1150, 250)
Controls.SetSize(BuyAlchemyLab, 200, 35)
AlchemyLabPrice = 200000
AlchemyLabNumber = 0
EndSub

'Sets up the portals'
Sub PortalSetup
BuyPortal = Controls.AddButton("Buy a Portal", 1150, 290)
Controls.SetSize(BuyPortal, 200, 35)
PortalPrice = 1677000
PortalNumber = 0
EndSub

'Sets up the time machines'
Sub TimeMachineSetup
BuyTimeMachine = Controls.AddButton("Buy a Time Machine", 1150, 330)
Controls.SetSize(BuyTimeMachine, 200, 35)
TimeMachinePrice = 123456789
TimeMachineNumber = 0
EndSub

'Sets up the antimatter condensers'
Sub AntimatterCondenserSetup
BuyAntimatterCondenser = Controls.AddButton("Buy an Antimatter Condenser", 1150, 370)
Controls.SetSize(BuyAntimatterCondenser, 200, 35)
AntimatterCondenserPrice = 4000000000
AntimatterCondenserNumber = 0
EndSub

'Sets up the prisms'
Sub PrismSetup
BuyPrism = Controls.AddButton("Buy a Prism", 1150, 410)
Controls.SetSize(BuyPrism, 200, 35)
PrismPrice = 75000000000
PrismNumber = 0
EndSub

'Does effects of the button the user clicked on'
Sub ButtonClicked
LastButton = Controls.LastClickedButton
If LastButton = Cookie Then 'Scores for clicking the cookie'
Score = Score + 1
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
ElseIf LastButton = BuyCursor Then 'Buys a cursor'
If Score > CursorPrice Then
Score = Score - CursorPrice
CpS = CpS + 0.1
CursorPrice = CursorPrice + 5
CursorNumber = CursorNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(CursorNumberText, "Number of cursors = " + CursorNumber)
ElseIf Score = CursorPrice Then
Score = Score - CursorPrice
CpS = CpS + 0.1
CursorPrice = CursorPrice + 5
CursorNumber = CursorNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(CursorNumberText, "Number of cursors = " + CursorNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A cursor costs " + CursorPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyGrandma Then 'Buys a grandma'
If Score > GrandmaPrice Then
Score = Score - GrandmaPrice
CpS = CpS + 0.5
GrandmaPrice = GrandmaPrice + 15
GrandmaNumber = GrandmaNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(GrandmaNumberText, "Number of grandmas = " + GrandmaNumber)
ElseIf Score = GrandmaPrice Then
Score = Score - GrandmaPrice
CpS = CpS + 0.5
GrandmaPrice = GrandmaPrice + 15
GrandmaNumber = GrandmaNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(GrandmaNumberText, "Number of grandmas = " + GrandmaNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A grandma costs " + GrandmaPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyFarm Then 'Buys a farm'
If Score > FarmPrice Then
Score = Score - FarmPrice
CpS = CpS + 4
FarmPrice = FarmPrice + 80
FarmNumber = FarmNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(FarmNumberText, "Number of farms = " + FarmNumber)
ElseIf Score = FarmPrice Then
Score = Score - FarmPrice
CpS = CpS + 4
FarmPrice = FarmPrice + 80
FarmNumber = FarmNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(FarmNumberText, "Number of farms = " + FarmNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A farm costs " + FarmPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyFactory Then 'Buys a factory'
If Score > FactoryPrice Then
Score = Score - FactoryPrice
CpS = CpS + 10
FactoryPrice = FactoryPrice + 450
FactoryNumber = FactoryNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(FactoryNumberText, "Number of factories = " + FactoryNumber)
ElseIf Score = FactoryPrice Then
Score = Score - FactoryPrice
CpS = CpS + 10
FactoryPrice = FactoryPrice + 450
FactoryNumber = FactoryNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(FactoryNumberText, "Number of factories = " + FactoryNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A factory costs " + FactoryPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyMine Then 'Buys a mine'
If Score > MinePrice Then
Score = Score - MinePrice
CpS = CpS + 40
MinePrice = MinePrice + 1500
MineNumber = MineNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(MineNumberText, "Number of mines = " + MineNumber)
ElseIf Score = MinePrice Then
Score = Score - MinePrice
CpS = CpS + 40
MinePrice = MinePrice + 1500
MineNumber = MineNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(MineNumberText, "Number of mines = " + MineNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A mine costs " + MinePrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyShipment Then 'Buys a shipment'
If Score > ShipmentPrice Then
Score = Score - ShipmentPrice
CpS = CpS + 100
ShipmentPrice = ShipmentPrice + 6000
ShipmentNumber = ShipmentNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(ShipmentNumberText, "Number of shipments = " + ShipmentNumber)
ElseIf Score = ShipmentPrice Then
Score = Score - ShipmentPrice
CpS = CpS + 100
ShipmentPrice = ShipmentPrice + 6000
ShipmentNumber = ShipmentNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(ShipmentNumberText, "Number of shipments = " + ShipmentNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A shipment costs " + ShipmentPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyAlchemyLab Then 'Buys an alchemy lab'
If Score > AlchemyLabPrice Then
Score = Score - AlchemyLabPrice
CpS = CpS + 400
AlchemyLabPrice = AlchemyLabPrice + 30000
AlchemyLabNumber = AlchemyLabNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(AlchemyLabNumberText, "Number of alchemy labs = " + AlchemyLabNumber)
ElseIf Score = AlchemyLabPrice Then
Score = Score - AlchemyLabPrice
CpS = CpS + 400
AlchemyLabPrice = AlchemyLabPrice + 30000
AlchemyLabNumber = AlchemyLabNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(AlchemyLabNumberText, "Number of alchemy labs = " + AlchemyLabNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! An alchemy lab costs " + AlchemyLabPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyPortal Then 'Buys a portal'
If Score > PortalPrice Then
Score = Score - PortalPrice
CpS = CpS + 6666
PortalPrice = PortalPrice + 250000
PortalNumber = PortalNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(PortalNumberText, "Number of portals = " + PortalNumber)
ElseIf Score = PortalPrice Then
Score = Score - PortalPrice
CpS = CpS + 6666
PortalPrice = PortalPrice + 250000
PortalNumber = PortalNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(PortalNumberText, "Number of portals = " + PortalNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A portal costs " + PortalPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyTimeMachine Then 'Buys a time machine'
If Score > TimeMachinePrice Then
Score = Score - TimeMachinePrice
CpS = CpS + 98765
TimeMachinePrice = TimeMachinePrice + 18518000
TimeMachineNumber = TimeMachineNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(TimeMachineNumberText, "Number of time machines = " + TimeMachineNumber)
ElseIf Score = TimeMachinePrice Then
Score = Score - TimeMachinePrice
CpS = CpS + 98765
TimeMachinePrice = TimeMachinePrice + 18518000
TimeMachineNumber = TimeMachineNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(TimeMachineNumberText, "Number of time machines = " + TimeMachineNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A time machine costs " + TimeMachinePrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyAntimatterCondenser Then 'Buys an antimatter condenser'
If Score > AntimatterCondenserPrice Then
Score = Score - AntimatterCondenserPrice
CpS = CpS + 999999
AntimatterCondenserPrice = AntimatterCondenserPrice + 600000000
AntimatterCondenserNumber = AntimatterCondenserNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(AntimatterCondenserNumberText, "Number of antimatter condensers = " + AntimatterCondenserNumber)
ElseIf Score = AntimatterCondenserPrice Then
Score = Score - AntimatterCondenserPrice
CpS = CpS + 999999
AntimatterCondenserPrice = AntimatterCondenserPrice + 600000000
AntimatterCondenserNumber = AntimatterCondenserNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(AntimatterCondenserNumberText, "Number of antimatter condensers = " + AntimatterCondenserNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! An antimatter condenser costs " + AntimatterCondenserPrice, "Not enough cookies!")
EndIf
ElseIf LastButton = BuyPrism Then 'Buys a prism'
If Score > PrismPrice Then
Score = Score - PrismPrice
CpS = CpS + 10000000
PrismPrice = PrismPrice + 11250000000
PrismNumber = PrismNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(PrismNumberText, "Number of prisms = " + PrismNumber)
ElseIf Score = PrismPrice Then
Score = Score - PrismPrice
CpS = CpS + 10000000
PrismPrice = PrismPrice + 11250000000
PrismNumber = PrismNumber + 1
Controls.SetTextBoxText(CpSText, "CpS = " + CpS)
Controls.SetTextBoxText(ScoreText, "Cookies = " + Score)
Controls.SetTextBoxText(PrismNumberText, "Number of prisms = " + PrismNumber)
Else
GraphicsWindow.ShowMessage("You don't have enough cookies! A prism costs " + PrismPrice, "Not enough cookies!")
EndIf
EndIf
EndSub

'Calls all of the setup subs'
GraphicsWindowSetup()
CookieSetup()
'ImageSetup()
ScoreSetup()
CpSSetup()
CpSTimerSetup()
CursorNumberSetup()
GrandmaNumberSetup()
FarmNumberSetup()
FactoryNumberSetup()
MineNumberSetup()
ShipmentNumberSetup()
AlchemyLabNumberSetup()
PortalNumberSetup()
TimeMachineNumberSetup()
AntimatterCondenserNumberSetup()
PrismNumberSetup()
CursorSetup()
GrandmaSetup()
FarmSetup()
FactorySetup()
MineSetup()
ShipmentSetup()
AlchemyLabSetup()
PortalSetup()
TimeMachineSetup()
AntimatterCondenserSetup()
PrismSetup()