Author Topic: Multiple Panels  (Read 6945 times)

0 Members and 1 Guest are viewing this topic.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Multiple Panels
« on: January 18, 2022, 04:40:45 am »
Quick question.

I am thinking of modifying an old text game. I am toying with the idea of having multiple 'windows/panels' to view the main game display; games stats and user/computer feedback.

Are there any tutorials/examples that I can help?

J
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Multiple Panels
« Reply #1 on: January 18, 2022, 05:21:48 am »
Absolute easiest way is the use multiple screens and then putimage them onto a main display.

LeftFrame = _NEWIMAGE(200, 720, 32)
RightFrame = _NEWIMAGE(200, 720, 32)
CenterFrame = _NEWIMAGE(624, 720, 32)
DisplayScreen = _NEWIMAGE(1024, 720, 32)

SCREEN DisplayScreen

With the above setup, you now have three panels to work with.  Use _DEST with LeftFrame, for example, to put your list of commands.  (Status, Skill, Equip, Quest, Save...)  Use _DEST with _RightFrame to place information like Day, Hour, Map Location, whatever..   With CenterFrame, you can display your map, or text, or whatever you need...

Then just _PUTIMAGE those frames onto your DisplayScreen and _DISPLAY them.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Multiple Panels
« Reply #2 on: January 18, 2022, 05:39:39 am »
Thanks, Steve. I'm not sure if anything will come of this game yet. I'm still trying to figure out how to do it. But, with the examples you have provided, it should help out with the display. Cool.

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Multiple Panels
« Reply #3 on: January 18, 2022, 12:22:05 pm »
Hey @johnno56

Would this happen to be about a certain Star Trek Game that I've been expecting from you for awhile? ;-))

What Steve describes is really nice you can work on each image independent of the others and as he said just _putimage (x, y)-step(imgWidth * scale, imgHeight * scale), img#, 0 (0=screen) when needed. x, y screen coord of top left corner, scale allows zoom in or out.
« Last Edit: January 18, 2022, 12:29:49 pm by bplus »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Multiple Panels
« Reply #4 on: January 18, 2022, 12:29:03 pm »
A working style example for you, just to showcase the display using the above method:

Code: QB64: [Select]
  1. LF = _NewImage(200, 720, 32)
  2. RF = _NewImage(200, 720, 32)
  3. CF = _NewImage(600, 720, 32)
  4. DisplayScreen = _NewImage(1024, 720, 32)
  5.  
  6. Screen DisplayScreen
  7.  
  8. 'Stuff to print ot left side
  9. Cls , &HFF0000AA
  10. Color , 0
  11. Print "Joe Blow"
  12. Print "Age: 18"
  13. Print "Sex: M"
  14. Print "ATK: 18:" 'attack
  15. Print "DEF: 12" 'deffense
  16. Print "MAT: 08" 'magic attack
  17. Print "MDF: 05" 'magic defense
  18. Print "Health: 102 / 126"
  19. Print "Mana  : 12  / 12"
  20.  
  21. 'Stuff to print to the right side
  22. Cls , &HFF0000AA
  23. Color , 0
  24. Print "Day: 01"
  25. Print "Location: Home"
  26. Print "Time: 07:00 AM"
  27. Print "Directions Available:"
  28. Print "North"
  29. Print "Bed"
  30.  
  31. 'Stuff to print to the center area
  32. Print "You wake up in your bed, in your home, with a hangover.  The sun is high in the sky and your alarm either failed to go off this morning, or else you were simply too drunk and hungover to respond to it.  Yesterday you were fired at work, and last night you spent drinking away your worries and concerns until into the wee hours of the morning."
  33. Print "In the room is your dirty clothes which are scattered all across the floor, your closet where you keep your clothes and extra blankets and such for the bed, and a small nightside table where you keep your loaded 45, in case of home invasion while you sleep.  You live in a rough neighborhood after all!"
  34. Print "What do you want to do now? "
  35.  
  36. _Dest DisplayScreen
  37.     Cls
  38.     _PutImage (0, 0), LF, DisplayScreen
  39.     _PutImage (824, 0), RF, DisplayScreen
  40.     _PutImage (210, 0), CF, DisplayScreen
  41.     _PrintString (210, 700), "=>" + user$
  42.     _Limit 30
  43.     _Display
  44.  

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline madscijr

  • Seasoned Forum Regular
  • Posts: 295
    • View Profile
Re: Multiple Panels
« Reply #5 on: January 18, 2022, 01:09:50 pm »
A working style example for you, just to showcase the display using the above method:

Wow, this should really simplify a lot of things I have been doing the hard way. Thanks for sharing!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Multiple Panels
« Reply #6 on: January 18, 2022, 02:14:28 pm »
Thanks, Steve. Much appreciated. I realize the use of coloured panels (to clearly display the individual areas) but most of all, I like the colour.
Another related question. How would I create panels like: two panels across the screen and a third panel below both but is the full width of the main screen... I hope I have described that correctly...
Logic is the beginning of wisdom.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Multiple Panels
« Reply #7 on: January 18, 2022, 02:30:58 pm »
bplus,

Based on my latest post, you may be lead to believe that the layout may be 'Star Trek' related... but in this case, even thought the overall layout will be similar, it will be used to cobble together David Ahl's "Seabat". I have no idea if this is going to work. The mongrel of a game uses line numbers. I would prefer no line numbers. But my lack of skill dictates, for me anyway, that kind of conversion is "not on the table"....

There was a far superior version (seatbat 2.0) that was made in 14-Jun-2011 by Vincent Erickson using freebasic?
Graphics, sound etc... Very cool. I have the source codes for all three versions if you are interested? (original, V1.0 and V2.03)

I suppose a study of how V2 was written might help in bypassing all those line numbers from the original version... lol

ps: I have been expecting a 'certain game' as well... I suppose it would be a good idea to get it done... before I "shuffle off"... lol
Logic is the beginning of wisdom.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Multiple Panels
« Reply #8 on: January 18, 2022, 03:01:11 pm »
Thanks, Steve. Much appreciated. I realize the use of coloured panels (to clearly display the individual areas) but most of all, I like the colour.
Another related question. How would I create panels like: two panels across the screen and a third panel below both but is the full width of the main screen... I hope I have described that correctly...

Do you mean something like the following?

Code: [Select]
LF = _NewImage(512, 300, 32)
RF = _NewImage(512, 300, 32)
CF = _NewImage(1024, 420, 32)
DisplayScreen = _NewImage(1024, 720, 32)

Screen DisplayScreen

'Stuff to print ot left side
_Dest LF
Cls , &HFF0000AA
Color , 0
Print "Joe Blow"
Print
Print "Age: 18"
Print "Sex: M"
Print
Print "ATK: 18:" 'attack
Print "DEF: 12" 'deffense
Print "MAT: 08" 'magic attack
Print "MDF: 05" 'magic defense
Print
Print "Health: 102 / 126"
Print "Mana  : 12  / 12"

'Stuff to print to the right side
_Dest RF
Cls , &HFF7700AA
Color , 0
Print "Day: 01"
Print "Location: Home"
Print "Time: 07:00 AM"
Print
Print "Directions Available:"
Print "North"
Print "Bed"

'Stuff to print to the center area
_Dest CF
Print "You wake up in your bed, in your home, with a hangover.  The sun is high in the sky and your alarm either failed to go off this morning, or else you were simply too drunk and hungover to respond to it.  Yesterday you were fired at work, and last night you spent drinking away your worries and concerns until into the wee hours of the morning."
Print ""
Print "In the room is your dirty clothes which are scattered all across the floor, your closet where you keep your clothes and extra blankets and such for the bed, and a small nightside table where you keep your loaded 45, in case of home invasion while you sleep.  You live in a rough neighborhood after all!"
Print
Print "What do you want to do now? "
Print

_Dest DisplayScreen
Do
    Cls
    _PutImage (0, 0), LF, DisplayScreen
    _PutImage (512, 0), RF, DisplayScreen
    _PutImage (0, 300), CF, DisplayScreen
    _PrintString (0, 700), "=>" + user$
    _Limit 30
    _Display
Loop Until _KeyHit
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Multiple Panels
« Reply #9 on: January 18, 2022, 03:40:08 pm »
bplus,

Based on my latest post, you may be lead to believe that the layout may be 'Star Trek' related... but in this case, even thought the overall layout will be similar, it will be used to cobble together David Ahl's "Seabat". I have no idea if this is going to work. The mongrel of a game uses line numbers. I would prefer no line numbers. But my lack of skill dictates, for me anyway, that kind of conversion is "not on the table"....

There was a far superior version (seatbat 2.0) that was made in 14-Jun-2011 by Vincent Erickson using freebasic?
Graphics, sound etc... Very cool. I have the source codes for all three versions if you are interested? (original, V1.0 and V2.03)

I suppose a study of how V2 was written might help in bypassing all those line numbers from the original version... lol

ps: I have been expecting a 'certain game' as well... I suppose it would be a good idea to get it done... before I "shuffle off"... lol

