'Basic Challenge 2
'Write a program with 4 buttons, one in each corner or the GraphicsWindow. They will:
'Change the background colour
'Make a sound
'Show an image in the middle of the GraphicsWindow
'Clear the GraphicsWindow, but not the buttons!
'TO DO Animate opn screen??
'DONE Preview Next pic & BG colour.
SetGW()
OpeningMessage()
LoadPic()
Controls.Remove(openningMsg)
Offsets() 'pos for buttons and main pic and btn sizes
ColourPreview()
GraphicsWindow.DrawResizedImage(pic, gw-60, 60, 50, 50) 'preview
AddButtons()
While "true"
If flag_ShowImage = 1 Then 'load next pic didn't work in event routine
GraphicsWindow.DrawResizedImage(pic, picOffset_X, picOffset_Y, PW, PH)
Controls.SetButtonCaption(btn[3], "Wait a Sec")
LoadPic()
GraphicsWindow.DrawResizedImage(pic, gw-60, 60, 50, 50)
Controls.SetButtonCaption(btn[3], "Show Image")
flag_ShowImage = 0
ElseIf flag_clear = 1 Then
AddButtons() 'add this stuff at the same time the pic preview has loaded
ColourPreview()
GraphicsWindow.DrawResizedImage(pic, gw-60, 60, 50, 50)
flag_clear = 0
EndIf
'Program.Delay(20) not needed there's no events triggered
EndWhile
Sub ButtonClicked
Sound.PlayClickAndWait()
caption = Controls.GetButtonCaption(Controls.LastClickedButton)
If caption = "BG Colour" Then 'can change colour while pic is loading in the event loop
GraphicsWindow.BackgroundColor = colour
colour = GraphicsWindow.GetRandomColor()
ColourPreview()
ElseIf caption = "Make Sound" Then
Sound.PlayChimesAndWait() 'play while event loop is running
ElseIf caption = "Show Image" Then
flag_ShowImage = 1
ElseIf caption = "Clear" Then
ClearScreen() 'clear while pic is loading in the event loop
flag_clear = 1
EndIf
EndSub
Sub AddButtons
GraphicsWindow.BrushColor = "black"
For i = 1 To 4
btn[i] = Controls.AddButton(capt[i], 0,0)
Controls.SetSize(btn[i], size["bw"], size["bh"])
EndFor