News:

Function Finder  Find all the functions within source code files

Main Menu

Scrolling Viewports

Started by kevin, December 15, 2010, 04:07:14 PM

Previous topic - Next topic

kevin

 Scrolling Viewports

    The following shows a few different ways of creating a scrolling area in the screen.  


  Using Viewport to limit the draw area.

PlayBASIC Code: [Select]
   size=32

//make a block
pad=4
boxc 0,0,size,size,true,$008000
boxc Pad,pad,size-pad,size-pad,true,$00ff00
boxc 0,0,size-1,size-1,false,$ffffff
getimage 1,0,0,size,size


loadFont "arial",1,48


Do
c1=rgb(20,80,50)
c2=rgb(82,40,20)
ShadeBox 0,0,800,600,c1,c1,c2,c2


; screen Viewport to a reduce area of the screen
ScreenViewport 100,100,700,500
tileimage 1,xpos,ypos,false
xpos=mod(xpos+1,size)
ypos=mod(ypos+1,size)

; Restore to original size
ScreenViewport 0,0,800,600
centertext 400,10,"Scrolling Viewport"
sync
loop




 
  Using Image  to limit the draw area.

PlayBASIC Code: [Select]
   // Load the 
loadFont "arial",1,48


//make a block
size=32
pad=4
boxc 0,0,size,size,true,$008000
boxc Pad,pad,size-pad,size-pad,true,$00ff00
boxc 0,0,size-1,size-1,false,$ffffff
getimage 1,0,0,size,size



// Create image to represent the scrolling screen
ScrollingScreen=NewImage(600,400)


// main loop of program.

Do
c1=rgb(20,80,50)
c2=rgb(82,40,20)
ShadeBox 0,0,800,600,c1,c1,c2,c2


; screen Viewport to a reduce area of the screen
rendertoimage ScrollingSCreen
tileimage 1,xpos,ypos,false
xpos=mod(xpos+1,size)
ypos=mod(ypos+1,size)


; Restore rendering back to the screen
rendertoscreen

; draw scrolling screen to the display
drawimage ScrollingScreen,100,100,false

; display the heading message
centertext 400,10,"Scrolling Using Images"

sync
loop