b+ Beginners Corner - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Prolific Programmers (https://staging.qb64phoenix.com/forumdisplay.php?fid=26) +---- Forum: bplus (https://staging.qb64phoenix.com/forumdisplay.php?fid=36) +---- Thread: b+ Beginners Corner (/showthread.php?tid=1693) |
RE: b+ Beginners Corner - mnrvovrfc - 05-29-2023 This is pretty cool. But I would remove that beep. Sorry but Wordpad made me hate sound to react to any keypress LOL. I didn't want to change the "Windows Media" settings to do something about it. It's too bad how keyboards are designed these days. Otherwise I would change it so one hand could press [CTRL] (left) or [ALT] (right), and the other hand could use [SHIFT] (up) or [CTRL] (down) so it could behave like a real Ohio Art Etch-and-Sketch. On my keyboard for the left hand, [CTRL] and [ALT] are too wide apart for my taste: [Fn] and [Win] keys in between. Would have to use [SHIFT] and [CTRL] for vertical motion for the left hand, and involve the application key for the right hand so it's a bit more comfortable. On Linux probably could also reassign the "Super" [Win] key but I don't like feeling that I'm using a Macintosh. I highly respect those [Command] keys hugging the spacebar. For a window manager on Linux using the "Super" key to help "design" application windows, it could be changed to [ALT] which ensures the [Win] key won't be involved that well in QB64 programs using _KEYDOWN(). RE: b+ Beginners Corner - bplus - 05-30-2023 Cool Tip for doing Color Walker from Paul Dunn AKA ZXDunny: https://retrocoders.phatcode.net/index.php?topic=584.0 not exactly Beginner's stuff In Paul Dunn's Horizontal coding style we get: Code: (Select All) _Title "Mod 3 Ron77 Color Walker: a | d left or right, w | s for up or down, c for color change" Breaking it down: Code: (Select All) '_Title "Mod 3 Ron77 Color Walker: a|d left or right, w|s for up or down, c for color change" RE: b+ Beginners Corner - bplus - 06-15-2023 Build a Scrolling Text Screen
Code: (Select All)
_Title "Building a Scrolling LED Screen" ' b+ 2021-05-08 Screen _NewImage(1200, 160, 32) _Delay .25 'give screen time to load _ScreenMove _Middle 'and center screen 'scroll some text Text$ = "Try scrolling me for awhile until you got it, then press a key... " lenText = Len(Text$) startTextPos = 1 'put text in sign 15 chars wide in middle of screen print the message moving down 1 character evey frame _Title "Building a Scrolling LED Screen: Step 1 get some code to scroll your message in middle of screen." Do k$ = InKey$ Cls ' two pieces of text? when get to end of text will have less than 15 chars to fill sign so get remainder from front len1 = lenText - startTextPos If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0 ' locate at middle of screen for 15 char long sign _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2) startTextPos = startTextPos + 1 If startTextPos > lenText Then startTextPos = 1 _Display ' no blinking when clear screen so often _Limit 5 ' slow down to see scroll Loop Until Len(k$) ' OK now for the enLARGE M E N T using _PutImage ' our little sign is 16 pixels high and 8 * 15 chars pixels wide = 120 Dim sign As Long sign = _NewImage(120, 16, 32) ' we will store the print image here ' _PUTIMAGE [STEP] [(dx1, dy1)-[STEP][(dx2, dy2)]][, sourceHandle&][, destHandle&][, ][STEP][(sx1, sy1)[-STEP][(sx2, sy2)]][_SMOOTH] ' use same pixel location to _printString as for _PutImage Source rectangle ie (sx1, sy1), -step( sign width and height) ' test screen capture with _putimage and then blowup with _putimage '_PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15) 'Cls '_PutImage , sign, 0 ' stretch to whole screen '_Display 'now that that works do it on the move ' about here I resized the screen to 1200 x 160 to make the text scalable X's 10 ie 120 x 10 wide and 16 x 10 high _Title "Building a Scrolling LED Screen: Step 2 Blow it up by using _PutImage twice once to capture, then to expand" k$ = "" Do k$ = InKey$ Cls ' two pieces of text? when get to end of text will have less than 15 chars to fill sign so get remainder from front len1 = lenText - startTextPos If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0 ' locate at middle of screen for 15 char long sign _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2) _PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15) Cls _PutImage , sign, 0 ' stretch to whole screen _Display ' no blinking when clear screen so often _Limit 5 ' slow down to see scroll startTextPos = startTextPos + 1 If startTextPos > lenText Then startTextPos = 1 Loop Until Len(k$) ' now for a mask just draw a grid test grid draw here 'For x = 0 To _Width Step 10 ' verticals ' Line (x, 0)-(x + 3, _Height), &HFF000000, BF 'Next 'For y = 0 To _Height Step 10 ' Line (0, y)-(_Width, y + 3), &HFF000000, BF 'Next _Title "Building a Scrolling LED Screen: Step 3 Mask or Cover the thing with a grid or grate." ' here is the whole code with all setup variables k$ = "" Do k$ = InKey$ Cls ' two pieces of text? when get to end of text will have less than 15 chars to fill sign so get remainder from front len1 = lenText - startTextPos If len1 < 15 Then len2 = 15 - len1 Else len1 = 15: len2 = 0 ' locate at middle of screen for 15 char long sign _PrintString ((1200 - 15 * 8) / 2, (160 / 2) - 8), Mid$(Text$, startTextPos, len1) + Mid$(Text$, 1, len2) _PutImage , 0, sign, ((1200 - 15 * 8) / 2, (160 / 2) - 8)-Step(119, 15) Cls _PutImage , sign, 0 ' stretch to whole screen ' now for a mask just draw a grid best to draw this and copy and layover screen as another layer ' here QB64 is fast evough to redarw each time For x = 0 To _Width Step 10 ' verticals Line (x, 0)-(x + 3, _Height), &HFF000000, BF Next For y = 0 To _Height Step 10 Line (0, y)-(_Width, y + 3), &HFF000000, BF Next _Display ' no blinking when clear screen so often _Limit 5 ' slow down to see scroll startTextPos = startTextPos + 1 If startTextPos > lenText Then startTextPos = 1 Loop Until Len(k$) Step one is just getting text scrolling in center of screen: Step 2 is enlarging text to fill screen: Step 3 is adding a grid face cover to make the letters appear to be lights: RE: b+ Beginners Corner - GareBear - 06-15-2023 Step 2 and 3 I can read it with out glasses. I like it. Thanks bplus for sharing. RE: b+ Beginners Corner - bplus - 06-15-2023 (06-15-2023, 07:50 PM)GareBear Wrote: Step 2 and 3 I can read it with out glasses. I like it. Thanks bplus for sharing. You will like working with fonts I bet! RE: b+ Beginners Corner - bplus - 06-23-2023 Once again Charlie's post inspires b+ to dig into his files and pull out a better version in his opinion of course Compare this to Charlie's Clay Pigeon https://staging.qb64phoenix.com/showthread.php?tid=1773&pid=17053#pid17053 Code: (Select All) W = 800: H = 600 ' b+ updated 2023-06-23 Looks like I should pull a Terry Richie and cleanup and comment code for teaching purposes, stay tuned... RE: b+ Beginners Corner - CharlieJV - 06-23-2023 (06-23-2023, 02:46 PM)bplus Wrote: Once again Charlie's post inspires b+ to dig into his files and pull out a better version in his opinion of course That's very cool. Let it be known, though, that you are standing tall on electricwalrus' work. At most, I may have added a hair to that height by making it a hair easier to get that FB program ported to QB64pe with that intermediary BAM code. At most. For all I know, it might have been quicker/easier going straight from FB to QB64pe ... RE: b+ Beginners Corner - bplus - 06-23-2023 OK I have "Terryfied" enRitchied the code. Update: I suppose I should refrain from word play with newbies but I wanted to honor Terry Ritchie's work and very notable commenting of code in a humorous way. Terry has been building a great beginner resource here: https://www.qb64tutorial.com/games Code: (Select All) Option _Explicit ' Get into this habit and save yourself grief from Typos BTW you can click the mouse more than once, in fact you can turn the mouse and missile into a heat seeker and curve around back if you over shoot, pretty cool! Look at the nice clean edges I had in the IDE, can't repeat in any code tag??? wait now old code tag looks good and it pastes correctly aligned back in IDE yea! RE: b+ Beginners Corner - TerryRitchie - 06-23-2023 Yikes, that sounds like "terrified" LOL How about "enRitched" instead RE: b+ Beginners Corner - bplus - 06-23-2023 Sure don't want to use your name in vain, "enRitchied" OK? (edit with a t)* BTW never, never, never use single letter constants if you ever hope to modify your code later and change names to make it more readable. *Update: the humor would work better if I learned to spell Terry Ritchie's name correctly, oops sorry again Terry. |