@@ -49,6 +49,7 @@ void MotionBlocks::registerBlocks(IEngine *engine)
4949 engine->addCompileFunction (this , " motion_glideto" , &compileGlideTo);
5050 engine->addCompileFunction (this , " motion_changexby" , &compileChangeXBy);
5151 engine->addCompileFunction (this , " motion_setx" , &compileSetX);
52+ engine->addCompileFunction (this , " motion_changeyby" , &compileChangeYBy);
5253}
5354
5455CompilerValue *MotionBlocks::compileMoveSteps (Compiler *compiler)
@@ -268,6 +269,16 @@ CompilerValue *MotionBlocks::compileSetX(Compiler *compiler)
268269 return nullptr ;
269270}
270271
272+ CompilerValue *MotionBlocks::compileChangeYBy (Compiler *compiler)
273+ {
274+ if (!compiler->target ()->isStage ()) {
275+ CompilerValue *dy = compiler->addInput (" DY" );
276+ compiler->addTargetFunctionCall (" motion_changeyby" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { dy });
277+ }
278+
279+ return nullptr ;
280+ }
281+
271282extern " C" void motion_movesteps (Sprite *sprite, double steps)
272283{
273284 double dir = sprite->direction ();
@@ -542,6 +553,11 @@ extern "C" void motion_setx(Sprite *sprite, double x)
542553 sprite->setX (x);
543554}
544555
556+ extern " C" void motion_changeyby (Sprite *sprite, double dy)
557+ {
558+ sprite->setY (sprite->y () + dy);
559+ }
560+
545561extern " C" double motion_xposition (Sprite *sprite)
546562{
547563 return sprite->x ();
0 commit comments