@@ -56,6 +56,7 @@ void MotionBlocks::registerBlocks(IEngine *engine)
5656 engine->addCompileFunction (this , " motion_setrotationstyle" , &compileSetRotationStyle);
5757 engine->addCompileFunction (this , " motion_xposition" , &compileXPosition);
5858 engine->addCompileFunction (this , " motion_yposition" , &compileYPosition);
59+ engine->addCompileFunction (this , " motion_direction" , &compileDirection);
5960}
6061
6162CompilerValue *MotionBlocks::compileMoveSteps (Compiler *compiler)
@@ -345,6 +346,14 @@ CompilerValue *MotionBlocks::compileYPosition(Compiler *compiler)
345346 return compiler->addTargetFunctionCall (" motion_yposition" , Compiler::StaticType::Number);
346347}
347348
349+ CompilerValue *MotionBlocks::compileDirection (Compiler *compiler)
350+ {
351+ if (compiler->target ()->isStage ())
352+ return compiler->addConstValue (90 );
353+ else
354+ return compiler->addTargetFunctionCall (" motion_direction" , Compiler::StaticType::Number);
355+ }
356+
348357extern " C" void motion_movesteps (Sprite *sprite, double steps)
349358{
350359 double dir = sprite->direction ();
@@ -737,3 +746,8 @@ extern "C" double motion_yposition(Sprite *sprite)
737746{
738747 return sprite->y ();
739748}
749+
750+ extern " C" double motion_direction (Sprite *sprite)
751+ {
752+ return sprite->direction ();
753+ }
0 commit comments