b+ Beginners Corner
#9
Here is a cute one from Ron77 I fixed up a little:
Code: (Select All)
_Title "Mod Ron77 Color Walker, arrows to move, c to cycle color change" 'b+ 2023-05-28
' kinda cute! nice one Ron77

' Notice I put the instructions to the app in the _Title

' We will be using the default Screen 0, Shout out to Pete! :)
' This uses 16 colors 0 to 15

' We will be using _KeyHit for user input because it's real easy to get
' the arrow key numbers in IDE. Just put cursor where you need the number
' Select Tools > Insert Quick Keycode (or shortcut Ctrl+K)
' then press the direction arrow key, BAM! there's your number!

' Notice at Locate under update screen comment, its y, x.
' That's because Locate does Row, Column not x, y like all graphics commands
' eg Pset (x,y), Color
' Row Column are how Print Locations work with Row (Vertical) listed first
' followed by the Column (Horizontal) position.
' That use to mix the hell up in me back with GW BASIC years ago.

DefLng A-Z ' all variables are long unless otherwise spec'd
x = 20
y = 20
c = 12
Color c ' Ron77 started the color at 0 and ha! Aurel is complaining nothing
'         is happening, nice joke on Aurel Ron :)
'
Do
    'update screen
    Locate y, x: Print "@";

    kh = _KeyHit ' see if user hit a key and if so which?
    If kh = 18432 Then ' arrow up
        If y - 1 > 0 Then y = y - 1 Else Beep
    End If
    If kh = 19200 Then ' arrow left
        If x - 1 > 0 Then x = x - 1 Else Beep
    End If
    If kh = 19712 Then ' arrow right
        If x + 1 <= _Width Then x = x + 1 Else Beep
    End If
    If kh = 20480 Then ' arrow down
        If y + 1 <= _Height Then y = y + 1 Else Beep
    End If

    'I did color changes different than Ron, I only updated color after color change
    'and I never set the color at 0 the black background, so maybe Aurel will enjoy
    'my version better ;-))

    If kh = 99 Then ' key c is for color change
        c = c + 1
        If c > 15 Then c = 1 ' if c exceeds 15 the last color at top range set it to 1, not 0
        Color c
        Locate y, x: Print "@"; ' update our @ guy immediately with color change so Aurel knows
    End If
Loop Until kh = 27 ' standard escape clause that johnno always insisted on

It's like a color Etch-A-Sketch:
   

BTW unlike Ron's if you try to go out of bounds of the screen, you are going to hear about it. Beep can be loud enough to make you jump out of your seat if you have volume up, so now consider yourself warned Smile
b = b + ...
Reply


Messages In This Thread
b+ Beginners Corner - by bplus - 05-20-2023, 06:34 PM
RE: b+ Beginners Corner - by vince - 05-20-2023, 06:47 PM
RE: b+ Beginners Corner - by bplus - 05-20-2023, 07:11 PM
RE: b+ Beginners Corner - by PhilOfPerth - 05-26-2023, 12:12 AM
RE: b+ Beginners Corner - by bplus - 05-26-2023, 04:11 PM
RE: b+ Beginners Corner - by PhilOfPerth - 05-26-2023, 11:18 PM
RE: b+ Beginners Corner - by mnrvovrfc - 05-27-2023, 12:15 AM
RE: b+ Beginners Corner - by PhilOfPerth - 05-27-2023, 02:27 AM
RE: b+ Beginners Corner - by bplus - 05-29-2023, 12:07 AM
RE: b+ Beginners Corner - by bplus - 05-29-2023, 01:37 AM
RE: b+ Beginners Corner - by mnrvovrfc - 05-29-2023, 02:29 AM
RE: b+ Beginners Corner - by bplus - 05-30-2023, 04:17 PM
RE: b+ Beginners Corner - by bplus - 06-15-2023, 03:06 PM
RE: b+ Beginners Corner - by GareBear - 06-15-2023, 07:50 PM
RE: b+ Beginners Corner - by bplus - 06-15-2023, 10:42 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 02:46 PM
RE: b+ Beginners Corner - by CharlieJV - 06-23-2023, 03:26 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 08:28 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-23-2023, 09:45 PM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 09:56 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-24-2023, 02:47 AM
RE: b+ Beginners Corner - by bplus - 06-23-2023, 10:02 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 02:35 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 02:52 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 07:48 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-24-2023, 08:02 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 08:40 PM
RE: b+ Beginners Corner - by TerryRitchie - 06-24-2023, 10:07 PM
RE: b+ Beginners Corner - by bplus - 06-24-2023, 09:08 PM
RE: b+ Beginners Corner - by Dimster - 06-24-2023, 09:12 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-24-2023, 11:44 PM
RE: b+ Beginners Corner - by bplus - 06-25-2023, 02:27 PM
RE: b+ Beginners Corner - by OldMoses - 06-25-2023, 05:49 PM
RE: b+ Beginners Corner - by bplus - 06-25-2023, 06:40 PM
RE: b+ Beginners Corner - by OldMoses - 06-25-2023, 08:03 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 01:14 AM
RE: b+ Beginners Corner - by mnrvovrfc - 06-26-2023, 02:26 AM
RE: b+ Beginners Corner - by Ultraman - 06-26-2023, 11:29 AM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 12:17 PM
RE: b+ Beginners Corner - by Ultraman - 06-26-2023, 12:21 PM
RE: b+ Beginners Corner - by Dimster - 06-26-2023, 02:38 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 03:32 PM
RE: b+ Beginners Corner - by bplus - 06-26-2023, 04:48 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 01:29 AM
RE: b+ Beginners Corner - by OldMoses - 06-27-2023, 11:49 AM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 12:40 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-27-2023, 02:12 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 03:22 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-27-2023, 05:21 PM
RE: b+ Beginners Corner - by bplus - 06-27-2023, 05:48 PM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 03:20 AM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 02:54 PM
RE: b+ Beginners Corner - by mnrvovrfc - 06-28-2023, 07:07 PM
RE: b+ Beginners Corner - by Dimster - 06-28-2023, 09:50 PM
RE: b+ Beginners Corner - by bplus - 06-28-2023, 10:27 PM



Users browsing this thread: 25 Guest(s)