@@ -50,6 +50,7 @@ void MotionBlocks::registerBlocks(IEngine *engine)
5050 engine->addCompileFunction (this , " motion_changexby" , &compileChangeXBy);
5151 engine->addCompileFunction (this , " motion_setx" , &compileSetX);
5252 engine->addCompileFunction (this , " motion_changeyby" , &compileChangeYBy);
53+ engine->addCompileFunction (this , " motion_sety" , &compileSetY);
5354}
5455
5556CompilerValue *MotionBlocks::compileMoveSteps (Compiler *compiler)
@@ -279,6 +280,16 @@ CompilerValue *MotionBlocks::compileChangeYBy(Compiler *compiler)
279280 return nullptr ;
280281}
281282
283+ CompilerValue *MotionBlocks::compileSetY (Compiler *compiler)
284+ {
285+ if (!compiler->target ()->isStage ()) {
286+ CompilerValue *y = compiler->addInput (" Y" );
287+ compiler->addTargetFunctionCall (" motion_sety" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { y });
288+ }
289+
290+ return nullptr ;
291+ }
292+
282293extern " C" void motion_movesteps (Sprite *sprite, double steps)
283294{
284295 double dir = sprite->direction ();
@@ -558,6 +569,11 @@ extern "C" void motion_changeyby(Sprite *sprite, double dy)
558569 sprite->setY (sprite->y () + dy);
559570}
560571
572+ extern " C" void motion_sety (Sprite *sprite, double y)
573+ {
574+ sprite->setY (y);
575+ }
576+
561577extern " C" double motion_xposition (Sprite *sprite)
562578{
563579 return sprite->x ();
0 commit comments