Difference between revisions of "DISPLAY"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
m
Line 1: Line 1:
The {{KW|_DISPLAY}} statement turns off the automatic display of the screen graphics (which is at around 30 fps) while displaying the screen graphics.  
The {{KW|_DISPLAY}} statement turns off automatic display while only displaying the screen graphics when called.  




{{PageSyntax}}
{{PageSyntax}} <code>{{KW|_DISPLAY}}</code>
:<code>{{KW|_DISPLAY}}</code>




{{PageDescription}}
{{PageDescription}}
* '''_DISPLAY''' turns off the default [[_AUTODISPLAY]] when used.
* '''_DISPLAY''' turns off the default [[_AUTODISPLAY]] when used. Prevents screen flickering.
* Call _DISPLAY each time the screen graphics are to be displayed.  
* Call _DISPLAY each time the screen graphics are to be displayed. Place call after the image has been changed.
* Re-enable the automatic display by calling [[_AUTODISPLAY]].
* Re-enable the automatic display by calling [[_AUTODISPLAY]].


Line 16: Line 15:


  {{Cl|SCREEN (statement)|SCREEN}} 12
  {{Cl|SCREEN (statement)|SCREEN}} 12
  x = 21: y =31
  x = 21: y =31             'start position
  dx = 3: dy = 3
  dx = 3: dy = 3             'number of pixel moves per loop     
  {{Cl|DO}}
  {{Cl|DO}}
     {{Cl|_LIMIT}} 100 ' set to 100 frames per second
     {{Cl|_LIMIT}} 100       ' set to 100 frames per second
     x = x + dx: y = y + dy
     x = x + dx: y = y + dy
     {{Cl|IF...THEN|IF}} x < 0 {{Cl|OR}} x > 640 {{Cl|THEN}} dx = -dx  'limit columns
     {{Cl|IF...THEN|IF}} x < 0 {{Cl|OR}} x > 640 {{Cl|THEN}} dx = -dx  'limit columns
Line 25: Line 24:
     IF px <> x OR py <> y THEN FOR d = 1 to 20: CIRCLE (px, py), d, 0: NEXT 'erase
     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
     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
     px = x: py = y       'save older coordinates to erase older circle next loop
     {{Cl|_DISPLAY}} 'after new circle is set, show it
     {{Cl|_DISPLAY}}               'after new circle is set, show it
  {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = CHR$(27)
  {{Cl|LOOP}} {{Cl|UNTIL}} {{Cl|INKEY$}} = CHR$(27)


{{CodeEnd}}
{{CodeEnd}}


:''Explanation:'' The loop is set with [[_LIMIT]] to 100 frames per second to limit CPU usage. 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. This 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 helps slow the ball.
:''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.




Line 37: Line 36:
{{PageSeeAlso}}
{{PageSeeAlso}}
* {{KW|_AUTODISPLAY}}
* {{KW|_AUTODISPLAY}}
* {{KW|PCOPY}}




{{PageNavigation}}
{{PageNavigation}}

Revision as of 03:14, 11 July 2010

The _DISPLAY statement turns off automatic display while only displaying the screen graphics when called.


== Syntax == _DISPLAY


Description

  • _DISPLAY turns off the default _AUTODISPLAY when used. Prevents screen flickering.
  • Call _DISPLAY each time the screen graphics are to be displayed. Place call after the image has been changed.
  • Re-enable the automatic display by calling _AUTODISPLAY.


Examples: Displaying a circle bouncing around the screen.

SCREEN 12 x = 21: y =31 'start position dx = 3: dy = 3 'number of pixel moves per loop DO _LIMIT 100 ' set to 100 frames per second x = x + dx: y = y + dy IF x < 0 OR x > 640 THEN dx = -dx 'limit columns IF y < 0 OR y > 480 THEN dy = -dy 'limit rows IF px <> x OR py <> y THEN FOR d = 1 to 20: CIRCLE (px, py), d, 0: NEXT 'erase FOR c = 1 TO 20: 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 _DISPLAY 'after new circle is set, show it LOOP UNTIL INKEY$ = CHR$(27)

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 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.


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page