// Project: scissor // Created: 2019-09-02 // Shows how to use the SetScissor() and SetViewOffset() commands to create // a split screen effect // show all errors SetErrorMode(2) // set window properties SetWindowTitle( "scissor" ) SetWindowSize( 1024, 768, 0 ) SetWindowAllowResize( 1 ) // allow the user to resize the window // set display properties SetVirtualResolution( 1024, 768 ) // doesn't have to match the window SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts //create a couple of player sprites sprite1 = createsprite(0) setspritecolor(sprite1,255,0,0,255) SetSpriteSize(sprite1,64,64) sprite2 = createsprite(0) setspritecolor(sprite2,0,255,0,255) setspritesize(sprite2,64,64) //set a random direction for sprite movement angle1 as float angle2 as float angle1 = random(0,360) angle2 = random(0,360) dx1 as float dy1 as float dx2 as float dy2 as float dx1 = cos(angle1)*4 dy1 = sin(angle1)*4 dx2 = cos(angle2)*4 dy2 = sin(angle2)*4 //set a random starting position for the sprites px1 as float py1 as float px2 as float py2 as float px1 = random(0,1024) py1 = random(0,768) SetSpritePosition(sprite1,px1,py1) px2 = random(0,1024) py2 = random(0,768) SetSpritePosition(sprite2,px2,py2) //lets fill the area with some random static sprites for i = 1 to 20 sprite = createsprite(0) setspritecolor(sprite,0,0,255,255) setspritesize(sprite,random(32,128),random(32,128)) setspriteposition(sprite,random(0,1024),random(0,768)) next do //update the sprites positions px1 = px1 + dx1 py1 = py1 + dy1 if px1 <= 0 or px1 >= 959 then dx1 = -dx1 if py1 <=0 or py1 >= 703 then dy1 = -dy1 SetSpritePosition(sprite1,px1,py1) px2 = px2 + dx2 py2 = py2 + dy2 if px2 <= 0 or px2 >= 959 then dx2 = -dx2 if py2 <=0 or py2 >= 703 then dy2 = -dy2 SetSpritePosition(sprite2,px2,py2) //set rendering to left half and view offset centered on sprite1 SetScissor(0,0,511,767) SetViewOffset(Round(px1)-224,Round(py1)-352) render() //set rendering to left half and view offset centered on sprite2 SetScissor(512,0,1023,767) SetViewOffset(round(px2)-736,round(py2)-352) sync() loop