1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 11:40:38 +00:00
QB64-PE/internal/help/_DISPLAY.txt
SteveMcNeill 33adc04fc4 Add temp folder to repo. It's necessary as well!
Just more initial setting on... nothing much to see here.
2022-04-28 13:39:56 -04:00

84 lines
3.7 KiB
Plaintext

{{DISPLAYTITLE:_DISPLAY}}
The [[_DISPLAY]] statement turns off the automatic display while only displaying the screen changes when called.
{{PageSyntax}}
: [[_DISPLAY]]
{{PageDescription}}
* '''_DISPLAY''' turns off the auto refresh screen default [[_AUTODISPLAY]] behavior. Prevents screen flickering.
* Call _DISPLAY each time the screen graphics are to be displayed. Place call after the image has been changed.
* Re-enable automatic display refreshing by calling [[_AUTODISPLAY]]. If it isn't re-enabled, things may not be displayed later.
* _DISPLAY tells '''QB64''' to render all of the hardware [[_PUTIMAGE]] commands loaded into the buffer previously.
* The [[_AUTODISPLAY (function)]] can be used to detect the current display behavior.
* '''QB64''' can set the graphic rendering order of _SOFTWARE, _HARDWARE, and _GLRENDER with [[_DISPLAYORDER]].
{{PageExamples}}
''Example 1:'' Displaying a circle bouncing around the screen.
{{CodeStart}} '' ''
{{Cl|SCREEN (statement)|SCREEN}} 12
x = 21: y =31 'start position
dx = 3: dy = 3 'number of pixel moves per loop
{{Cl|DO}}
{{Cl|_LIMIT}} 100 ' set to 100 frames per second
x = x + dx: y = y + dy
{{Cl|IF...THEN|IF}} x < 0 {{Cl|OR}} x > 640 {{Cl|THEN}} dx = -dx 'limit columns and reverse column direction each side
{{Cl|IF...THEN|IF}} y < 0 {{Cl|OR}} y > 480 {{Cl|THEN}} dy = -dy 'limit rows and reverse row direction top or bottom
IF px <> x OR py <> y THEN FOR d = 1 to 20: CIRCLE (px, py), d, 0: NEXT 'erase
FOR c = 1 TO 20: {{Cl|CIRCLE}} (x, y), c, 6: NEXT 'draw new circle at new position
px = x: py = y 'save older coordinates to erase older circle next loop
{{Cl|_DISPLAY}} 'after new circle is set, show it
{{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = CHR$(27) '' ''
{{CodeEnd}}
:''Explanation:'' The loop is set with [[_LIMIT]] to 100 frames per second to limit CPU usage and the speed of the ball. Each loop a circle is drawn while the previous one is erased when the coordinates change. _DISPLAY only shows the new circle position once each loop. The '''_DISPLAY''' routine eliminates the need for setting [[SCREEN (statement)|SCREEN]] swap pages, [[CLS]] and [[PCOPY]]. _DISPLAY keeps the image off of the screen until the changes have all completed. Drawing 40 circles every loop helps slow down the ball.
''Example 2:'' [[_DISPLAY]] must be used to render hardware images placed with [[_PUTIMAGE]] ('''version 1.000 and up''').
{{CodeStart}} '' ''
{{Cl|CONST}} MenuHeight = 200
{{Cl|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32)
'{{Cl|SLEEP}} 1
{{Cl|LOCATE}} 20
DO
{{Cl|_LIMIT}} 30
DisplayMenu
k = {{Cl|_KEYHIT}}
{{Cl|IF...THEN|IF}} k <> 0 {{Cl|THEN}} {{Cl|PRINT}} k,
{{Cl|LOOP}} {{Cl|UNTIL}} k = 32 {{Cl|OR (boolean)|OR}} k = 27
{{Cl|SUB}} DisplayMenu
{{Cl|STATIC}} init, MS_HW {{Cl|AS}} {{Cl|LONG}}
{{Cl|IF...THEN|IF}} {{Cl|NOT}} init {{Cl|THEN}}
init = -1
MS = {{Cl|_NEWIMAGE}}(640, MenuHeight, 32) 'MenuScreen image
D = {{Cl|_DEST}}: {{Cl|_DEST}} MS
{{Cl|CLS}} , {{Cl|&H}}FFAAAAAA 'background color gray
{{Cl|_PRINTSTRING}} (20, 2), "Menu Test" 'image text
MS_HW = {{Cl|_COPYIMAGE}}(MS, 33) 'create the MenuScreen_HardWare image
{{Cl|_FREEIMAGE}} MS
{{Cl|_DEST}} D
{{Cl|END IF}}
{{Cl|_PUTIMAGE}} (0, 0)-(640, MenuHeight), MS_HW
{{Cl|_DISPLAY}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}{{small|Code adapted by Galleon}}
: ''Notes:'' When _DISPLAY is commented out, the hardware Menu Test screen portion will blink and key codes may be seen underneath.
{{PageSeeAlso}}
* [[_DISPLAY (function)]]
* [[_DISPLAYORDER]]
* [[_AUTODISPLAY]], [[_AUTODISPLAY (function)]]
* [[_PUTIMAGE]]
* [[PCOPY]]
{{PageNavigation}}
<