I think I found it:
Code: QB64: [Select]
  1. 10 Print Tab(33); "SEABAT"
  2. 20 Print Tab(15); "CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 40 Rem
  4. 50 Rem  PROGRAM BY VINCENT ERIKSON
  5. 60 Rem   ORIGINALLY IN H.P. BASIC
  6. 70 Rem   CONVERTED TO MICROSOFT BASIC BY S.N.
  7. 80 Rem
  8. 90 Rem  NOTE THE FOLLOWING ABOUT CONVERSIONS:
  9. 100 Rem   1) RESTORE <LINE NUMBER> MEANS TO SET THE DATA
  10. 110 Rem      POINTER TO THE SPECIFIED LINE. THIS IS ONLY
  11. 120 Rem      PRESENT IN TRS-80 LEVEL II AND CP/M BASIC.
  12. 130 Rem      FOR OTHERS, IMPROVISE BY USING A RESTORE, AND
  13. 140 Rem      FOR...NEXT WITH READ STATEMENTS TO SKIP OVER
  14. 150 Rem      THE DATA THAT SHOULD BE IGNORED.
  15. 160 Rem
  16. 170 Rem   2) LOGICAL EXPRESSIONS ARE USED OFTEN.  A TRUE
  17. 180 Rem      EXPRESSION EVALUATES AS A (-1) AND A FALSE EXPRESSION
  18. 190 Rem      EVALUATES AS A (0).  THUS IF THE PROGRAM SAYS:
  19. 200 Rem          X = (D<50)
  20. 210 Rem      IT MEANS, LET X=0 IF D>=50, AND LET X=-1 IF D<50.
  21. 220 Rem      AGAIN, IMPROVISE IF YOUR BASIC DOESN'T HAVE THIS
  22. 230 Rem      (BUT ALL MICROSOFT BASICS DO.)
  23. 240 Rem
  24. 245 Rem   The real name of this program is, "Underwater Pie Lob"
  25. 250 Rem *** PROGRAM FOLLOWS ***
  26. 260 Rem ***
  27. 270 Dim A(20, 20), D(9)
  28. 280 Print "WHAT IS YOUR NAME";
  29. 290 Input N$
  30. 300 Print
  31. 310 Rem *** SET UP AREA ***
  32. 320 For I = 1 To 20
  33.    322 For J = 1 To 20
  34.        324 A(I, J) = 0
  35.    326 Next J
  36. 328 Next I
  37. 330 Rem *** ISLAND ***
  38. 340 Restore 6300
  39. 350 For X = 7 To 13
  40.    360 For Y = 7 To 12
  41.        370 Read A(X, Y)
  42.    380 Next Y
  43. 390 Next X
  44. 400 Rem *** SUB ***
  45. 410 S1 = 10: S2 = 10
  46. 420 A(S1, S2) = 2
  47. 430 Rem *** ENEMY SHIPS ***
  48. 440 S = Int(Rnd(1) * 16) + 15
  49. 450 Restore 6090
  50. 460 For X = 1 To (Int(Rnd(1) * 4) + 1) * 2 - 1
  51.    470 Read D8, D9
  52. 480 Next X
  53. 490 For X = 1 To S
  54.    500 X1 = Int(Rnd(1) * 20) + 1
  55.    510 X2 = Int(Rnd(1) * 20) + 1
  56.    520 If A(X1, X2) <> 0 Then 500
  57.    530 A(X1, X2) = 3
  58. 540 Next X
  59. 550 Print "YOU MUST DESTROY"; S; "ENEMY SHIPS TO WIN "; N$; "."
  60. 560 Rem *** HEADQUARTERS ***
  61. 570 S3 = Int(Rnd(1) * 20) + 1
  62. 580 S4 = Int(Rnd(1) * 20) + 1
  63. 590 If A(S3, S4) <> 0 Then 570
  64. 600 A(S3, S4) = 4
  65. 610 Rem *** UNDERWATER MINES ***
  66. 620 For X = 1 To Int(Rnd(1) * 8) + 8
  67.    630 X1 = Int(Rnd(1) * 20) + 1
  68.    640 X2 = Int(Rnd(1) * 20) + 1
  69.    650 If A(X1, X2) <> 0 Then 630
  70.    660 A(X1, X2) = 5
  71. 670 Next X
  72. 680 Rem *** SEA MONSTERS ***
  73. 690 For X = 1 To 4
  74.    700 X1 = Int(Rnd(1) * 18) + 2
  75.    710 X2 = Int(Rnd(1) * 18) + 2
  76.    720 If A(X1, X2) <> 0 Then 700
  77.    730 A(X1, X2) = 6
  78.    740 Restore 6090
  79.    750 For Y = 1 To Int(Rnd(1) * 8) + 1
  80.        760 Read M1, M2
  81.    770 Next Y
  82. 780 Next X
  83. 790 Rem *** SET STARTING VALUES ***
  84. 800 For I = 1 To 9
  85.    802 D(I) = 0
  86. 804 Next I
  87. 810 C = 30
  88. 820 P = 6000
  89. 830 F = 2500
  90. 840 T = 10
  91. 850 M = 3
  92. 860 D = 100
  93. 870 D2 = 2
  94. 880 Rem *** COMMAND SECTION ***
  95. 890 Print: Print: Print "WHAT ARE YOUR ORDERS "; N$;
  96. 900 Input O
  97. 910 On Int(O + 1) GOTO 1040, 1680, 2220, 2680, 3250, 3410, 3700, 3880, 4400, 4660
  98. 920 Print "THE COMMANDS ARE:"
  99. 930 Print "     #0: NAVIGATION"
  100. 940 Print "     #1: SONAR"
  101. 950 Print "     #2: TORPEDO CONTROL"
  102. 960 Print "     #3: POLARIS MISSILE CONTROL"
  103. 970 Print "     #4: MANUEVERING"
  104. 980 Print "     #5: STATUS/DAMAGE REPORT"
  105. 990 Print "     #6: HEADQUARTERS"
  106. 1000 Print "     #7: SABOTAGE"
  107. 1010 Print "     #8: POWER CONVERSION"
  108. 1020 Print "     #9: SURRENDER"
  109. 1030 GoTo 890
  110. 1040 Rem *** #0: NAVIGATION ***
  111. 1050 If D(1) >= 0 Then 1080
  112. 1060 Print "ENGINES ARE UNDER REPAIR "; N$; "."
  113. 1070 GoTo 890
  114. 1080 If C > 8 Then 1110
  115. 1090 Print "NOT ENOUGH CREW TO MAN THE ENGINES "; N$; "."
  116. 1100 GoTo 890
  117. 1110 D1 = 1 - ((.23 + Rnd(1) / 10) * (-(D <= 50)))
  118. 1120 GoSub 6090
  119. 1130 Print "POWER AVAILABLE="; P; ". POWER TO USE";
  120. 1140 Input P1
  121. 1150 If P1 < 0 Or P1 > P Then 1130
  122. 1160 If P1 <= 1000 Then 1210
  123. 1170 If Rnd(1) < .43 Then 1210
  124. 1180 Print "ATOMIC PILE GOES SUPERCRITICAL "; N$; "!!! HEADQUARTERS"
  125. 1190 Print "WILL WARN ALL SUBS TO STAY AWAY FROM RADIOACTIVE AREA!!!"
  126. 1200 GoTo 6180
  127. 1210 X = S1
  128. 1220 Y = S2
  129. 1230 Q1 = 1
  130. 1240 For X2 = 1 To Int(Int(P1 / 100 + .5) * D1 + .5)
  131.    1250 If X + X1 > 0 And X + X1 < 21 And Y + Y1 > 0 And Y + Y1 < 21 Then 1280
  132.    1260 Print "YOU CAN'T LEAVE THE AREA "; N$; "!!"
  133.    1270 GoTo 1340
  134.    1280 On A(X + X1, Y + Y1) + 1 GOTO 1290, 1330, 1630, 1390, 1440, 1470, 1490
  135.    1290 X = X + X1
  136.    1300 Y = Y + Y1
  137.    1310 P = P - 100
  138.    1320 GoTo 1520
  139.    1330 Print "YOU ALMOST RAN AGROUND "; N$; "!!"
  140.    1340 A(X, Y) = 2
  141.    1350 A(S1, S2) = 0
  142.    1360 S1 = X
  143.    1370 S2 = Y
  144.    1380 GoTo 4690
  145.    1390 If D > 50 Then 1290
  146.    1400 Print "YOU RAMMED A SHIP!!! YOU'RE BOTH SUNK!!"; N$; "!!"
  147.    1410 S = S - 1
  148.    1420 If S = 0 Then 6260
  149.    1430 GoTo 6180
  150.    1440 If D > 50 Then 1290
  151.    1450 Print "YOU RAMMED HEADQUARTERS!! YOU'RE SUNK!!"
  152.    1460 GoTo 6180
  153.    1470 Print "YOU'VE BEEN BLOWN UP BY A MINE "; N$; "!!"
  154.    1480 GoTo 6180
  155.    1490 If Rnd(1) < .21 Then 1630
  156.    1500 Print "YOU WERE EATEN BY A SEA MONSTER, "; N$; "!!"
  157.    1510 GoTo 6180
  158.    1520 Rem *** CHECK FOR NEARBY SEA MONSTERS ***
  159.    1530 For X3 = X - 2 To X + 2
  160.        1540 For Y3 = Y - 2 To Y + 2
  161.            1550 If X3 < 1 Or X3 > 20 Or Y3 < 1 Or Y3 > 20 Then 1610
  162.            1560 If A(X, Y) <> 6 Then 1610
  163.            1570 If Rnd(1) < .25 Then 1500
  164.            1580 If Q1 = 0 Then 1610
  165.            1590 Print "YOU JUST HAD A NARROW ESCAPE WITH A SEA MONSTER "; N$; "!!"
  166.            1600 Q1 = 0
  167.        1610 Next Y3
  168.    1620 Next X3
  169. 1630 Next X2
  170. 1640 Print "NAVIGATION COMPLETE. POWER LEFT="; P; "."
  171. 1650 If P > 0 Then 1340
  172. 1660 Print "ATOMIC PILE HAS GONE DEAD!!! SUB SINKS, CREW SUFFOCATES"
  173. 1670 GoTo 6180
  174. 1680 Rem *** #1: SONAR ***
  175. 1690 If D(2) >= 0 Then 1720
  176. 1700 Print "SONAR IS UNDER REPAIR "; N$; "."
  177. 1710 GoTo 880
  178. 1720 If C > 5 Then 1750
  179. 1730 Print "NOT ENOUGH CREW TO WORK SONAR "; N$; "."
  180. 1740 GoTo 880
  181. 1750 Print "OPTION #";
  182. 1760 Input O
  183. 1770 On Int(O + 1) GOTO 1790, 2010
  184. 1780 GoTo 1750
  185. 1790 Rem *** PRINT OUT MAP ***
  186. 1800 Print
  187. 1810 For X = 1 To 20
  188.    1820 For Y = 1 To 20
  189.        1830 Data "   ","***","(X)","\S/","!H!"," $ ","-#-"
  190.        1840 If A(X, Y) <> 0 Then 1880
  191.        1850 If X <> 1 And X <> 20 And Y <> 1 And Y <> 20 Then 1880
  192.        1860 Print " . ";
  193.        1870 GoTo 1950
  194.        1880 Restore 1830
  195.        1890 For X1 = 1 To A(X, Y) + 1
  196.            1900 Read A$
  197.        1910 Next X1
  198.        1920 If D < 50 And Rnd(1) < .23 And A(X, Y) <> 1 And A(A, Y) <> 2 Then 1860
  199.        1930 If Rnd(1) < .15 And A(X, Y) > 2 Then 1860
  200.        1940 Print A$;
  201.    1950 Next Y
  202.    1960 Print
  203. 1970 Next X
  204. 1980 P = P - 50
  205. 1990 If P > 0 Then 880
  206. 2000 GoTo 1660
  207. 2010 Rem *** DIRECTIONAL INFORMATION ***
  208. 2020 For I = 1 To 5
  209.    2022 B(I) = 0
  210. 2024 Next I
  211. 2030 Print "DIRECTION   # OF SHIPS    DISTANCES"
  212. 2040 Restore 6090
  213. 2050 For X = 1 To 8
  214.    2060 Read X1, Y1
  215.    2070 X3 = 0
  216.    2080 For X4 = 1 To 20
  217.        2090 If S1 + X1 * X4 < 1 Or S1 + X1 * X4 > 20 Or S2 + Y1 * X4 < 1 Or S2 + Y1 * X4 > 20 Then 2140
  218.        2100 If A(S1 + X1 * X4, S2 + Y1 * X4) <> 3 Then 2130
  219.        2110 X3 = X3 + 1
  220.        2120 B(X3) = X4
  221.    2130 Next X4
  222.    2140 If X3 = 0 Then 2200
  223.    2150 Print "   "; X, X3,
  224.    2160 For X4 = 1 To X3
  225.        2170 Print B(X4);
  226.    2180 Next X4
  227.    2190 Print
  228. 2200 Next X
  229. 2210 GoTo 1980
  230. 2220 Rem *** #2: TORPEDO CONTROL ***
  231. 2230 If D(3) >= 0 Then 2260
  232. 2240 Print "TORPEDO TUBES ARE UNDER REPAIR "; N$; "."
  233. 2250 GoTo 880
  234. 2260 If C >= 10 Then 2290
  235. 2270 Print "NOT ENOUGH CREW TO FIRE TORPEDO "; N$; "."
  236. 2280 GoTo 880
  237. 2290 If T Then 2320
  238. 2300 Print "NO TORPEDOS LEFT "; N$; "."
  239. 2310 GoTo 880
  240. 2320 If D < 2000 Then 2360
  241. 2330 If Rnd(1) > .5 Then 2360
  242. 2340 Print "PRESSURE IMPLODES UPON FIRING...YOU'RE CRUSHED!!"
  243. 2350 GoTo 6180
  244. 2360 GoSub 6080
  245. 2370 X = S1
  246. 2380 Y = S2
  247. 2390 For X2 = 1 To Int(7 + 5 * (-(D > 50)) - Rnd(1) * 4 + .5)
  248.    2400 If X + X1 > 0 And X + X1 < 21 And Y + Y1 > 0 And Y + Y1 < 21 Then 2460
  249.    2410 Print "TORPEDO OUT OF SONAR RANGE...INEFFECTUAL "; N$; "."
  250.    2420 T = T - 1
  251.    2430 P = P - 150
  252.    2440 If P > 0 Then 4690
  253.    2450 GoTo 1660
  254.    2460 On A(X + X1, Y + Y1) + 1 GOTO 2470, 2510, 2650, 2540, 2580, 2610, 2630
  255.    2470 X = X + X1
  256.    2480 Y = Y + Y1
  257.    2490 Print "..!..";
  258.    2500 GoTo 2650
  259.    2510 Print "YOU TOOK OUT SOME ISLAND "; N$; "!"
  260.    2520 A(X + X1, Y + Y1) = 0
  261.    2530 GoTo 2420
  262.    2540 Print "OUCH!!! YOU GOT ONE "; N$; "!!"
  263.    2550 S = S - 1
  264.    2560 If S <> 0 Then 2520
  265.    2570 GoTo 6260
  266.    2580 Print "YOU BLEW UP YOUR HEADQUARTERS "; N$; "!!!"
  267.    2590 S3 = 0: S4 = 0: D2 = 0
  268.    2600 GoTo 2520
  269.    2610 Print "BLAM!! SHOT WASTED ON A MINE "; N$; "!!"
  270.    2620 GoTo 2520
  271.    2630 Print "A SEA MONSTER HAD A TORPEDO FOR LUNCH "; N$; "!!"
  272.    2640 GoTo 2420
  273. 2650 Next X2
  274. 2660 Print "DUD."
  275. 2670 GoTo 2420
  276. 2680 Rem #3: POLARIS MISSILE CONTROL ***
  277. 2690 If D(4) >= 0 Then 2720
  278. 2700 Print "MISSILE SILOS ARE UNDER REPAIR "; N$; "."
  279. 2710 GoTo 880
  280. 2720 If C > 23 Then 2750
  281. 2730 Print "NOT ENOUGH CREW TO LAUNCH A MISSILE "; N$; "."
  282. 2740 GoTo 880
  283. 2750 If M <> 0 Then 2780
  284. 2760 Print "NO MISSILES LEFT "; N$; "."
  285. 2770 GoTo 880
  286. 2780 If D > 50 And D < 2000 Then 2850
  287. 2790 Print "RECOMMEND THAT YOU DO NOT FIRE AT THIS DEPTH...PROCEED";
  288. 2800 Input A$
  289. 2810 If Left$(A$, 1) = "N" Then 880
  290. 2820 If Rnd(1) < .5 Then 2850
  291. 2830 Print "MISSILE EXPLODES UPON FIRING "; N$; "!! YOU'RE DEAD!!"
  292. 2840 GoTo 6180
  293. 2850 GoSub 6080
  294. 2860 Print "FUEL (LBS.)";
  295. 2870 Input F1
  296. 2880 If F1 > 0 And F1 <= F Then 2910
  297. 2890 Print "YOU HAVE"; F; "LBS. LEFT "; N$; "."
  298. 2900 GoTo 2860
  299. 2910 F2 = Int(F1 / 75 + .5)
  300. 2920 If S1 + X1 * F2 > 0 And S1 + X1 * F2 < 21 And S2 + Y1 * F2 > 0 And S2 + Y1 * F2 < 21 Then 2980
  301. 2930 Print "MISSILE OUT OF SONAR TRACKING "; N$; ". MISSILE LOST."
  302. 2940 M = M - 1
  303. 2950 F = F - F1
  304. 2960 P = P - 300
  305. 2970 GoTo 2440
  306. 2980 D3 = 0: D4 = 0: D5 = 0: D6 = 0
  307. 2990 For X = S1 + X1 * F2 - 1 To S1 + X1 * F2 + 1
  308.    3000 For Y = S2 + Y1 * F2 - 1 To S2 + Y1 * F2 + 1
  309.        3010 If X < 1 Or X > 20 Or Y < 1 Or Y > 20 Then 3140
  310.        3020 D3 = D3 - (A(X, Y) = 3)
  311.        3030 D4 = D4 - (A(X, Y) = 6)
  312.        3040 D5 = D5 - (A(X, Y) = 5)
  313.        3050 D6 = D6 - (A(X, Y) = 1)
  314.        3060 If A(X, Y) <> 4 Then 3100
  315.        3070 Print "YOU'VE JUST DESTROYED YOUR HEADQUARTERS "; N$; "!!!"
  316.        3080 D3 = 0: S4 = 0: D2 = 0
  317.        3090 GoTo 3130
  318.        3100 If A(X, Y) <> 2 Then 3130
  319.        3110 Print "YOU'VE JUST DESTROYED YOURSELF "; N$; "!!!    DUMMY!!"
  320.        3120 GoTo 6180
  321.        3130 A(X, Y) = 0
  322.    3140 Next Y
  323. 3150 Next X
  324. 3160 If D6 = 0 Then 3180
  325. 3170 Print "YOU BLEW OUT SOME ISLAND "; N$; "."
  326. 3180 If D5 = 0 Then 3200
  327. 3190 Print "YOU DESTROYED"; D5; "MINES "; N$; "."
  328. 3200 If D4 = 0 Then 3220
  329. 3210 Print "YOU GOT"; D4; "SEA MONSTERS "; N$; "!!!   GOOD WORK!!"
  330. 3220 Print "YOU DESTROYED"; D3; "ENEMY SHIPS "; N$; "!!!"
  331. 3230 S = S - D3
  332. 3240 GoTo 2940
  333. 3250 Rem *** MANUEVERING ***
  334. 3260 If D(5) >= 0 Then 3290
  335. 3270 Print "BALLAST CONTROLS ARE BEING REPAIRED "; N$; "."
  336. 3280 GoTo 890
  337. 3290 If C > 12 Then 3320
  338. 3300 Print "THERE ARE NOT ENOUGH CREW TO WORK THE CONTROLS "; N$; "."
  339. 3310 GoTo 880
  340. 3320 Print "NEW DEPTH";
  341. 3330 Input D1
  342. 3340 If D1 >= 0 And D1 < 3000 Then 3370
  343. 3350 Print "HULL CRUSHED BY PRESSURE "; N$; "!!"
  344. 3360 GoTo 6180
  345. 3370 P = P - Int(Abs((D - D1) / 2 + .5))
  346. 3380 Print "MANUEVER COMPLETE. POWER LOSS="; Int(Abs((D - D1) / 2 + .5))
  347. 3390 D = D1
  348. 3400 GoTo 4690
  349. 3410 Rem *** #5: STATUS / DAMAGE REPORT ***
  350. 3420 If D(6) >= 0 Then 3450
  351. 3430 Print "NO REPORTS ARE ABLE TO GET THROUGH "; N$; "."
  352. 3440 GoTo 880
  353. 3450 If C > 3 Then 3480
  354. 3460 Print "NO ONE LEFT TO GIVE THE REPORT "; N$; "."
  355. 3470 GoTo 880
  356. 3480 Print "# OF ENEMY SHIPS LEFT......."; S
  357. 3490 Print "# OF POWER UNITS LEFT......."; P
  358. 3500 Print "# OF TORPEDOS LEFT.........."; T
  359. 3510 Print "# OF MISSILES LEFT.........."; M
  360. 3520 Print "# OF CREWMEN LEFT..........."; C
  361. 3530 Print "LBS. OF FUEL LEFT..........."; F
  362. 3540 Print
  363. 3550 Print "WANT A DAMAGE REPORT";
  364. 3560 Input A$
  365. 3570 If Left$(A$, 1) = "N" Then 3670
  366. 3580 Print "   ITEM            DAMAGE  (+ GOOD, 0 NEUTRAL, - BAD)"
  367. 3590 Print "   ----            ------"
  368. 3600 Data "ENGINES","SONAR","TORPEDOS","MISSILES","MANUEVERING"
  369. 3610 Data "STATUS","HEADQUARTERS","SABOTAGE","CONVERTER"
  370. 3620 Restore 3600
  371. 3630 For X = 1 To 9
  372.    3640 Read A$
  373.    3650 Print A$, D(X)
  374. 3660 Next X
  375. 3670 Print "YOU ARE AT LOCATION ("; S1; ","; S2; ")."
  376. 3680 Print
  377. 3690 GoTo 880
  378. 3700 Rem #6: HEADQUARTERS ***
  379. 3710 If D(7) >= 0 Then 3740
  380. 3720 Print "HEADQUARTERS IS DAMAGED.  UNABLE TO HELP "; N$; "."
  381. 3730 GoTo 880
  382. 3740 If D2 <> 0 Then 3770
  383. 3750 Print "HEADQUARTERS IS DESERTED "; N$; "."
  384. 3760 GoTo 880
  385. 3770 If Sqr((S1 - S3) ^ 2 + (S2 - S4) ^ 2) <= 2 And D < 51 Then 3800
  386. 3780 Print "UNABLE TO COMPLY WITH DOCKING ORDERS "; N$; "."
  387. 3790 GoTo 880
  388. 3800 Print "DIVERS FROM HEAD QUARTERS BRING OUT SUPPLYS AND MEN."
  389. 3810 P = 4000
  390. 3820 T = 8
  391. 3830 M = 2
  392. 3840 F = 1500
  393. 3850 C = 25
  394. 3860 D2 = D2 - 1
  395. 3870 GoTo 4690
  396. 3880 Rem *** #7: SABOTAGE ***
  397. 3890 If D(8) >= 0 Then 3920
  398. 3900 Print "HATCHES INACCESSIBLE "; N$; ".  NO SABOTAGES POSSIBLE."
  399. 3910 GoTo 880
  400. 3920 If C > 10 Then 3950
  401. 3930 Print "NOT ENOUGH CREW TO GO ON MISSION "; N$; "."
  402. 3940 GoTo 880
  403. 3950 D3 = 0: D4 = 0
  404. 3960 For X = S1 - 2 To S1 + 2
  405.    3970 For Y = S2 - 2 To S2 + 2
  406.        3980 If X < 1 Or X > 20 Or Y < 1 Or Y > 20 Then 4010
  407.        3990 D3 = D3 - (A(X, Y) = 3)
  408.        4000 D4 = D4 - (A(X, Y) = 6)
  409.    4010 Next Y
  410. 4020 Next X
  411. 4030 If D3 <> 0 Then 4060
  412. 4040 Print "NO SHIPS IN RANGE "; N$; "."
  413. 4050 GoTo 880
  414. 4060 Print "THERE ARE"; D3; "SHIPS IN RANGE "; N$; "."
  415. 4070 Print "HOW MANY MEN ARE GOING "; N$;
  416. 4080 Input Q1
  417. 4090 If C - Q1 >= 10 Then 4120
  418. 4100 Print "YOU MUST LEAVE AT LEAST 10 MEN ON BOARD "; N$; "."
  419. 4110 GoTo 4070
  420. 4120 D5 = Int(D3 / Q1 + .5)
  421. 4130 D6 = 0
  422. 4140 For X = S1 - 2 To S1 + 2
  423.    4150 For Y = S2 - 2 To S2 + 2
  424.        4160 If D3 / Q1 > 1 - Rnd(1) And Rnd(1) + D3 / Q1 < .9 Then 4220
  425.        4170 If A(X, Y) <> 3 Then 4220
  426.        4180 D6 = D6 + 1
  427.        4190 A(X, Y) = 0
  428.        4200 S = S - 1
  429.        4210 If S = 0 Then 6260
  430.    4220 Next Y
  431. 4230 Next X
  432. 4240 Print D6; "SHIPS WERE DESTROYED "; N$; "."
  433. 4250 D6 = 0: D7 = 0
  434. 4260 For X = 1 To Q1
  435.    4270 D7 = D7 - (Rnd(1) > .6)
  436. 4280 Next X
  437. 4290 For X = 1 To Q1 - D7
  438.    4300 D6 = D6 - (Rnd(1) < .15)
  439. 4310 Next X
  440. 4320 If D4 = 0 Then 4360
  441. 4330 Print "A SEA MONSTER SMELLS THE MEN ON THE WAY BACK!!!"
  442. 4340 Print D7; "MEN WERE EATEN "; N$; "!!"
  443. 4350 C = C - D7
  444. 4360 Print D6; "MEN WERE LOST THROUGH ACCIDENTS "; N$; "."
  445. 4370 C = C - D6
  446. 4380 P = P - Int(10 * Q1 + Rnd(1) * 10)
  447. 4390 GoTo 4700
  448. 4400 Rem *** #8: POWER CONVERTER ***
  449. 4410 If D(9) >= 0 Then 4440
  450. 4420 Print "POWER CONVERTER IS DAMAGED "; N$; "."
  451. 4430 GoTo 880
  452. 4440 If C > 5 Then 4470
  453. 4450 Print "NOT ENOUGH MEN TO WORK THE CONVERTER "; N$; "."
  454. 4460 GoTo 880
  455. 4470 Print "OPTION? (1=FUEL TO POWER, 2=POWER TO FUEL)";
  456. 4480 Input O
  457. 4490 On O GOTO 4520, 4590
  458. 4500 GoTo 4470
  459. 4510 Rem *** FUEL TO POWER CONVERSION ***
  460. 4520 Print "FUEL AVAILABLE="; F; ". CONVERT";
  461. 4530 Input C1
  462. 4540 If C1 > F Or C1 < 0 Then 4520
  463. 4550 F = F - C1
  464. 4560 P = P + Int(C1 / 3)
  465. 4570 GoTo 4640
  466. 4590 Print "POWER AVAILABLE="; P - 1; ". CONVERT";
  467. 4600 Input C1
  468. 4610 If C1 > P - 1 Or C1 < 0 Then 4590
  469. 4620 P = P - C1
  470. 4630 F = F + Int(C1 * 3)
  471. 4640 Print "CONVERSION COMPLETE. POWER="; P; ". FUEL="; F; "."
  472. 4650 GoTo 4690
  473. 4660 Rem *** #9: SURRENDER ***
  474. 4670 Print "COWARD!! YOU'RE NOT VERY PATRIOTIC "; N$; "!!!"
  475. 4680 GoTo 6180
  476. 4690 Rem *** RETALIATION SECTION ***
  477. 4700 Q = 0
  478. 4710 For X = S1 - 4 To S1 + 4
  479.    4720 For Y = S2 - 4 To S2 + 4
  480.        4730 If X < 1 Or X > 20 Or Y < 1 Or Y > 20 Then 4760
  481.        4740 If A(X, Y) <> 3 Then 4760
  482.        4750 Q = Q + (Rnd(1) / Sqr((S1 - X) ^ 2 + (S2 - Y) ^ 2))
  483.    4760 Next Y
  484. 4770 Next X
  485. 4780 If Q Then 4810
  486. 4790 Print "NO SHIPS IN RANGE TO DEPTH CHARGE YOU "; N$; "!!"
  487. 4800 GoTo 5210
  488. 4810 Print "DEPTH CHARGES OFF ";
  489. 4820 If Rnd(1) > .5 Then 4850
  490. 4830 Print "PORT SIDE "; N$; "!!!"
  491. 4840 GoTo 4860
  492. 4850 Print "STARBOARD SIDE "; N$; "!!!"
  493. 4860 If Q3 > .13 Or Rnd(1) > .92 Then 4890
  494. 4870 Print "NO REAL DAMAGE SUSTAINED "; N$; "."
  495. 4880 GoTo 5220
  496. 4890 If Q > .36 Or Rnd(1) > .96 Then 4940
  497. 4900 Print "LIGHT, SUPERFICAL DAMAGE "; N$; "."
  498. 4910 P = P - 50
  499. 4920 D(Int(Rnd(1) * 9) + 1) = -Rnd(1) * 2
  500. 4930 GoTo 5210
  501. 4940 If Q > .6 Or Rnd(1) > .975 Then 5020
  502. 4950 Print "MODERATE DAMAGE. REPAIRS NEEDED."
  503. 4960 P = P - 75 + Int(Rnd(1) * 30)
  504. 4970 For Y = 1 To 2
  505.    4980 X = Int(Rnd(1) * 9) + 1
  506.    4990 D(X) = D(X) - Rnd(1) * 8
  507. 5000 Next Y
  508. 5010 GoTo 5210
  509. 5020 If Q > .9 Or Rnd(1) > .983 Then 5100
  510. 5030 Print "HEAVY DAMAGE!! REPAIRS IMMEDIATE "; N$; "!!!"
  511. 5040 P = P - (200 + Int(Rnd(1) * 76))
  512. 5050 For X = 1 To 4 + Int(Rnd(1) * 2)
  513.    5060 Y = Int(Rnd(1) * 9) + 1
  514.    5070 D(Y) = D(Y) - Rnd(1) * 11
  515. 5080 Next X
  516. 5090 GoTo 5210
  517. 5100 Print "DAMAGE CRITICAL!!!!   WE NEED HELP!!!"
  518. 5110 A$ = "VRAVUKXCNVPCRHFDRSAXQURLQTRHXYACVFZYITLCBSSYYKDQIPCAEGQGPCNOTSIO"
  519. 5120 X = Int(Rnd(1) * 16) + 1
  520. 5130 Print "SEND 'HELP' IN CODE. HERE IS THE CODE:"; Mid$(A$, X, 4);
  521. 5134 For I = 1 To 500: Next I
  522. 5136 Print Chr$(13); Tab(38); "XXXX"; Chr$(13); Tab(38); "****"
  523. 5140 Input "ENTER CODE"; B$
  524. 5150 Print
  525. 5160 If B$ <> Mid$(A$, X, 4) Then 5190
  526. 5170 Print "FAST WORK "; N$; "!! HELP ARRIVES IN TIME TO SAVE YOU!!!"
  527. 5180 GoTo 5040
  528. 5190 Print "MESSAGE GARBLED "; N$; "...NO HELP ARRIVES!!!"
  529. 5200 GoTo 6180
  530. 5210 Rem *** MOVE SHIPS / SEA MONSTERS ***
  531. 5220 If D(1) >= 0 Or D(3) >= 0 Or D(4) >= 0 Or D(5) >= 0 Or D(6) >= 0 Or D(7) >= 0 Then 5260
  532. 5230 If D(8) >= 0 Or D(9) >= 0 Then 5270
  533. 5240 Print "DAMAGE TOO MUCH "; N$; "!!!   YOU'RE SUNK!!"
  534. 5250 GoTo 6180
  535. 5260 Rem *** MOVE SHIPS / SEA MONSTERS ***
  536. 5270 Print: Print: Print "---*** RESULT OF LAST ENEMY MANUEVER ***---"
  537. 5280 For X = 1 To 20
  538.    5290 For Y = 1 To 20
  539.        5300 If A(X, Y) <> 3 Then 5690
  540.        5310 Rem *** MOVE A SHIP ***
  541.        5320 W = D8
  542.        5330 V = D9
  543.        5340 If X + W > 0 And X + W < 21 And Y + V > 0 And Y + V < 21 Then 5420
  544.        5350 For X0 = 19 To 1 Step -1
  545.            5360 If A(X - W * X0, Y - V * X0) <> 0 Then 5400
  546.            5370 A(X - W * X0, Y - V * X0) = 3
  547.            5380 A(X, Y) = 0
  548.            5390 GoTo 6000
  549.        5400 Next X0
  550.        5410 Stop
  551.        5420 On A(X + W, Y + V) + 1 GOTO 5430, 5460, 5530, 5460, 5560, 5600, 5650
  552.        5430 A(X + W, Y + V) = 3
  553.        5440 A(X, Y) = 0
  554.        5450 GoTo 6000
  555.        5460 Rem *** CHANGE DIRECTION ***
  556.        5470 Restore 6090
  557.        5480 For X0 = 1 To Int(Rnd(1) * 8) + 1
  558.            5490 Read W, V
  559.        5500 Next X0
  560.        5510 If X + W < 1 Or X + W > 20 Or Y + V < 1 Or Y + V > 20 Then 5470
  561.        5520 GoTo 5420
  562.        5530 If D > 50 Then 5460
  563.        5540 Print "*** YOU'VE BEEN RAMMED BY A SHIP "; N$; "!!! ***"
  564.        5550 GoTo 6180
  565.        5560 If Rnd(1) < .15 Then 5460
  566.        5570 Print "*** YOUR HEADQUARTERS WAS RAMMED "; N$; "!!! ***"
  567.        5580 S3 = 0: S4 = 0: D2 = 0: A(X + W, Y + V) = 0
  568.        5590 GoTo 5620
  569.        5600 If Rnd(1) < .7 Then 5460
  570.        5610 Print "*** SHIP DESTROYED BY A MINE "; N$; "!!! ***"
  571.        5620 S = S - 1
  572.        5630 If S <> 0 Then 5440
  573.        5640 GoTo 6260
  574.        5650 If Rnd(1) < .8 Then 5460
  575.        5660 Print "*** SHIP EATEN BY A SEA MONSTER "; N$; "!! ***"
  576.        5670 S = S - 1
  577.        5680 GoTo 5630
  578.        5690 Rem *** MOVE A SEA MONSTER ***
  579.        5700 If A(X, Y) <> 6 Then 6000
  580.        5710 If X + M1 < 1 Or X + M1 > 20 Or Y + M2 < 1 Or Y + M2 > 20 Then 5760
  581.        5720 On A(X + M1, Y + M2) + 1 GOTO 5730, 5760, 5830, 5850, 5900, 5730, 5930
  582.        5730 A(X + M1, Y + M2) = 6
  583.        5740 A(X, Y) = 0
  584.        5750 GoTo 6000
  585.        5760 Rem *** CHANGE DIRECTION ***
  586.        5770 Restore 6090
  587.        5780 For X0 = 1 To Int(Rnd(1) * 8) + 1
  588.            5790 Read M1, M2
  589.        5800 Next X0
  590.        5810 If X + M1 < 1 Or X + M1 > 20 Or Y + M2 < 1 Or Y + M2 > 20 Then 5760
  591.        5820 GoTo 5720
  592.        5830 Print "*** YOU'VE BEEN EATEN BY A SEA MONSTER "; N$; "!! ***"
  593.        5840 GoTo 6180
  594.        5850 If Rnd(1) > .2 Then 5760
  595.        5860 Print "*** SHIP EATEN BY A SEA MONSTER "; N$; "!! ***"
  596.        5870 S = S - 1
  597.        5880 If S <> 0 Then 5730
  598.        5890 GoTo 6260
  599.        5900 Print "*** A SEA MONSTER ATE YOU HEADQUARTERS "; N$; "!! ***"
  600.        5910 S3 = 0: S4 = 0: D2 = 0
  601.        5920 GoTo 5730
  602.        5930 If Rnd(1) < .75 Then 5760
  603.        5940 Print "*** A SEA MONSTER FIGHT "; N$; "!!! ";
  604.        5950 If Rnd(1) < .8 Then 5980
  605.        5960 Print "AND ONE DIES!! ***"
  606.        5970 GoTo 5730
  607.        5980 Print "IT'S A TIE!! ***"
  608.        5990 GoTo 5760
  609.    6000 Next Y
  610. 6010 Next X
  611. 6020 Rem *** MAKE REPAIRS ***
  612. 6030 For Y = 1 To 9
  613.    6040 X = Int(Rnd(1) * 9) + 1
  614.    6050 D(X) = D(X) + (Rnd(1) * (2 + Rnd(1) * 2)) * (1 + (-(D < 51) Or -(D > 2000))) * (-(D(X) < 3))
  615. 6060 Next Y
  616. 6070 GoTo 880
  617. 6080 Rem *** GOSUB FOR COURSE / DIRECTION ***
  618. 6090 Data -1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1
  619. 6100 Print "COURSE (1-8)";
  620. 6110 Input C1
  621. 6120 If C1 < 1 Or C1 > 8 Then 6100
  622. 6130 Restore 6090
  623. 6140 For X9 = 1 To Int(C1 + .5)
  624.    6150 Read X1, Y1
  625. 6160 Next X9
  626. 6170 Return
  627. 6180 Rem *** DESTROYED ? ***
  628. 6190 Print "THERE ARE STILL"; S; "ENEMY SHIPS LEFT "; N$; "."
  629. 6200 Print "YOU WILL BE DEMOTED TO THE RANK OF DECK SCRUBBER!!!"
  630. 6210 Print "WANT ANOTHER GAME";
  631. 6220 Input A$
  632. 6230 If Left$(A$, 1) <> "Y" Then 6250
  633. 6240 GoTo 310
  634. 6250 Stop
  635. 6260 Print "GOOD WORK "; N$; "!!!  YOU GOT THEM ALL!!!"
  636. 6270 Print "PROMOTION AND COMMENDATIONS WILL BE GIVEN IMMEDIATELY!!!"
  637. 6280 GoTo 6210
  638. 6300 Data 0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,1
  639. 6310 Data 1,1,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0
  640. 6320 End
  641.  
  642.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Multiple Panels
