Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim as integer scr
- 'Globals
- Dim shared As integer w, h
- Dim shared as String Options(5)
- Dim shared as integer currentIndex
- 'Subs Prototypes
- Declare Sub drawScreen()
- Declare Sub credits()
- Declare Sub startMenu(x as integer, y as integer, fc0 as integer, bc0 as integer, fc1 as integer, bc1 as integer)
- Declare Sub printItem(index as integer, x as integer, y as integer, fc as integer, bc as integer)
- 'Obtain screen details
- scr = Width
- h = HiWord(scr)
- w = LoWord(scr)
- 'Initial values
- currentIndex = 0
- options (0) = "Option 1"
- options (1) = "Option 2"
- options (2) = "Option 3"
- options (3) = "Option 4"
- options (4) = "Option 5"
- 'Main
- drawScreen()
- startMenu(10,5,7,0,15,1)
- credits()
- 'SUB declations
- Private Sub drawScreen()
- Color 0,0
- CLS
- End sub
- Private Sub printItem(index as integer, x as integer, y as integer, fc as integer, bc as integer)
- Locate y,x
- Color fc,bc
- Print Options(index)
- End Sub
- Private Sub startMenu(x as integer, y as integer, fc0 as integer, bc0 as integer, fc1 as integer, bc1 as integer)
- Dim as integer i,j
- j=0
- 'Print list of options
- for i=0 to UBound(options)
- printItem (i, x,y+j,fc0,bc0)
- j=j+1
- next
- printItem (currentIndex, x,y+currentIndex,fc1,bc1)
- do
- While Inkey <> "": Wend
- if MultiKey(1) then
- 'Escape pressed.
- exit Sub
- end if
- if MultiKey(&h50) then
- 'Down arrow key pressed.
- printItem (currentIndex, x,y+currentIndex,fc0,bc0)
- if currentIndex < UBound(Options)-1 then currentIndex = currentIndex + 1
- printItem (currentIndex, x,y+currentIndex,fc1,bc1)
- sleep
- getkey()
- end if
- if MultiKey(&h48) then
- 'Up arrow key pressed.
- printItem (currentIndex, x,y+currentIndex,fc0,bc0)
- if currentIndex > 0 then currentIndex = currentIndex - 1
- printItem (currentIndex, x,y+currentIndex,fc1,bc1)
- sleep
- getkey()
- end if
- if MultiKey(&h1C) then
- 'Enter pressed.
- locate 12,10
- color 15,5
- print "You have selected: " + options(currentIndex)
- sleep
- getkey()
- end if
- While Inkey <> "": Wend
- loop
- end sub
- Private Sub Credits()
- 'Credits
- Color 7,0
- CLS
- print "Selection Menu test. Coded by Velorek 2022."
- End sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement