Advanced Scrolling Platformer Tutorial

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

Шаблон:StubШаблон:NotUsefulThis will be a step-by-step tutorial of how to make an advanced scrolling platformer. This is a type of platformer where it has physics as a normal platformer, yet has elements of a scrolling platformer.

Setting Up

Variables

For all sprites:

xvelocityyvelocitySCROLLXSCROLLYSlopeOldScrollY

Custom Block(s)

The following custom block will be needed:

definePlatformerPhysicsJumpHeightGravityFrictionRunningSpeed

Coding in The Player Sprite

X Movement

Starting in the Custom block, we add our X Movement to walk left and right.

definePlatformerPhysicsJumpHeightGravityFrictionRunningSpeedifkeyrightarrowpressedthenchangexvelocitybyRunningSpeed
ifkeyleftarrowpressedthenchangexvelocitybyRunningSpeed*-1
setxvelocitytoRunningSpeed*Friction

Y Movement

Under the Set X Velocity by Running Speed times Friction block that we made, we need gravity for our player to jump and fall, and slope physics.