« Reply #10 on: January 19, 2022, 12:26:46 am »
That's the one!  I plan to use three panels, instead of having the text scroll off the screen... Top left will be the main ocean map. Top right will show ammunition and other submarine stats. The third panel (letter box style) will sit beneath the top two panels and will use the full width of the screen. I may go with Screen 12.

The Star Trek game (based on the same book) will use 5 panels... I hope...
Logic is the beginning of wisdom.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Multiple Panels
« Reply #11 on: January 19, 2022, 11:06:46 am »
Perhaps find an old game called EGA TREK for inspiration on the "panel" layout.
Granted after becoming radioactive I only have a half-life!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Multiple Panels
« Reply #12 on: January 19, 2022, 01:14:39 pm »
If you need a little more power than just printing to a panel area, you might want to try out my Frame Library.  https://qb64forum.alephc.xyz/index.php?topic=718.0

The idea behind it is rather simple:

First, define a frame area with:

LeftFrame = NewTextArea(0, 0, 400, _Height - 1, False)
RightFrame = NewTextArea(401, 0, _Width - 1, _Height - 1, False)

Based off the FUNCTION NewTextArea% (tx1 AS INTEGER, ty1 AS INTEGER, tx2 AS INTEGER, ty2 AS INTEGER, SaveBackground AS INTEGER)

