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 - bplus - 06-23-2023 Oh hey! Here is the unenRitchied AI Missile Guided version called AIM - AI Missile.bas Code: (Select All) W = 800: H = 600 That draws a sort of Hippie message overall when you run it. RE: b+ Beginners Corner - TerryRitchie - 06-24-2023 (06-23-2023, 09:56 PM)bplus Wrote: 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.Yeah, single letter constants and globally shared single letter variables become your worst enemy very quickly. It's tempting to use them at first to quickly type in an idea but they quickly become a headache later on when cleaning up the code. RE: b+ Beginners Corner - Dimster - 06-24-2023 I've written code in QBasic for a Drop Down Menu. I used that old standard code routine of printing one, erase that one, print two, erase two, print three .. printing and erasing was the basic way of creating the drop down effect. There has been so many improvements to the language since then. Has the basic print/erase method changed at all in terms of creating a drop down menu? RE: b+ Beginners Corner - bplus - 06-24-2023 (06-24-2023, 02:35 PM)Dimster Wrote: I've written code in QBasic for a Drop Down Menu. I used that old standard code routine of printing one, erase that one, print two, erase two, print three .. printing and erasing was the basic way of creating the drop down effect. There has been so many improvements to the language since then. Has the basic print/erase method changed at all in terms of creating a drop down menu? Hi Dimster! I think you might of missed where you wanted to post your question, maybe here https://staging.qb64phoenix.com/showthread.php?tid=1768 instead? There are a thousand ways to do this, I was tempted to post some other ways in that post but... I didn't want to hijack. But since you ask in this little corner of forum, I will say basic methods don't change much when QB64pe tries to stay compatible with the past but sure as shoot'n there are new ways always being added to our tool box! So I will show some alternates I considered to do a Multiple Input: Here is short and sweet: Code: (Select All) again: To fix that here is a menu of choices to edit until you get everything as you want: Code: (Select All) _Title "Multiple Input Menu demo" 'b+ 2021-06-11 This allows you to use arrow keys up and down until you press enter on last field: Code: (Select All) Option _Explicit ' to remind what I haven't dim'd B+ mod Cobalt and NOVARSEG and Dav 2021-06-15 I had that titled "best" but Steve has a really nice version that bests mine with popup like menu functioning: (Come to think, there was a slew awhile back. Dav had a nice one too and someone else I think, Pete? ...) Code: (Select All) Screen _NewImage(1280, 720, 32) RE: b+ Beginners Corner - Dimster - 06-24-2023 Those are definitely menus, but I was thinking more along the lines of a drop drown. Here is an example of what I had in mind. This example comes from the old Qbasic coding days and I see where I did change the animation of the drop down from the print/erase to a loop with a delay to slow down the drop. Also, only the "1 - Opening Info" menu item is working here but it gives you a good idea of the drop down effect. Code: (Select All) Cls When you factor in the additional menu item choices of 2,3,4 & 5 , the code can become quite lengthy. Using the modern day QB64PE, I would think the _DELAY command would be drop rate control and "reveal" of the submenu items, as the drop progresses, would be better than the sudden appearance. RE: b+ Beginners Corner - mnrvovrfc - 06-24-2023 (06-24-2023, 07:48 PM)Dimster Wrote: When you factor in the additional menu item choices of 2,3,4 & 5 , the code can become quite lengthy. Using the modern day QB64PE, I would think the _DELAY command would be drop rate control and "reveal" of the submenu items, as the drop progresses, would be better than the sudden appearance. bplus is trying to help you with a solution, because adding menu items your way is an impossible way to program. It doesn't matter if you're doing a "dropdown" or any kind of menu. The thing is you need to use a string array to keep track of the elements of the menu, so you could use your menu-creating code again in the future. With the example you provided, you will be able to create that one application, and then hesitate to do another one the same way again. What if you decided you wanted one menu option to open another menu. Ahh, the sub-menus found in many applications like Libreoffice Writer. It becomes tricky then. Have a double-dimensional string array which is each menu with its distinct set of options. This includes any menu-within-a-menu. Then it requires trickery to show the "main" menus and when to show the sub-menus. I have code that somebody else wrote long ago for QuickBASIC for a simple menu in SCREEN 0, with colors and stuff. However it doesn't restore the screen area under the menu. Basically it clears the screen, puts on the menu, accepts the input and then clears the screen again for the rest of the program execution. I have to go dig into my backups... EDIT: Read the previous post again. So what you want is animations? The dumbass animations I'm still trying to kill on Linux LOL which slow down my computer. Well, then it becomes even more important how you organize your menu. You begin drawing the menu with the first item only, and the box around it. Then a very short pause. Then you redraw the menu, overwriting the bottom of the menu with the second option and restoring the whole box. Then another very short pause. And so on until you have all the menu entries. This is just visual trickery which could affect how the user could interact with the program. I don't know about you but I want snappy response in my programs without discussion. I cannot get it, for example from the QB64 IDE on Linux which is the main reason why I don't use it very much except for formatting source code to post on this forum. RE: b+ Beginners Corner - bplus - 06-24-2023 Sorry @Dimster I was a little off about drop downing, instead my focus was on doing multiple input which is handy for filling out a database form. Never did much with drop down menus but mnrvovrfc is right about using a string array and setting up your code so what you do come up with for drop downs can be reused again in other apps. @TerryRitchie this might be a topic for Game Programming (I just did a quick scan for it and came up empty). I swear I remember seeing menu code of yours sometime ago, maybe mistaken. I will dig around my files. RE: b+ Beginners Corner - bplus - 06-24-2023 Oh maybe we can play around with this starter code: Code: (Select All)
Modify so: 1. the buttons are stacked one above the other to fit more 2. add a parameter xAcross to designate the column to run the buttons down from 3. save the screen section before menu is displayed, display menu then replace the screen section with saved image RE: b+ Beginners Corner - Dimster - 06-24-2023 Hi Minerva - my apologies to bplus if I gave the impression that I did not read his example or run them. I do eagerly read and run the code and always find something new that I hadn't thought of before. Thanks b+. I have worked with a lot of menu styles, even tried to adopt some of those really interesting child window by Tempodi but I seem to always drift back to the efficiency of the Drop Drop. It reduces a lot of screen clutter of multiple displays of menus plus it provides a lot more of the screen to display results of the choices. I'd like to think of myself as knowing how to program but I was sold on Qbasic and just looking over what's available in the language with QB64PE, I'm finding it a little confusing on the best way to use the new syntax/code with the underscore (ie _Delay) and if the various underscored Screen stuff ( ie _Screenhide, _Screenshow) along with defining a window may be a new way to create and place a drop down menu. Love the comment on killing animation. RE: b+ Beginners Corner - TerryRitchie - 06-24-2023 (06-24-2023, 08:40 PM)bplus Wrote: Sorry @Dimster I was a little off about drop downing, instead my focus was on doing multiple input which is handy for filling out a database form. Never did much with drop down menus but mnrvovrfc is right about using a string array and setting up your code so what you do come up with for drop downs can be reused again in other apps.Yes, I have a menu library. If it's not in my library section I'll get it up shortly. |