From QB64 Wiki
Revision as of 06:11, 10 July 2010 by imported>Clippy
Jump to navigation Jump to search

The _DISPLAY statement turns off the automatic display of the screen graphics (which is at around 30 fps) while displaying the screen graphics.




  • _DISPLAY turns off the default _AUTODISPLAY when used.
  • Call _DISPLAY each time the screen graphics are to be displayed.
  • Re-enable the automatic display by calling _AUTODISPLAY.

Examples: Displaying a circle bouncing around the screen.

SCREEN 12 x = 21: y =31 dx = 2: dy = 2 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 = 0 to 20: CIRCLE (px, py), d, 0: NEXT 'erase FOR c = 0 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. 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 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.

See also

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