So, in the two above examples, LeftFrame goes from (0,0)-(400, _height-1) and we don't save the background.  RightFrame goes from (400,0)-(_width-1, _height-1) and doesn't save the background.


After that, we PrintOut to the frames, with a simple little call to:

SUB PrintOut (WhichHandle AS INTEGER, What AS STRING) 

Which we use as simple as:

PrintOut LeftFrame, "Whatever I want to print to the left side."
PrintOut RightFrame, "Whatever I want to print to the right side."

And the library has a lot more functions included with it so you can justify your printing inside a frame (left, right, center), change colors, hide backgrounds, use the frame as a pop-up and then close it and restore your screen when finished, ect, ect...


It's a little bit more complicated than the simple method I showed you above, but it's a whole lot more powerful as well, with a lot of nice features built in which might reduce your development time considerably.  (Especially if you want to justify words or implement word wrap into your text adventure, as it can do those things for you automatically.)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline OldMoses

  • Seasoned Forum Regular
  • Posts: 469
    • View Profile
Re: Multiple Panels
« Reply #13 on: January 19, 2022, 02:25:08 pm »
I did one a while back for taking a picture and superimposing a square or hex grid over a loaded picture. It then saves the resulting image with Steve's SaveImage utility. It displays a smaller navigation image on the left side.

