Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

Latest commit

 

History

History
131 lines (108 loc) · 3.96 KB

GPAGE.org

File metadata and controls

131 lines (108 loc) · 3.96 KB

Top | Up (Main) | < Previous (Array) | Next (Sprite) >

GPAGE

This command allows you to switch which graphic page will be drawn to and shown. Graphic pages are 6 512x512 images you can edit. They can be used as sprite sheets and background tile sheets with the SPPAGE and BGPAGE commands respectively. There is a negative graphic page that contains the font, but it can only be used with GCOPY.

Syntax

GPAGE display%, draw%
GPAGE OUT display%, draw%
Parameter/OutputDescription
display%The graphic page to display.
draw%The graphic page to use with drawing commands.

Examples

This example displays each of the graphic pages (excluding the font page) for 1 second. After that, it edits one page while displaying another.

ACLS

FOR I=0 TO 5
 'Run through each of the 6 graphic pages, showing their default graphics.
 GPAGE I,I
 ?"Showing graphic page ";I;"."
 WAIT 60 'Wait a second.
NEXT I

'Edit one page while showing another page
GPAGE 4,5
?"Showing graphic page 4 and editing graphic page 5."
GBOX 0,0,31,31,&hFF1F3F7F 'Pretty color
WAIT 60

GPAGE 5,4
?"Showing graphic page 5 and editing graphic page 4."
GBOX 32,32,63,63,&hFF7F1F3F 'Also just as pretty color
WAIT 60

?"Showing graphic page 5."
GPAGE 5,5

Drawing to one page and displaying another can create a “double-buffered” effect, where if one frame takes too long to draw, the gamer will see a complete picture instead of the currently drawing one.

ACLS

'This variable will hold our buffer page.
VAR BUFFPAGE=0

WHILE 1
 'Set current page to either 0 or 1.
 GPAGE BUFFPAGE,!BUFFPAGE
 
 'Clears page we're going to write to.
 GCLS
 
 'Swaps buffer. 0 becomes 1, 1 becomes 0.
 BUFFPAGE=!BUFFPAGE
 
 FOR I=0 TO 15
  'Draw some random boxes
  GBOX RND(400),RND(240),RND(400),RND(240)
  VSYNC 1 'Fake lag.
 VSYNC
WEND

Possible Errors

ErrorCause
Out of RangeEither display% or draw% is less than 0 or greater than 5. If you’re trying to display the font page, you’ll need to GCOPY it to an accessible page.

Version Information

3.1.0

Fixed a bug where using GPAGE after setting a GCLIP area would reset the GCLIP area. 1

3.2.0

OUT variant added. 1

See Also

References

1 SmileBoom, “Additions/Changes in Ver. 3.2.0 (June 17, 2015)” http://smilebasic.com/debug/archive/


Top | Up (Main) | < Previous (Array) | Next (Sprite) >