Microsoft Small Basic
Program Listing: KDQ877
'WINDOW
GraphicsWindow.Hide()
GraphicsWindow.Width = 800
GraphicsWindow.Height = 600
GraphicsWindow.Left = (1366 - 800) / 2
GraphicsWindow.Top = 50
GraphicsWindow.CanResize = "false"
GraphicsWindow.Title = "Candyrain"
'ORANGE __ :)
GraphicsWindow.BrushColor = "orange"
skull = Shapes.AddEllipse(100, 100)
Shapes.Move(skull, 350, 50)
GraphicsWindow.BrushColor = "white"
mouth = Shapes.AddEllipse(60, 55)
Shapes.Move(mouth, 370, 80)
GraphicsWindow.PenColor = "orange"
GraphicsWindow.BrushColor = "orange"
rectangle = Shapes.AddRectangle(80, 30)
Shapes.Move(rectangle, 360, 80)
GraphicsWindow.PenColor = "black"
lip = Shapes.AddLine(70, 60, 130, 60)
Shapes.Move(lip, 300, 50)
GraphicsWindow.BrushColor = "white"
lefteye = Shapes.AddEllipse(35, 35)
Shapes.Move(lefteye, 365, 70)
righteye = Shapes.AddEllipse(35, 35)
Shapes.Move(righteye, 400, 70)
GraphicsWindow.BrushColor = "black"
lefteyeball = Shapes.AddEllipse(15, 15)
Shapes.Move(lefteyeball, 375, 80)
righteyeball = Shapes.AddEllipse(15, 15)
Shapes.Move(righteyeball, 410, 80)
'NUMBER
number = Controls.AddButton("1", 0, 0)
Controls.HideControl(number)
'MENU
'DECORATION
GraphicsWindow.BrushColor = "lime"
GraphicsWindow.PenWidth = 5
leftdecoration1 = Shapes.AddEllipse(500, 500)
Shapes.Move(leftdecoration1, -250, 350)
GraphicsWindow.BrushColor = "lightblue"
leftdecoration2 = Shapes.AddEllipse(500, 500)
Shapes.Move(leftdecoration2, -250, 400)
Shapes.SetOpacity(leftdecoration2, 50)
GraphicsWindow.BrushColor = "lime"
rightdecoration1 = Shapes.AddEllipse(500, 500)
Shapes.Move(rightdecoration1, 550, -300)
Shapes.SetOpacity(rightdecoration1, 50)
GraphicsWindow.BrushColor = "red"
rightdecoration2 = Shapes.AddEllipse(500, 500)
Shapes.Move(rightdecoration2, 550, -250)
Shapes.SetOpacity(rightdecoration2, 50)
GraphicsWindow.BrushColor = "blue"
GraphicsWindow.FontSize = 20
'PLAY
play = Controls.AddButton("Play", 300, 200)
Controls.SetSize(play, 200, 45)
'DIFFICULTY
exit = Controls.AddButton("Exit", 300, 300)
Controls.SetSize(exit, 200, 45)
Controls.HideControl(exit)
yes = Controls.AddButton("Yes", 300, 300)
Controls.SetSize(yes, 100, 45)
Controls.HideControl(yes)
no = Controls.AddButton("No", 400, 300)
Controls.SetSize(no, 100, 45)
Controls.HideControl(no)
setdifficulty = Controls.AddButton("Difficulty", 300, 300)
Controls.SetSize(setdifficulty, 200, 45)
GraphicsWindow.BrushColor = "darkblue"
GraphicsWindow.FontSize = 17
easy = Controls.AddButton("Easy", 345, 360)
Controls.SetSize(easy, 110, 35)
Controls.HideControl(easy)
medium = Controls.AddButton("Medium", 345, 410)
Controls.SetSize(medium, 110, 35)
Controls.HideControl(medium)
GraphicsWindow.BrushColor = "gray"
forgetit = Controls.AddButton("Forget it!", 345, 460)
Controls.SetSize(forgetit, 110, 35)
Controls.HideControl(forgetit)
GraphicsWindow.BrushColor = "lime"
difficultyindicator1 = Shapes.AddEllipse(20, 20)
Shapes.Move(difficultyindicator1, 465, 365)
Shapes.HideShape(difficultyindicator1)
difficultyindicator2 = Shapes.AddEllipse(20, 20)
Shapes.Move(difficultyindicator2, 315, 365)
Shapes.HideShape(difficultyindicator2)
'PLAYER
GraphicsWindow.BrushColor = "blue"
GraphicsWindow.PenWidth = 2
player = Shapes.AddRectangle(100, 30)
Shapes.Move(player, 350, 570)
Controls.HideControl(player)
'OBSTACLES
GraphicsWindow.BrushColor = "red"
GraphicsWindow.PenWidth = 3
obstacle = Shapes.AddEllipse(80, 80)
Shapes.HideShape(obstacle)
Timer.Interval = 0
Timer.Tick = tick
difficulty = 10
difficultydrop = 680
difficultyloss = 490
difficultyscore = 520
Sub tick
getnumber = Controls.GetButtonCaption(number)
If getnumber = 0 Then
gettop = Shapes.GetTop(obstacle)
Shapes.Move(obstacle, Math.GetRandomNumber(720), 0)
getleft = Shapes.GetLeft(obstacle)
Shapes.Move(obstacle, newleft, gettop + difficulty)
If gettop = difficultydrop Then
newleft = getleft
Shapes.Move(obstacle, getleft, 0)
EndIf
If gettop = difficultyscore Then
getscore = Controls.GetButtonCaption(score)
Controls.SetButtonCaption(score, getscore + 1)
EndIf
getleftofplayer = Shapes.GetLeft(player)
gettop = Shapes.GetTop(obstacle)
getleft = Shapes.GetLeft(obstacle)
If gettop = difficultyloss And getleft > getleftofplayer - 75 And getleft < getleftofplayer + 95 Then
Sound.PlayChimes()
Controls.SetButtonCaption(number, 1)
Shapes.ShowShape(gameoverblackscreen)
Shapes.ShowShape(gameover)
Shapes.ShowShape(yourscore)
Shapes.ShowShape(yourscoreline)
Controls.Move(score, 370, 90)
Controls.ShowControl(tryagain)
Controls.ShowControl(menu)
EndIf
EndIf
EndSub
'IF_STATEMENTS
'KEY_DOWN
GraphicsWindow.BrushColor = "red"
GraphicsWindow.KeyDown = keydown
Sub keydown
getnumber = Controls.GetButtonCaption(number)
If getnumber = 0 Then
lastkey = GraphicsWindow.LastKey
getleftofplayer = Shapes.GetLeft(player)
gettopofplayer = Shapes.GetTop(player)
If lastkey = "Left" Then
Shapes.Move(player, getleftofplayer - 50, gettopofplayer)
If getleftofplayer = 0 Then
Sound.PlayChimes()
Shapes.Move(player, 0, gettopofplayer)
EndIf
EndIf
If lastkey = "Right" Then
Shapes.Move(player, getleftofplayer + 50, gettopofplayer)
If getleftofplayer = 700 Then
Shapes.Move(player, 700, gettopofplayer)
Sound.PlayChimes()
EndIf
EndIf
EndIf
EndSub
'BUTTON_CLICK
Controls.ButtonClicked = buttonclicked
Sub buttonclicked
lastbutton = Controls.LastClickedButton
If lastbutton = tryagain Then
Sound.PlayClick()
Controls.Move(score, 370, 20)
Shapes.HideShape(yourscore)
Shapes.HideShape(yourscoreline)
Shapes.HideShape(gameoverblackscreen)
Shapes.HideShape(gameover)
Controls.HideControl(tryagain)
Controls.HideControl(menu)
Controls.SetButtonCaption(score, 0)
Controls.SetButtonCaption(number, 0)
EndIf
If lastbutton = play Then
Sound.PlayClick()
Controls.HideControl(play)
Controls.HideControl(setdifficulty)
Shapes.ShowShape(player)
Shapes.ShowShape(obstacle)
Controls.ShowControl(score)
Controls.HideControl(easy)
Controls.HideControl(medium)
Controls.HideControl(forgetit)
Controls.HideControl(exit)
Controls.HideControl(yes)
Controls.HideControl(no)
Shapes.HideShape(skull)
Shapes.HideShape(mouth)
Shapes.HideShape(rectangle)
Shapes.HideShape(lip)
Shapes.HideShape(lefteyeball)
Shapes.HideShape(righteyeball)
Shapes.HideShape(lefteye)
Shapes.HideShape(righteye)
Shapes.HideShape(difficultyindicator1)
Shapes.HideShape(difficultyindicator2)
Shapes.HideShape(leftdecoration1)
Shapes.HideShape(leftdecoration2)
Shapes.HideShape(rightdecoration1)
Shapes.HideShape(rightdecoration2)
Controls.SetButtonCaption(number, 0)
EndIf
If lastbutton = setdifficulty Then
Sound.PlayClick()
Controls.ShowControl(easy)
Controls.ShowControl(medium)
Controls.ShowControl(forgetit)
Shapes.ShowShape(difficultyindicator1)
Shapes.ShowShape(difficultyindicator2)
EndIf
If lastbutton = easy Then
Sound.PlayClick()
Controls.HideControl(easy)
Controls.HideControl(medium)
Controls.HideControl(forgetit)
Shapes.Move(difficultyindicator1, 465, 365)
Shapes.Move(difficultyindicator2, 315, 365)
Shapes.HideShape(difficultyindicator1)
Shapes.HideShape(difficultyindicator2)
difficulty = 10
difficultydrop = 680
difficultyloss = 490
difficultyscore = 520
EndIf
If lastbutton = medium Then
Sound.PlayClick()
Controls.HideControl(easy)
Controls.HideControl(medium)
Controls.HideControl(forgetit)
Shapes.Move(difficultyindicator1, 465, 415)
Shapes.Move(difficultyindicator2, 315, 415)
Shapes.HideShape(difficultyindicator1)
Shapes.HideShape(difficultyindicator2)
difficulty = 15
difficultydrop = 690
difficultyloss = 480
difficultyscore = 540
EndIf
If lastbutton = forgetit Then
Sound.PlayClick()
Controls.HideControl(easy)
Controls.HideControl(medium)
Controls.HideControl(forgetit)
Shapes.Move(difficultyindicator1, 465, 465)
Shapes.Move(difficultyindicator2, 315, 465)
Shapes.HideShape(difficultyindicator1)
Shapes.HideShape(difficultyindicator2)
difficulty = 20
difficultydrop = 700
difficultyloss = 480
difficultyscore = 540
EndIf
If lastbutton = menu Then
Sound.PlayClick()
Controls.HideControl(score)
Controls.HideControl(tryagain)
Controls.HideControl(menu)
Shapes.HideShape(player)
Shapes.HideShape(gameoverblackscreen)
Shapes.HideShape(obstacle)
Shapes.HideShape(yourscore)
Shapes.HideShape(yourscoreline)
Shapes.HideShape(gameover)
Shapes.ShowShape(skull)
Shapes.ShowShape(mouth)
Shapes.ShowShape(rectangle)
Shapes.ShowShape(lip)
Shapes.ShowShape(lefteyeball)
Shapes.ShowShape(righteyeball)
Shapes.ShowShape(lefteye)
Shapes.ShowShape(righteye)
Shapes.ShowShape(leftdecoration1)
Shapes.ShowShape(leftdecoration2)
Shapes.ShowShape(rightdecoration1)
Shapes.ShowShape(rightdecoration2)
Controls.SetButtonCaption(score, 0)
Controls.Move(score, 370, 20)
Controls.HideControl(easy)
Controls.HideControl(medium)
Controls.HideControl(forgetit)
Controls.ShowControl(play)
Controls.ShowControl(exit)
EndIf
If lastbutton = exit Then
Sound.PlayClick()
Controls.HideControl(exit)
Controls.ShowControl(yes)
Controls.ShowControl(no)
EndIf
If lastbutton = yes Then
Sound.PlayClickAndWait()
Program.End()
EndIf
If lastbutton = no Then
Sound.PlayClick()
Controls.HideControl(yes)
Controls.HideControl(no)
Controls.ShowControl(exit)
EndIf
EndSub
'GAME_OVER
GraphicsWindow.BrushColor = "black"
gameoverblackscreen = Shapes.AddRectangle(800, 600)
Shapes.SetOpacity(gameoverblackscreen, 90)
Shapes.HideShape(gameoverblackscreen)
GraphicsWindow.BrushColor = "white"
GraphicsWindow.FontSize = 50
gameover = Shapes.AddText("Game Over")
Shapes.Move(gameover, 265, 250)
Shapes.HideShape(gameover)
GraphicsWindow.FontSize = 25
yourscore = Shapes.AddText("Your score:")
Shapes.Move(yourscore, 330, 20)
Shapes.HideShape(yourscore)
GraphicsWindow.PenColor = "white"
yourscoreline = Shapes.AddLine(330, 60, 475, 60)
Shapes.HideShape(yourscoreline)
'SCORE
GraphicsWindow.FontSize = 25
GraphicsWindow.BrushColor = "blue"
score = Controls.AddButton("0", 370, 20)
Controls.SetSize(score, 60, 50)
Controls.HideControl(score)
'TRY_AGAIN
GraphicsWindow.BrushColor = "blue"
tryagain = Controls.AddButton("Play", 325, 400)
Controls.SetSize(tryagain, 150, 50)
Controls.HideControl(tryagain)
menu = Controls.AddButton("Menu", 325, 470)
Controls.SetSize(menu, 150, 50)
Controls.HideControl(menu)
'SHOW_WINDOW
GraphicsWindow.Show()