The heart of that aspect of the program is SUB Image_Resize, which will put any size image in any other size area of another image or screen. It will justify up/down/left/right/center within the defined space and maintain the original images aspect ratio.

Maybe you can find it of some utility in slapping up image panels on a screen, the images should be of similar aspect ratio to the space if there are not to be some rather large waste areas.

Code: QB64: [Select]
  1. '$INCLUDE:'SaveImage.BI'
  2. 'Grid-a-Pic version 0.2
  3. 'Thanks go to:  Steve McNeill for SaveImage
  4. '               Galleon/Bplus for Rotozoom3
  5.  
  6. TYPE object
  7.     x AS INTEGER
  8.     y AS INTEGER
  9.  
  10. 'GLOBAL VARIABLES
  11. DIM SHARED camera AS object
  12. DIM dWidth AS INTEGER
  13. DIM dHeight AS INTEGER
  14. DIM mWidth AS INTEGER
  15. DIM mHeight AS INTEGER
  16. DIM SHARED navrat AS SINGLE '                                   nav map reduction ratio
  17. DIM SHARED gtog AS _BYTE '                                      Grid state toggle
  18. '                                                               bit 0 = Hex(1) Box(0)
  19. '                                                               bit 1 = 1 on 0 off
  20.  
  21. DIM SHARED mp AS LONG '                                         working image handle
  22. DIM SHARED mpt& '                                               temp working image
  23. DIM SHARED main& '                                              main display handle
  24. DIM SHARED grid& '                                              grid image handle
  25. DIM SHARED arw& '                                               offset arrow handle
  26. DIM SHARED abyt AS _UNSIGNED _BYTE '                            Alpha
  27. DIM SHARED rbyt AS _UNSIGNED _BYTE '                            Red
  28. DIM SHARED gbyt AS _UNSIGNED _BYTE '                            Green
  29. DIM SHARED bbyt AS _UNSIGNED _BYTE '                            Blue
  30.  
  31. 'INITIAL PARAMETERS
  32. dWidth = _DESKTOPWIDTH '                                        Desktop size
  33. dHeight = _DESKTOPHEIGHT - 80 '                                 leave room for task bar
  34. wWidth = dWidth - 401 '                                         Window size
  35. wHeight = dHeight
  36. mp = _NEWIMAGE(wWidth, wHeight, 32)
  37. mWidth = _WIDTH(mp) '                                           Map/pic size
  38. mHeight = _HEIGHT(mp)
  39. gsiz = 35: hOff = 0: vOff = 0 '                                 grid size 35 pixels, no offsets
  40. abyt = 127: rbyt = 127: gbyt = 127: bbyt = 127
  41. main& = _NEWIMAGE(dWidth, dHeight, 32) '                        Complete display screen
  42. grid& = _NEWIMAGE(mWidth, mHeight, 32) '                        grid handle
  43. arw& = _NEWIMAGE(30, 30, 32) '                                  grid positioning arrow
  44. Make_Arrow
  45. SCREEN main&
  46. _TITLE "GridPic (esc to quit, arrows to pan, +/- to resize grid, 'h' for hex grid, 'b' for box grid)"
  47.  
  48. 'Main program loop
  49. in = -1 '                                                       short around the input loop on startup
  50.     DO 'begin input loop
  51.         IF _KEYDOWN(98) THEN '                                  Box grid has been toggled "b"
  52.             IF _READBIT(gtog, 1) THEN '                         If grid is on
  53.                 IF _READBIT(gtog, 0) THEN '                     and it is a hex
  54.                     gtog = _RESETBIT(gtog, 0) '                 then make it a box
  55.                 ELSE '                                          if it's already a box
  56.                     gtog = _TOGGLEBIT(gtog, 1) '                then turn it off
  57.                 END IF
  58.             ELSE '                                              if grid is off
  59.                 gtog = _RESETBIT(gtog, 0) '                     set for box and,
  60.                 gtog = _TOGGLEBIT(gtog, 1) '                    turn the grid on
  61.             END IF
  62.             _DELAY .2
  63.             : in = -1
  64.         END IF
  65.         IF _KEYDOWN(104) THEN '                                 Hex grid has been toggled "h"
  66.             IF _READBIT(gtog, 1) THEN '                         If the grid is on
  67.                 IF NOT _READBIT(gtog, 0) THEN '                 and it is a box
  68.                     gtog = _SETBIT(gtog, 0) '                   then make it a hex
  69.                 ELSE '                                          if it's already a hex
  70.                     gtog = _TOGGLEBIT(gtog, 1) '                then turn it off
  71.                 END IF
  72.             ELSE '                                              if the grid is off
  73.                 gtog = _SETBIT(gtog, 0) '                       set for hex and,
  74.                 gtog = _TOGGLEBIT(gtog, 1) '                    turn the grid on
  75.             END IF
  76.             _DELAY .2
  77.             : in = -1
  78.         END IF
  79.         IF _KEYDOWN(115) THEN Save_Gridpic: in = -1
  80.         IF _KEYDOWN(111) THEN Load_Image: in = -1
  81.         IF _KEYDOWN(43) THEN gsiz = gsiz + 1: in = -1 '         increase grid size
  82.         IF _KEYDOWN(45) THEN gsiz = gsiz - 1 - (gsiz = 6): in = -1 'decrease grid size, limit to 6 or more
  83.         IF _KEYDOWN(18432) THEN camera.y = camera.y - 10 - ((camera.y = 0) * 10): in = -1
  84.         IF _KEYDOWN(20480) THEN camera.y = camera.y + 10 + ((camera.y > (_HEIGHT(mp) - wHeight)) * 10): in = -1
  85.         IF _KEYDOWN(19200) THEN camera.x = camera.x - 10 - ((camera.x = 0) * 10): in = -1
  86.         IF _KEYDOWN(19712) THEN camera.x = camera.x + 10 + ((camera.x > (_WIDTH(mp) - wWidth)) * 10): in = -1
  87.         IF _KEYDOWN(27) THEN SYSTEM
  88.         IF _KEYDOWN(113) THEN SYSTEM
  89.         IF _KEYDOWN(97) AND hOff > -gsiz / 2 THEN hOff = hOff - 1: in = -1
  90.         IF _KEYDOWN(100) AND hOff < gsiz / 2 THEN hOff = hOff + 1: in = -1
  91.         IF _KEYDOWN(119) AND vOff > -gsiz / 2 THEN vOff = vOff - 1: in = -1
  92.         IF _KEYDOWN(122) AND vOff < gsiz / 2 THEN vOff = vOff + 1: in = -1
  93.  
  94.         WHILE _MOUSEINPUT
  95.         WEND
  96.         IF _MOUSEBUTTON(1) THEN
  97.             Mouse_Ops _MOUSEX, _MOUSEY
  98.             in = -1
  99.         END IF
  100.         _LIMIT 30
  101.     LOOP UNTIL in 'end of input loop
  102.     in = 0
  103.  
  104.     'Create grid overlay
  105.     _DEST grid&
  106.     CLS
  107.     IF _READBIT(gtog, 1) THEN '                                 if grid is enabled
  108.         IF _READBIT(gtog, 0) THEN '                             if hex enabled
  109.             Hex_Grid gsiz, hOff, vOff
  110.         ELSE '                                                  if box enabled
  111.             Box_Grid gsiz, hOff, vOff
  112.         END IF
  113.     END IF
  114.     _CLEARCOLOR _RGB32(0, 0, 0)
  115.     _DEST main&
  116.  
  117.     'place finished images in screen window
  118.     CLS
  119.     IF _WIDTH(mp) < wWidth THEN b = wWidth / _WIDTH(mp) ELSE b = 1
  120.     _PUTIMAGE , mp, mpt& '                                      put map onto temp map
  121.     _PUTIMAGE , grid&, mpt& '                                   overlay grid onto temp map
  122.     _PUTIMAGE (400, 0), mpt&, main&, (camera.x, camera.y)-(camera.x + wWidth, camera.y + wHeight) 'temp map to main display
  123.     LINE (0, 200)-(399, _HEIGHT(main&) - 1), &HFF0000FF, B
  124.     Image_Resize 0, 200, 399, _HEIGHT(main&) - 1, mp, main&, "l", "u" 'Place nav map in navmap window
  125.     navrat = navrat / b
  126.     LINE (camera.x * navrat, 200 + camera.y * navrat)-((camera.x + wWidth) * navrat, 200 + (camera.y + wHeight) * navrat), &HFFFF0000, B
  127.     LINE (camera.x * navrat + 1, 201 + camera.y * navrat)-((camera.x + wWidth) * navrat - 1, 199 + (camera.y + wHeight) * navrat), &HFFFF0000, B
  128.  
  129.     Para_Disp
  130.  
  131.     _LIMIT 30
  132.     _DISPLAY
  133. 'End main program loop
  134.  
  135. '                                                               END: MAIN MODULE / BEGIN SUBROUTINES
  136.  
  137.  
  138. SUB Box_Grid (siz AS INTEGER, h AS INTEGER, v AS INTEGER)
  139.  
  140.     DIM s, ho, vo
  141.     COLOR _RGBA32(rbyt, gbyt, bbyt, abyt)
  142.     s = siz
  143.     ho = 0
  144.     DO 'vertical lines
  145.         LINE (ho * s + h, 0)-(ho * s + h, _HEIGHT(grid&) - 1)
  146.         ho = ho + 1
  147.     LOOP UNTIL ho * s > _WIDTH(grid&)
  148.     vo = 0
  149.     DO 'horizontal lines
  150.         LINE (0, vo * s + v)-(_WIDTH(grid&) - 1, vo * s + v)
  151.         vo = vo + 1
  152.     LOOP UNTIL vo * s + v > _HEIGHT(grid&)
  153.  
  154. END SUB 'Box_Grid
  155.  
  156.  
  157. SUB Con_Blok (xpos AS INTEGER, ypos AS INTEGER, xsiz AS INTEGER, ysiz AS INTEGER, label AS STRING, high AS INTEGER, col AS _UNSIGNED LONG)
  158.  
  159.     'Create control block
  160.     DIM CN&, x, p, sx, sy
  161.     CN& = _NEWIMAGE(xsiz, ysiz, 32)
  162.     _DEST CN&
  163.     COLOR , col
  164.     CLS
  165.     x = LEN(label)
  166.     sx = xsiz / 2 - x * 4: sy = ysiz / 2 - 8
  167.     FOR p = 1 TO x '                                            iterate through label characters
  168.         IF p = high THEN '                                      print hotkey highlight color (red) else (black)
  169.             IF col = &HFFFF0000 THEN
  170.                 COLOR &HFFFFFFFF
  171.             ELSE
  172.                 COLOR &HFFFF0000
  173.             END IF
  174.         ELSE
  175.             COLOR &HFF000000
  176.         END IF
  177.         _PRINTSTRING (sx + (p - 1) * 8, sy), MID$(label, p, 1)
  178.     NEXT p
  179.     _PUTIMAGE (xpos, ypos), CN&, main&
  180.     _FREEIMAGE CN&
  181.  
  182. END SUB 'Con_Blok
  183.  
  184.  
  185. SUB DialogBox (heading AS STRING, xsiz AS INTEGER, ysiz AS INTEGER, ypos AS INTEGER, bcol AS _UNSIGNED LONG, tcol AS _UNSIGNED LONG)
  186.  
  187.     'superimpose a screen centered input box for various input routines
  188.     cr& = _DEST '                                               save calling destination
  189.     dbox& = _NEWIMAGE(xsiz, ysiz, 32) '                         define box
  190.     _DEST dbox&
  191.     COLOR tcol, &HFF000000 '                                    set text color with black background
  192.     CLS
  193.     FOR x% = 0 TO 5 '                                           draw bounding box 6 pixels thick
  194.         b~& = -Black * (x% < 2) - bcol * (x% >= 2) '             color=outer two black, balance bcol
  195.         LINE (0 + x%, 0 + x%)-(xsiz - 1 - x%, ysiz - 1 - x%), b~&, B 'draw color border
  196.     NEXT x%
  197.     _PRINTSTRING (_SHR(xsiz, 1) - _SHL(LEN(heading), 2), 31), heading 'print heading two rows below top
  198.     _DEST cr& '                                                 reset to calling destination
  199.     _PUTIMAGE (_SHR(_WIDTH, 1) - _SHR(xsiz, 1), ypos), dbox& '  display box centered over calling destination image
  200.     _FREEIMAGE dbox& '                                          clean up
  201.  
  202. END SUB 'DialogBox
  203.  
  204.  
  205. SUB Hex_Grid (siz AS INTEGER, h AS INTEGER, v AS INTEGER)
  206.  
  207.     'siz= size in pixels across hex flats
  208.     'h= horizontal bias
  209.     'v= vertical bias
  210.     DIM s, sb, ho, vo, vo2, ro, col, of, roho, colvo
  211.     CLS
  212.     s = siz / (2 * SIN(_PI / 3)) '                              side length
  213.     sb = s / 2 '                                                slope apex horzontal distance
  214.     ho = s + sb '                                               horizontal offset
  215.     vo = siz '                                                  vertical offset
  216.     vo2 = vo / 2 '                                              1/2 vertical offset
  217.     COLOR _RGBA32(rbyt, gbyt, bbyt, abyt)
  218.     ro = -1 '                                                   starting row position
  219.     DO '                                                        x row loop
  220.         col = -1 '                                              starting column position
  221.         roho = ro * ho + h '                                    row position x horizontal offset + horizontal bias
  222.         of = -(vo2) * (ro MOD 2 = 0) '                          even/odd bias, branchless for: IF ro MOD 2 = 0 THEN of = vo2 ELSE of = 0
  223.         DO '                                                    y column loop
  224.             colvo = col * vo + v + of '                         column position x vertical offset + vertical bias + even/odd row bias
  225.             LINE (roho - sb, colvo)-(roho + sb, colvo) '        hex horizontal
  226.             LINE (roho + sb, colvo)-(roho + s, colvo - vo2) '   hex up leg
  227.             LINE (roho + sb, colvo)-(roho + s, colvo + vo2) '   hex down leg
  228.             col = col + 1 '                                     advance column
  229.         LOOP UNTIL (col - 1) * vo > _HEIGHT(grid&)
  230.         ro = ro + 1 '                                           advance row
  231.     LOOP UNTIL (ro - 1) * ho > _WIDTH(grid&)
  232.  
  233. END SUB 'Hex_Grid
  234.  
  235.  
  236. '²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²²
  237. SUB Image_Resize (xpos AS INTEGER, ypos AS INTEGER, xlim AS INTEGER, ylim AS INTEGER, i AS LONG, d AS LONG, xj AS STRING, yj AS STRING)
  238.  
  239.     DIM AS INTEGER xs, ys, xp, yp, xl, yl
  240.     DIM AS SINGLE rt, xrt, yrt
  241.     xrt = (xlim - xpos) / _WIDTH(i) '                           width of area divided by width of image
  242.     yrt = (ylim - ypos) / _HEIGHT(i) '                          height of area divided by height of image
  243.     rt = -xrt * (xrt < yrt) - yrt * (yrt <= xrt) '             pick the smaller of the two ratios to fit area
  244.     navrat = rt '                                               for global use-can be removed in other programs that don't need it
  245.     xs = _WIDTH(i) * rt '                                       final image size ratio in x
  246.     ys = _HEIGHT(i) * rt '                                      final image size ratio in y
  247.  
  248.     xp = -xpos * (xj = "l") - (_SHR(xlim - xpos, 1) + xpos - _SHR(xs, 1)) * (xj = "c") - (xlim - xs) * (xj = "r")
  249.     xl = xp + xs
  250.     yp = -ypos * (yj = "u") - (_SHR(ylim - ypos, 1) + ypos - _SHR(ys, 1)) * (yj = "c") - (ylim - ys) * (yj = "d")
  251.     yl = yp + ys
  252.     _PUTIMAGE (xp, yp)-(xl, yl), i, d
  253.  
  254. END SUB 'Image_Resize
  255.  
  256.  
  257. SUB Load_Image
  258.  
  259.     DialogBox "Load Image", 600, 400, 50, &HFF00FF00, &HFFFFFFFF
  260.     _PRINTSTRING (_WIDTH(main&) / 2 - 140, 116), "Input path \ filename and extension", 0
  261.     _DISPLAY
  262.     _KEYCLEAR
  263.     LOCATE 148 \ 16, (_WIDTH(main&) / 2 - 120) \ 8
  264.     INPUT ": ", fn$: fn$ = _TRIM$(fn$)
  265.         _FREEIMAGE (mp)
  266.         IF mpt& < -1 THEN _FREEIMAGE (mpt&)
  267.         _FREEIMAGE (grid&)
  268.         mp = _LOADIMAGE(fn$, 32)
  269.         IF mp = -1 THEN mp = _LOADIMAGE(fn$)
  270.         mwidth = _WIDTH(mp)
  271.         mheight = _HEIGHT(mp)
  272.         grid& = _NEWIMAGE(mwidth, mheight, 32)
  273.         IF _WIDTH(mp) < wWidth THEN b = wWidth / _WIDTH(mp) ELSE b = 1
  274.         mpt& = _NEWIMAGE(_WIDTH(mp) * b, _HEIGHT(mp) * b, 32)
  275.         camera.x = 0: camera.y = 0
  276.     ELSE
  277.     END IF
  278.  
  279. END SUB 'Load_Image
  280.  
  281.  
  282. SUB Make_Arrow
  283.  
  284.     _DEST arw&
  285.     CLS
  286.     _CLEARCOLOR &HF000000
  287.     COLOR &HFF00FF00
  288.     LINE (15, 5)-(25, 25)
  289.     LINE (25, 25)-(15, 16)
  290.     LINE (15, 16)-(5, 25)
  291.     LINE (5, 25)-(15, 5)
  292.     _DEST 0
  293.  
  294. END SUB 'Make_Arrow
  295.  
  296.  
  297. FUNCTION map! (value!, minRange!, maxRange!, newMinRange!, newMaxRange!)
  298.  
  299.     map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
  300.  
  301.  
  302.  
  303. SUB Mouse_Ops (xpos AS INTEGER, ypos AS INTEGER)
  304.  
  305.     SELECT CASE xpos
  306.         CASE IS < 400 '                                         left screen cases
  307.             SELECT CASE ypos
  308.                 CASE IS < 25
  309.                     SELECT CASE xpos
  310.                         CASE 0 TO 39 '                          open
  311.                             Load_Image
  312.                         CASE 50 TO 89 '                         save
  313.                             Save_Gridpic
  314.                         CASE 100 TO 139: SYSTEM
  315.                         CASE 200 TO 239 '                       hex button click
  316.                             IF _READBIT(gtog, 1) THEN '         if grid active
  317.                                 IF NOT _READBIT(gtog, 0) THEN ' and box
  318.                                     gtog = _SETBIT(gtog, 0) '   change to hex
  319.                                 ELSE '                          otherwise
  320.                                     gtog = _RESETBIT(gtog, 1) ' make grid inactive
  321.                                 END IF
  322.                             ELSE '                              otherwise if grid inactive
  323.                                 gtog = _SETBIT(gtog, 1) '       activate it
  324.                                 gtog = _SETBIT(gtog, 0) '       as a hex
  325.                             END IF
  326.                             _DELAY .2
  327.                         CASE 250 TO 289 '                       box button click
  328.                             IF _READBIT(gtog, 1) THEN '         if grid active
  329.                                 IF _READBIT(gtog, 0) THEN '     and hex
  330.                                     gtog = _RESETBIT(gtog, 0) ' change to box
  331.                                 ELSE
  332.                                     gtog = _RESETBIT(gtog, 1) ' make grid inactive
  333.                                 END IF
  334.                             ELSE '                              otherwise
  335.                                 gtog = _SETBIT(gtog, 1) '       activate it
  336.                                 gtog = _RESETBIT(gtog, 0) '     as a box
  337.                             END IF
  338.                             _DELAY .2
  339.                     END SELECT
  340.                 CASE 24 TO 199 '                                color, size & offset
  341.                     SELECT CASE xpos
  342.                         CASE 5 TO 200 '                         color block
  343.                             SELECT CASE ypos
  344.                                 CASE 50 TO 60 '                 alpha
  345.                                     abyt = map!(xpos, 5, 200, 1, 255)
  346.                                 CASE 90 TO 100 '                red
  347.                                     rbyt = map!(xpos, 5, 200, 1, 255)
  348.                                 CASE 130 TO 140 '               green
  349.                                     gbyt = map!(xpos, 5, 200, 1, 255)
  350.                                 CASE 170 TO 180 '               blue
  351.                                     bbyt = map!(xpos, 5, 200, 1, 255)
  352.                             END SELECT
  353.                         CASE IS > 200 '                         size & offset cross
  354.                             SELECT CASE ypos
  355.                                 CASE 46 TO 70
  356.                                     SELECT CASE xpos
  357.                                         CASE 225 TO 257
  358.                                             gsiz = gsiz - 1
  359.                                         CASE 343 TO 375
  360.                                             gsiz = gsiz + 1
  361.                                     END SELECT
  362.                                 CASE 90 TO 120
  363.                                     SELECT CASE xpos
  364.                                         CASE 286 TO 314 '       offset up
  365.                                             IF vOff > -gsiz / 2 THEN vOff = vOff - 1
  366.                                     END SELECT
  367.                                 CASE 121 TO 149
  368.                                     SELECT CASE xpos
  369.                                         CASE 255 TO 285 '       offset left
  370.                                             IF hOff > -gsiz / 2 THEN hOff = hOff - 1
  371.                                         CASE 286 TO 314 '       offset to (0, 0)
  372.                                             hOff = 0: vOff = 0
  373.                                         CASE 315 TO 345 '       offset right
  374.                                             IF hOff < gsiz / 2 THEN hOff = hOff + 1
  375.                                     END SELECT
  376.                                 CASE 150 TO 180
  377.                                     SELECT CASE xpos
  378.                                         CASE 286 TO 314 '       offset down
  379.                                             IF vOff < gsiz / 2 THEN vOff = vOff + 1
  380.                                     END SELECT
  381.                             END SELECT
  382.  
  383.                     END SELECT
  384.                 CASE IS > 199
  385.                     'move the camera box in the navmap
  386.                     'LINE (camera.x * navrat, 200 + camera.y * navrat)-((camera.x + wWidth) * navrat, 200 + (camera.y + wHeight) * navrat), &HFFFF0000, B
  387.                     'LINE (camera.x * navrat + 1, 201 + camera.y * navrat)-((camera.x + wWidth) * navrat - 1, 199 + (camera.y + wHeight) * navrat), &HFFFF0000, B
  388.  
  389.                     ''This works at the upper left corner
  390.                     camera.x = xpos / navrat
  391.                     camera.y = (ypos - 200) / navrat
  392.  
  393.                     ''Trying to get it centered
  394.                     'camera.x = (xpos - ((wWidth / 2) / navrat)) / navrat ' - wWidth * navrat
  395.                     'camera.y = (ypos - 200) / navrat
  396.                     'camera.x = map!(xpos, 0, 400, 0, _WIDTH(mp) - 1)
  397.                     'camera.y = map!(ypos,200,_height(main&)-1,0, )
  398.             END SELECT '                                        end: left screen ypos cases
  399.         CASE ELSE
  400.             _MOUSEMOVE 400 + wWidth / 2, wHeight / 2
  401.             camera.x = camera.x - (xpos - 400 - wWidth / 2)
  402.             camera.y = camera.y - (ypos - wHeight / 2)
  403.     END SELECT
  404.  
  405. END SUB 'Mouse_Ops
  406.  
  407.  
  408. SUB Panel_Blank (xpos AS INTEGER, ypos AS INTEGER, xsiz AS INTEGER, ysiz AS INTEGER, col AS LONG)
  409.  
  410.     'Background blank to mark and mask button use and/or changes
  411.     DIM CN&
  412.     CN& = _NEWIMAGE(xsiz, ysiz, 32) '                           active button overlay
  413.     _DEST CN&
  414.     COLOR , col '                                               set overlay background color
  415.     CLS
  416.     _PUTIMAGE (xpos, ypos), CN&, main& '                        cover button
  417.     _FREEIMAGE CN&
  418.  
  419. END SUB 'Panel_Blank
  420.  
  421.  
  422. SUB Para_Disp
  423.  
  424.     'Display available parameters and controls
  425.     Con_Blok 0, 0, 40, 24, "Open", 1, &HFF00FF00
  426.     Con_Blok 50, 0, 40, 24, "Save", 1, &HFF0000FF
  427.     Con_Blok 100, 0, 40, 24, "Quit", 1, &HFFFF0000
  428.     Con_Blok 200, 0, 40, 24, "Hex", 1, &HFFF0F0F0
  429.     Con_Blok 250, 0, 40, 24, "Box", 1, &HFFF0F0F0
  430.     IF _READBIT(gtog, 1) THEN
  431.         IF _READBIT(gtog, 0) THEN
  432.             Panel_Blank 250, 0, 40, 24, &H9F000000
  433.         ELSE
  434.             Panel_Blank 200, 0, 40, 24, &H9F000000
  435.         END IF
  436.     ELSE
  437.         Panel_Blank 200, 0, 40, 24, &H9F000000
  438.         Panel_Blank 250, 0, 40, 24, &H9F000000
  439.     END IF
  440.  
  441.     _PRINTSTRING (5, 30), "Alpha " + STR$(abyt) '               color bars
  442.     LINE (5, 50)-(200, 60), &HFF7F7F7F, B
  443.     LINE (5, 50)-(map!(abyt, 1, 255, 5, 200), 60), &HFF7F7F7F, BF
  444.     _PRINTSTRING (5, 70), "Red " + STR$(rbyt)
  445.     LINE (5, 90)-(200, 100), &HFF7F0000, B
  446.     LINE (5, 90)-(map!(rbyt, 1, 255, 5, 200), 100), &HFF7F0000, BF
  447.     _PRINTSTRING (5, 110), "Green " + STR$(gbyt)
  448.     LINE (5, 130)-(200, 140), &HFF007F00, B
  449.     LINE (5, 130)-(map!(gbyt, 1, 255, 5, 200), 140), &HFF007F00, BF
  450.     _PRINTSTRING (5, 150), "Blue " + STR$(bbyt)
  451.     LINE (5, 170)-(200, 180), &HFF0000FF, B
  452.     LINE (5, 170)-(map!(bbyt, 1, 255, 5, 200), 180), &HFF0000FF, BF
  453.  
  454.     _PRINTSTRING (284, 30), "Size" '                            size buttons
  455.     Con_Blok 225, 46, 32, 24, "-", 1, &HFF00007F
  456.     Con_Blok 343, 46, 32, 24, "+", 1, &HFF00007F
  457.     _PRINTSTRING (284, 48), STR$(gsiz)
  458.  
  459.     LINE (285, 90)-(315, 180), &HFFFFFFFF, B '                  offset cross
  460.     LINE (255, 120)-(345, 150), &HFFFFFFFF, B
  461.     CIRCLE (300, 135), 8, &HFFFF0000
  462.     LINE (290, 135)-(310, 135), &HFFFF0000
  463.     LINE (300, 125)-(300, 145), &HFFFF0000
  464.     RotoZoom3 285 + _WIDTH(arw&) / 2, 90 + _HEIGHT(arw&) / 2, arw&, 1, 1, 0
  465.     RotoZoom3 255 + _WIDTH(arw&) / 2, 120 + _HEIGHT(arw&) / 2, arw&, 1, 1, _PI * 3 / 2
  466.     RotoZoom3 315 + _WIDTH(arw&) / 2, 120 + _HEIGHT(arw&) / 2, arw&, 1, 1, _PI / 2
  467.     RotoZoom3 285 + _WIDTH(arw&) / 2, 150 + _HEIGHT(arw&) / 2, arw&, 1, 1, _PI
  468.  
  469. END SUB 'Para_Disp
  470.  
  471.  
  472. SUB RotoZoom3 (X AS LONG, Y AS LONG, Image AS LONG, xScale AS SINGLE, yScale AS SINGLE, radianRotation AS SINGLE)
  473.  
  474.     ' Thanks be to Galleon and Bplus for this SUB, wish I was this good...
  475.     ' This assumes you have set your drawing location with _DEST or default to screen.
  476.     ' X, Y - is where you want to put the middle of the image
  477.     ' Image - is the handle assigned to the image to be rotated
  478.     ' xScale, yScale - are shrinkage < 1 or magnification > 1 on the given axis, 1 just uses image size.
  479.     ' These are multipliers so .5 will create image .5 size on given axis and 2 for twice image size.
  480.     ' radianRotation is the Angle in Radian units to rotate the image
  481.     ' note: Radian units for rotation because it matches angle units of other Basic Trig functions
  482.     '       and saves a little time converting from degree.
  483.     '       Use the _D2R() function if you prefer to work in degree units for angles.
  484.  
  485.     DIM px(3) AS SINGLE: DIM py(3) AS SINGLE '                  simple arrays for x, y to hold the 4 corners of image
  486.     DIM W&, H&, sinr!, cosr!, i&, x2&, y2& '                    variables for image manipulation
  487.     W& = _WIDTH(Image&): H& = _HEIGHT(Image&)
  488.     px(0) = -W& / 2: py(0) = -H& / 2 '                          left top corner
  489.     px(1) = -W& / 2: py(1) = H& / 2 '                           left bottom corner
  490.     px(2) = W& / 2: py(2) = H& / 2 '                            right bottom
  491.     px(3) = W& / 2: py(3) = -H& / 2 '                           right top
  492.     sinr! = SIN(-radianRotation): cosr! = COS(-radianRotation) 'rotation helpers
  493.     FOR i& = 0 TO 3 '                                           calc new point locations with rotation and zoom
  494.         x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
  495.         px(i&) = x2&: py(i&) = y2&
  496.     NEXT
  497.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, H& - 1)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(1), py(1))-(px(2), py(2))
  498.     _MAPTRIANGLE _SEAMLESS(0, 0)-(W& - 1, 0)-(W& - 1, H& - 1), Image TO(px(0), py(0))-(px(3), py(3))-(px(2), py(2))
  499.  
  500. END SUB 'RotoZoom3
  501.  
  502.  
  503. SUB Save_Gridpic
  504.  
  505.     DIM si&, fn$, fn1$, r
  506.     DialogBox "Save Image", 600, 400, 50, &HFF0000FF, &HFFFFFFFF
  507.     si& = _COPYIMAGE(mp&, 32)
  508.     _PUTIMAGE , grid&, si&
  509.     _PRINTSTRING (_WIDTH(main&) / 2 - 140, 116), "Input path \ filename and extension", 0
  510.     _DISPLAY
  511.     LOCATE 148 \ 16, (_WIDTH(main&) / 2 - 120) \ 8
  512.     INPUT ": ", fn$: fn$ = _TRIM$(fn$)
  513.     r = SaveImage(fn$, si&, 0, 0, _WIDTH(si&) - 1, _HEIGHT(si&) - 1)
  514.     IF r = 1 THEN
  515.         fn1$ = "grid_" + fn$
  516.         r = SaveImage(fn1$, si&, 0, 0, _WIDTH(si&) - 1, _HEIGHT(si&) - 1)
  517.     END IF
  518.     IF r < 0 THEN
  519.         _PRINTSTRING (_WIDTH(main&) / 2 - 68, 300), "successful export", 0
  520.         _DISPLAY
  521.         SLEEP 2
  522.     END IF
  523.     _FREEIMAGE si&
  524.  
  525. END SUB 'Save_Gridpic
  526.  
  527. '$INCLUDE:'SaveImage.BM'
  528.  
  529.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Multiple Panels
