Challenge 4 - Colour buttons - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Challenges (https://litdev.uk/mybb/forumdisplay.php?fid=5) +--- Thread: Challenge 4 - Colour buttons (/showthread.php?tid=124) Pages:
1
2
|
Challenge 4 - Colour buttons - litdev - 09-04-2024 Create some buttons that when pressed change the background colour of the GraphicsWindow. As an extra challenge, try to make it so that the buttons are suitably coloured - no extensions! RE: Challenge 4 - Colour buttons - AbsoluteBeginner - 09-04-2024 (translated by Google translator) Hi all. For those who are gambling people, this challenge can be made more difficult. First, let the program itself choose one of the buttons at random. And then let the person choose the button he wants. If you count the number of coincidences between the choice of a program and a person, you can check whether your intuition differs from the statistical probability of coincidences. What if it turns out that you have paranormal abilities? What if you can guess or be wrong much more often than expected by probability theory? RE: Challenge 4 - Colour buttons - jrmrhrb00 - 09-04-2024 Button1=Controls.AddButton("My Button1",0,0) Button2 = Controls.AddButton("My Button2",0,30) Controls.ButtonClicked=OnButtonClicked Sub OnButtonClicked If Controls.LastClickedButton = "Button1" then GraphicsWindow.BackgroundColor="Blue" Elseif Controls.LastClickedButton = "Button2" then GraphicsWindow.BackgroundColor= "Green" EndIf endsub JR RE: Challenge 4 - Colour buttons - Scout - 09-04-2024 Code: Red = 0 RE: Challenge 4 - Colour buttons - litdev - 09-05-2024 ZJLF704.000 RE: Challenge 4 - Colour buttons - Scout - 09-05-2024 Great! This means you can create buttons with other shapes and not just rectangular ones. For example, use the triangle-shaped arrow keys to change values or scrolling. RE: Challenge 4 - Colour buttons - WhTurner - 09-07-2024 Here is my solution for a colour button program: Code: GraphicsWindow.Show() RE: Challenge 4 - Colour buttons - Scout - 09-07-2024 Dear SmallBasic friends, shouldn't we all just copy the button name into a variable and work with it? The use of the internal name is very confusing for beginners because it assumes knowledge of the internals. In my opinion, using it in variables is also simpler and more elegant and is more appropriate for a high-level language. What do you think? RE: Challenge 4 - Colour buttons - AbsoluteBeginner - 09-07-2024 (translated by Google translator) Hello. I can't quite understand your words. When creating a button, we assign its internal name to a variable. The developer assigns the name of this variable himself. He can use the name that is most convenient and understandable to him. I don't understand what problem you're talking about. RE: Challenge 4 - Colour buttons - jrmrhrb00 - 09-08-2024 Scout, Just like AB I don't understand what your asking. Could you give an example? JR |