@@ -42,6 +42,7 @@ void MotionBlocks::registerBlocks(IEngine *engine)
4242 engine->addCompileFunction (this , " motion_turnleft" , &compileTurnLeft);
4343 engine->addCompileFunction (this , " motion_pointindirection" , &compilePointInDirection);
4444 engine->addCompileFunction (this , " motion_pointtowards" , &compilePointTowards);
45+ engine->addCompileFunction (this , " motion_gotoxy" , &compileGoToXY);
4546}
4647
4748CompilerValue *MotionBlocks::compileMoveSteps (Compiler *compiler)
@@ -113,6 +114,17 @@ CompilerValue *MotionBlocks::compilePointTowards(Compiler *compiler)
113114 return nullptr ;
114115}
115116
117+ CompilerValue *MotionBlocks::compileGoToXY (Compiler *compiler)
118+ {
119+ if (!compiler->target ()->isStage ()) {
120+ CompilerValue *x = compiler->addInput (" X" );
121+ CompilerValue *y = compiler->addInput (" Y" );
122+ compiler->addTargetFunctionCall (" motion_gotoxy" , Compiler::StaticType::Void, { Compiler::StaticType::Number, Compiler::StaticType::Number }, { x, y });
123+ }
124+
125+ return nullptr ;
126+ }
127+
116128extern " C" void motion_movesteps (Sprite *sprite, double steps)
117129{
118130 double dir = sprite->direction ();
@@ -196,3 +208,8 @@ extern "C" void motion_pointtowards(ExecutionContext *ctx, const StringPtr *towa
196208 }
197209 }
198210}
211+
212+ extern " C" void motion_gotoxy (Sprite *sprite, double x, double y)
213+ {
214+ sprite->setPosition (x, y);
215+ }
0 commit comments