Pen Scrolling

Материал из Поле цифровой дидактики

A pen scrolling engine is a scrolling engine that uses the Pen Extension.

Setup

Create these variables:

ScrollXScrollYXVelYVel

Create these custom blocks:

drawstage
drawplayer
controls
gotox:y:withscroll

Scripts

To start off, create the main script.

whenclickedhidesetScrollXto0setScrollYto0setXVelto0setXVelto0forevereraseallResetthestagedrawstageThiswillbeexplainedlaterdrawplayerThiswillbeexplainedlatercontrolsThiswillbeexplainedlaterend

Now, add the control script.

definecontrolschangeXVelbykeyrightarrowpressed?-keyleftarrowpressed?changeYVelbykeyuparrowpressed?-keydownarrowpressed?setXVeltoXVel*0.9setYVeltoYVel*0.9changeScrollXbyXVelchangeScrollYbyYVel

Now the important part, the stage.

definedrawstageMakesurethisis"RunWithoutScreenRefresh".setpensizeto5setpencolortogotox:50y:50withscrollpendowngotox:50y:-50withscrollgotox:-50y:-50withscrollgotox:-50y:50withscrollgotox:50y:50withscrollpenupdefinegotox:xy:ywithscrollgotox:x-ScrollXy:y-ScrollY

Now to draw the player:

definedrawplayerMakesurethisissetto"RunWithoutScreenRefresh".gotox:0y:0setpensizeto40setpencolortopendownpenup

Now the pen scrolling engine is complete.