Posts: 404
Threads: 58
Joined: Apr 2022
Reputation:
14
Talk about modernizing the old Drop Down Menu, wow. I'm not running the latest version of qb64pe so when I tried to run your code b+ it hangs up on _MessageBox but the image you provided...holy cow, what amazing menu choices that could provide...combine that with OldMoses's code and Minerva's animation, plus the hovering mouse by Ulltraman , one could have unlimited Main Menu Boxes popping up thru out the program run with Drop Down Menus for each running in all directions. Drop Down on steroids'.
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
 Colors then it's going to be fonts and colors and fonts for tool tips or whatever you call those mouse over messages... ahem!
Sheesh! Good thing this is a forum where we share our code and if someone has an idea for a mod = modification they can go right ahead and bring their ideas to being just by a couple little tweaks in code!
If it's a really good mod, please share with the rest of us! I do that all the time.
We ALL stand on the shoulders of not just giants but all who come before that share their documented ideas.
We are the Makers of History!
(oh and try to keep up with at least a 4 month old QB64pe version, ahem...)
b = b + ...
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
06-26-2023, 04:48 PM
(This post was last modified: 06-26-2023, 07:05 PM by bplus.)
Sorry for disruption of thought flow in this thread but from feedback at another forum about bombs being visible, I've mod the last version of: "b+ Missile Command EnRitchied" with the _Hypot substitutions talked about in _Hypot Word for Day here:
https://qb64phoenix.com/forum/showthread...9#pid17129
the size of missiles, the color and size of bombs and also a tiny fix to center missiles at base on the "^" character, so now the official b+ version looks like this:
Code: (Select All) Option _Explicit ' Get into this habit and save yourself grief from Typos
_Title "Missile Command EnRitchied" ' another b+ mod 2023-06-24, replace distance with _Hypot.
' I probably picked up this game at the JB forum some years ago.
' Get Constants, Shared Variables and Arrays() declared. These Will Start with Capital Letters.
' Get Main module variables and arrays declared with starting lower case letters for local.
' This is what Option _Explicit helps, by forcing us to at least declare these before use.
' While declaring, telling QB64 the Type we want to use, we can also give brief description.
Const ScreenWidth = 800, ScreenHeight = 600 ' for our custom screen dimensions
Dim As Integer bombX, bombY ' incoming bomb screen position to shoot down
Dim As Single bombDX, bombDY ' DX and DY mean change in X position and Y position
Dim As Integer missileX, missileY ' missile position
Dim As Single missileDX, missileDY ' change X and Y of Missile position
Dim As Integer hits, misses ' score hits and misses
Dim As Integer mouseDistanceX, mouseDistanceY ' for calculations of missile DX, DY direction
Dim As Single distance ' ditto
Dim As Integer radius ' drawing hits with target like circles
Dim As Integer boolean ' to shorten the code line with a bunch of OR tests
Screen _NewImage(ScreenWidth, ScreenHeight, 32) ' sets up a graphics screen with custom dimensions
' the 32 is for _RGB32(red, green, blue, alpha) coloring.
'
_ScreenMove 250, 60 ' this centers screen in my laptop, you may need different numbers
InitializeForRound: ' reset game and start a round with a bomb falling
Cls
bombX = Rnd * ScreenWidth ' starts bomb somewhere across the screen
bombY = 0 ' starts bomb at top of screen
bombDX = Rnd * 6 - 3 ' pick rnd dx = change in x between -3 and 3
bombDY = Rnd * 3 + 3 ' pick rnd dy = change in y between 3 and 6, > 0 for falling
missileX = ScreenWidth / 2 ' missile base at middle across screen
missileY = ScreenHeight - 4 ' missile launch point at missile base is nearly at bottom of screen
missileDX = 0 ' missile is not moving awaiting mouse click for direction
missileDY = 0 ' ditto
distance = 0 ' distance of mouse click to missile base
Do
'what's the score?
_Title "Click mouse to intersect incoming Hits:" + Str$(hits) + ", misses:" + Str$(misses)
_PrintString (400, 594), "^" ' draw missle base = launch point
While _MouseInput: Wend ' poll mouse to get update
If _MouseButton(1) Then ' the mouse was clicked calc the angle from missile base
mouseDistanceX = _MouseX - missileX
mouseDistanceY = _MouseY - missileY
'distance = (mouseDistanceX ^ 2 + mouseDistanceY ^ 2) ^ .5
' rewrite the above line using _Hypot() which is hidden distance forumla
distance = _Hypot(mouseDistanceX, mouseDistanceY)
missileDX = 5 * mouseDistanceX / distance
missileDY = 5 * mouseDistanceY / distance
End If
missileX = missileX + missileDX ' update missile position
missileY = missileY + missileDY ' ditto
bombX = bombX + bombDX ' update bomb position
bombY = bombY + bombDY ' ditto
' I am about to use a boolean variable to shorten a very long IF code line
' boolean is either 0 or -1 when next 2 statements are execued
' -1/0 or True/False is everything still in screen?
boolean = missileX < 0 Or missileY < 0 Or bombX < 0 Or bombY < 0
boolean = boolean Or missileX > ScreenWidth Or bombX > ScreenWidth Or bombY > ScreenHeight
If boolean Then ' done with this boolean
' reuse boolean to shorten another long code line checking if bomb and missile in screen
boolean = bombY > ScreenHeight Or missileX < 0 Or missileY < 0 Or missileX > ScreenWidth
If boolean Then misses = misses + 1
GoTo InitializeForRound
End If
' if the distance between missle and bomb < 20 pixels then the missile got the bomb, a hit
'If ((missileX - bombX) ^ 2 + (missileY - bombY) ^ 2) ^ .5 < 20 Then ' show strike as target
' rewrite the above line using _Hypot() which is hidden distance forumla
If _Hypot(missileX - bombX, missileY - bombY) < 20 Then
For radius = 1 To 20 Step 4 ' draw concetric circles to show strike
Circle ((missileX + bombX) / 2, (missileY + bombY) / 2), radius
_Limit 60
Next
hits = hits + 1 ' add hit to hits score
GoTo InitializeForRound
Else
Circle (missileX + 4, missileY), 2, &HFFFFFF00 '+4 center on ^ base draw missle yellow
Circle (bombX, bombY), 2, &HFF0000FF ' draw bomb blue
End If
_Limit 20
Loop
b = b + ...
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
06-27-2023, 01:29 AM
(This post was last modified: 06-27-2023, 01:31 AM by bplus.)
OK some more work done with Drop Menu's. Mouse Over now high-lights the menu Items. The code has been adjusted to take very long strings for Menu Items as opposed to attempting tool tips with mouse-overs. And now if you click outside a dropped menu, you canceled or escaped the dropped menu selection process. Changed colors too.
Code: (Select All)
| | | Option _Explicit | | _Title "Drop Menu more! function test" | | | | | | | | | | | | Const ButtonW = 100, ButtonH = 20 | | Type BoxType | | As String Label | | As Long LeftX, TopY, BoxW, BoxH | | End Type | | | | Dim Shared As Integer NBoxes | | NBoxes = 72 | | Dim Shared Boxes(1 To NBoxes) As BoxType | | Dim As Integer i, x, y, mz, nItems, choice | | ReDim menu$(1 To 1) | | Dim s$ | | | | Screen _NewImage(800, 600, 32) | | _ScreenMove 250, 50 | | _PrintMode _KeepBackground | | Cls | | | | x = 0: y = 0 | | For i = 1 To NBoxes | | Boxes(i).Label = "Box" + Str$(i) | | Boxes(i).LeftX = x: Boxes(i).TopY = y | | Boxes(i).BoxW = ButtonW | | Boxes(i).BoxH = ButtonH | | If (x + 2 * ButtonW) > _Width Then | | x = 0: y = y + ButtonH | | Else | | x = x + ButtonW | | End If | | DrawTitleBox i | | Next | | | | Do | | mz = MouseZone% | | If mz Then | | nItems = Int(Rnd * 10) + 1 | | ReDim menu$(1 To nItems) | | For i = 1 To nItems | | s$ = "Box" + Str$(mz) + " Menu Item:" + Str$(i) | | s$ = s$ + " with extra, extra, long description." | | menu$(i) = s$ | | Next | | choice = getButtonNumberChoice%(Boxes(mz).LeftX, Boxes(mz).TopY, menu$()) | | If choice = 0 Then s$ = "You quit menu by clicking outside of it." Else s$ = menu$(choice) | | _MessageBox "Drop Menu Test", "Your Menu Choice was: " + s$, "info" | | End If | | _Limit 30 | | Loop Until _KeyDown(27) | | | | Sub DrawTitleBox (i) | | Line (Boxes(i).LeftX + 1, Boxes(i).TopY + 1)-Step(ButtonW - 2, ButtonH - 2), &HFF550088, BF | | Color &HFFFFFFFF | | _PrintString (Boxes(i).LeftX + (ButtonW - _PrintWidth(Boxes(i).Label)) / 2, _ | | Boxes(i).TopY + ButtonH / 2 - 8), Boxes(i).Label | | End Sub | | | | Sub DrawChoiceBox (highliteTF%, leftX, topY, BoxW As Integer, S$) | | If highliteTF% Then | | Line (leftX, topY)-Step(BoxW, ButtonH), &HFFAAAAAA, BF | | Color &HFF333333 | | _PrintString (leftX + (BoxW - _PrintWidth(S$)) / 2, topY + ButtonH / 2 - 8), S$ | | Else | | Line (leftX, topY)-Step(BoxW, ButtonH), &HFF333333, BF | | Color &HFFAAAAAA | | _PrintString (leftX + (BoxW - _PrintWidth(S$)) / 2, topY + ButtonH / 2 - 8), S$ | | End If | | Line (leftX, topY)-Step(BoxW, ButtonH), &HFF000000, B | | End Sub | | | | Function MouseZone% | | | | | | | | | | | | | | | | Dim As Integer i, mb, mx, my | | | | While _MouseInput: Wend | | mb = _MouseButton(1) | | If mb Then | | _Delay .25 | | mx = _MouseX: my = _MouseY | | For i = 1 To NBoxes | | If mx > Boxes(i).LeftX And mx < Boxes(i).LeftX + Boxes(i).BoxW Then | | If my > Boxes(i).TopY And my < Boxes(i).TopY + Boxes(i).BoxH Then | | MouseZone% = i: Exit Function | | End If | | End If | | Next | | End If | | End Function | | | | Function getButtonNumberChoice% (BoxX As Integer, BoxY As Integer, choice$()) | | | | | | | | Dim As Integer ub, lb, b | | Dim As Integer longest | | Dim As Integer menuW, menuX | | Dim As Integer mx, my, mb | | Dim As Long Save | | | | ub = UBound(choice$): lb = LBound(choice$) | | For b = lb To ub | | If Len(choice$(b)) > longest Then longest = Len(choice$(b)) | | Next | | If (longest + 2) * 8 > ButtonW Then | | menuW = (longest + 2) * 8 | | If BoxX < _Width / 2 - 3 Then | | menuX = BoxX | | Else | | menuX = BoxX + ButtonW - menuW | | End If | | Else | | menuW = ButtonW | | menuX = BoxX | | End If | | Save = _NewImage(_Width, _Height, 32) | | _PutImage , 0, Save | | Do | | For b = lb To ub | | DrawChoiceBox 0, menuX, BoxY + b * ButtonH, menuW, choice$(b) | | Next | | While _MouseInput: Wend | | mx = _MouseX: my = _MouseY: mb = _MouseButton(1) | | For b = lb To ub | | If mx > menuX And mx <= menuX + menuW Then | | If my >= BoxY + b * ButtonH And my <= BoxY + b * ButtonH + ButtonH Then | | If mb Then | | _PutImage , Save, 0 | | _FreeImage Save | | | | | | getButtonNumberChoice% = b: _Delay .25: _AutoDisplay: Exit Function | | Else | | | | DrawChoiceBox -1, menuX, BoxY + b * ButtonH, menuW, choice$(b) | | End If | | End If | | End If | | Next | | If mb Then | | _PutImage , Save, 0 | | _FreeImage Save | | | | | | getButtonNumberChoice% = 0: _Delay .25: _AutoDisplay: Exit Function | | End If | | _Display | | _Limit 60 | | Loop | | End Function |
b = b + ...
Posts: 293
Threads: 15
Joined: Apr 2022
Reputation:
37
Nice job. Seems to work flawlessly.
I've never tried "mouseover" tool tips, the timing issues seem a bit challenging, but I used a right click context help scheme for control buttons in a project. It used a separate text file for text bubble contents, so it wasn't suitable for a stand alone executable.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
Thanks OldMoses, yeah I considered a sort of Window View (or is it View Window?) for doing messages from the application, sort of like an app narrator that makes comments on the stuff you are doing in the real time run. That would keep all comments in one place out of the way of the main screen program. A Dialog without having to open and close all the time!
I need old or new project that will truly test the use of the menu, that is where the rubber meets the road!
A smallish app that really needs a menu for simple flexibility... actually several little tests would be better.
Anyone have any ideas? I will up your rep points for good ones ;-))
b = b + ...
Posts: 1,432
Threads: 58
Joined: Jul 2022
Reputation:
52
The "mini-mods" and their offerings!
For each project, have an option to read what the project is about (if it's a library what it is used for), to see the source code, to accept the mission of "to do" for the project, to look at a couple of examples of the code in action, and more.
Or if not, something taken from the documentation of one of Terry's libraries which I mention here as example. Subs and functions, one by one as menu choice, what each one does with a brief example and with pictures. I sort of liked the "menu" and "sprite" libraries LOL, still remember the "American theme" for the menu and the princess "Peach" being two sprites high while Mario was one.
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
06-27-2023, 03:22 PM
(This post was last modified: 06-27-2023, 03:23 PM by bplus.)
Thankyou @mnrvovrfc for helping me with some ideas.
Ah for testing Subs and Functions with different parameters, maybe?
Definitely have to establish a File Menu: New, Load, Save, Save As... Sure and an About File with source code too, sure!
Ah! another reason to review Terry's tut, beautiful!
b = b + ...
Posts: 1,432
Threads: 58
Joined: Jul 2022
Reputation:
52
06-27-2023, 05:21 PM
(This post was last modified: 06-27-2023, 05:22 PM by mnrvovrfc.)
But this wasn't about drawers, or is it now just a menu bar?
Each drawer could be:
Terry's sprite library.
Terry's button library.
Steve's "keyhit" library.
Another one of Steve's libraries.
Balderdash's URL thing.
and so on.
For each drawer, choose at least two subprograms or functions.
Each subprogram or function, as choice then would give up the description on how to call it, what does it do, and an example of it in action. An example could be a screenshot of it, or an animated GIF file of it (can't be too big though) or could encourage the user to copy the source code, paste it into the QB64 IDE and run it in his/her own time.
Like:
Code: (Select All) +-------------------------------------------+
+__value% = buttoncheck%(buttonhandle%)_____+
+___________________________________________+
+_"buttoncheck%" function returns the state_+
+_of the button that was previously_________+
+_allocated in "buttonhandle%"._____________+
+___________________________________________+
+_Example:__________________________________+
+___________________________________________+
+__screen _newimage(640, 480, 32)___________+
+__mybut% = initbutton%("switch.jpeg", _ ___+
+___________64, 64, 0, 64)__________________+
+__locatebutton% 100, 100, mybut%___________+
+__do_______________________________________+
+_ _limit 600_______________________________+
+__thisbut% = buttoncheck%(mybut%)__________+
+__loop until thisbut%______________________+
+__system___________________________________+
+-------------------------------------------+
LOL but this is for something I wrote not Terry...
An additional drawer menu choice could have one example program putting to work as many subprograms as possible from the same library.
But this thing isn't going to have 70 drawers LOL. Maybe ten or so. Also remember to put on the quirk that Dimster desires... the pulldown animation.
<-- This is from a little kid begging, just proposals being made.
Posts: 4,146
Threads: 187
Joined: Apr 2022
Reputation:
253
(06-27-2023, 05:21 PM)mnrvovrfc Wrote: But this wasn't about drawers, or is it now just a menu bar?
Each drawer could be:
Terry's sprite library.
Terry's button library.
Steve's "keyhit" library.
Another one of Steve's libraries.
Balderdash's URL thing.
and so on.
For each drawer, choose at least two subprograms or functions.
Each subprogram or function, as choice then would give up the description on how to call it, what does it do, and an example of it in action. An example could be a screenshot of it, or an animated GIF file of it (can't be too big though) or could encourage the user to copy the source code, paste it into the QB64 IDE and run it in his/her own time.
Like:
Code: (Select All) +-------------------------------------------+
+__value% = buttoncheck%(buttonhandle%)_____+
+___________________________________________+
+_"buttoncheck%" function returns the state_+
+_of the button that was previously_________+
+_allocated in "buttonhandle%"._____________+
+___________________________________________+
+_Example:__________________________________+
+___________________________________________+
+__screen _newimage(640, 480, 32)___________+
+__mybut% = initbutton%("switch.jpeg", _ ___+
+___________64, 64, 0, 64)__________________+
+__locatebutton% 100, 100, mybut%___________+
+__do_______________________________________+
+_ _limit 600_______________________________+
+__thisbut% = buttoncheck%(mybut%)__________+
+__loop until thisbut%______________________+
+__system___________________________________+
+-------------------------------------------+
LOL but this is for something I wrote not Terry...
An additional drawer menu choice could have one example program putting to work as many subprograms as possible from the same library.
But this thing isn't going to have 70 drawers LOL. Maybe ten or so. Also remember to put on the quirk that Dimster desires... the pulldown animation. 
<-- This is from a little kid begging, just proposals being made.
Drawers! I forgot I used that expression, drop your drawers, but yeah they could be drawers and we need a routine to put stuff in and edit those drawers. We're cooking with butter now!
b = b + ...
|