« Reply #14 on: January 20, 2022, 01:17:23 am »
Do you mean something like the following?

Code: [Select]
LF = _NewImage(512, 300, 32)
RF = _NewImage(512, 300, 32)
CF = _NewImage(1024, 420, 32)
DisplayScreen = _NewImage(1024, 720, 32)

Screen DisplayScreen

'Stuff to print ot left side
_Dest LF
Cls , &HFF0000AA
Color , 0
Print "Joe Blow"
Print
Print "Age: 18"
Print "Sex: M"
Print
Print "ATK: 18:" 'attack
Print "DEF: 12" 'deffense
Print "MAT: 08" 'magic attack
Print "MDF: 05" 'magic defense
Print
Print "Health: 102 / 126"
Print "Mana  : 12  / 12"

'Stuff to print to the right side
_Dest RF
Cls , &HFF7700AA
Color , 0
Print "Day: 01"
Print "Location: Home"
Print "Time: 07:00 AM"
Print
Print "Directions Available:"
Print "North"
Print "Bed"

'Stuff to print to the center area
_Dest CF
Print "You wake up in your bed, in your home, with a hangover.  The sun is high in the sky and your alarm either failed to go off this morning, or else you were simply too drunk and hungover to respond to it.  Yesterday you were fired at work, and last night you spent drinking away your worries and concerns until into the wee hours of the morning."
Print ""
Print "In the room is your dirty clothes which are scattered all across the floor, your closet where you keep your clothes and extra blankets and such for the bed, and a small nightside table where you keep your loaded 45, in case of home invasion while you sleep.  You live in a rough neighborhood after all!"
Print
Print "What do you want to do now? "
Print

_Dest DisplayScreen
Do
    Cls
    _PutImage (0, 0), LF, DisplayScreen
    _PutImage (512, 0), RF, DisplayScreen
    _PutImage (0, 300), CF, DisplayScreen
    _PrintString (0, 700), "=>" + user$
    _Limit 30
    _Display
Loop Until _KeyHit

Cool... That's the kind of layout That I am aiming for... I will take a look at your 'framework'. Many thanks for the tips.

J
Logic is the beginning of wisdom.