diff --git a/source/Engine/Bytecode/Compiler.cpp b/source/Engine/Bytecode/Compiler.cpp index 2c4f3cb4..af640d83 100644 --- a/source/Engine/Bytecode/Compiler.cpp +++ b/source/Engine/Bytecode/Compiler.cpp @@ -1503,7 +1503,7 @@ PUBLIC void Compiler::GetUnary(bool canAssign) { case TOKEN_LOGICAL_NOT: EmitByte(OP_LG_NOT); break; case TOKEN_TYPEOF: EmitByte(OP_TYPEOF); break; - // HACK: replace these with prefix version of OP + // TODO: replace these with prefix version of OP // case TOKEN_INCREMENT: EmitByte(OP_INCREMENT); break; // case TOKEN_DECREMENT: EmitByte(OP_DECREMENT); break; default: diff --git a/source/Engine/Bytecode/StandardLibrary.cpp b/source/Engine/Bytecode/StandardLibrary.cpp index a26dfc9a..18abff2c 100644 --- a/source/Engine/Bytecode/StandardLibrary.cpp +++ b/source/Engine/Bytecode/StandardLibrary.cpp @@ -490,6 +490,21 @@ VMValue Animator_Create(int argCount, VMValue* args, Uint32 threadID) { return INTEGER_VAL((int)index); } +/*** + * Animator.Remove + * \desc Removes an animator. + * \param animator (Integer): The index of the animator. + * \ns Animator + */ +VMValue Animator_Remove(int argCount, VMValue* args, Uint32 threadID) { + CHECK_ARGCOUNT(1); + int animator = GET_ARG(0, GetInteger); + if (!Scene::AnimatorList[animator]) + return NULL_VAL; + delete Scene::AnimatorList[animator]; + Scene::AnimatorList[animator] = NULL; + return NULL_VAL; +} /*** * Animator.SetAnimation * \desc Sets the current animation and frame of an animator. @@ -8768,8 +8783,8 @@ VMValue Scene_ObjectTileCollision(int argCount, VMValue* args, Uint32 threadID) int cLayers = GET_ARG(1, GetInteger); int cMode = GET_ARG(2, GetInteger); int cPlane = GET_ARG(3, GetInteger); - int xOffset = GET_ARG(4, GetDecimal); - int yOffset = GET_ARG(5, GetDecimal); + int xOffset = (int)GET_ARG(4, GetDecimal); + int yOffset = (int)GET_ARG(5, GetDecimal); int setPos = GET_ARG(6, GetInteger); auto ent = (Entity*)entity->EntityPtr; @@ -8795,8 +8810,8 @@ VMValue Scene_ObjectTileGrip(int argCount, VMValue* args, Uint32 threadID) { int cLayers = GET_ARG(1, GetInteger); int cMode = GET_ARG(2, GetInteger); int cPlane = GET_ARG(3, GetInteger); - float xOffset = GET_ARG(4, GetDecimal); - float yOffset = GET_ARG(5, GetDecimal); + int xOffset = (int)GET_ARG(4, GetDecimal); + int yOffset = (int)GET_ARG(5, GetDecimal); float tolerance = GET_ARG(6, GetDecimal); auto ent = (Entity*)entity->EntityPtr; @@ -14379,6 +14394,49 @@ VMValue View_SetZ(int argCount, VMValue* args, Uint32 threadID) { Scene::Views[view_index].Z = value; return NULL_VAL; } +/*** +View.AdjustX +* \desc Adjusts the x - axis position of the camera for the specified view by an amount. +* \param viewIndex(Integer) : Index of the view. +* \param x(Number) : Desired X adjust amount. +* \ns View +*/ +VMValue View_AdjustX(int argCount, VMValue * args, Uint32 threadID) { + CHECK_ARGCOUNT(2); + int view_index = GET_ARG(0, GetInteger); + CHECK_VIEW_INDEX(); + Scene::Views[view_index].X += GET_ARG(1, GetDecimal); + return NULL_VAL; +} +/*** +* View.AdjustY +* \desc Adjusts the y-axis position of the camera for the specified view by an amount. +* \param viewIndex (Integer): Index of the view. +* \param y (Number): Desired Y adjust amount. +* \ns View +*/ +VMValue View_AdjustY(int argCount, VMValue * args, Uint32 threadID) { + CHECK_ARGCOUNT(2); + int view_index = GET_ARG(0, GetInteger); + CHECK_VIEW_INDEX(); + Scene::Views[view_index].Y += GET_ARG(1, GetDecimal); + return NULL_VAL; +} +/*** +* View.AdjustX +* \desc Adjusts the z-axis position of the camera for the specified view by an amount. +* \param viewIndex (Integer): Index of the view. +* \param z (Number): Desired Z adjust amount. +* \ns View +*/ +VMValue View_AdjustZ(int argCount, VMValue * args, Uint32 threadID) { + CHECK_ARGCOUNT(2); + int view_index = GET_ARG(0, GetInteger); + CHECK_VIEW_INDEX(); + Scene::Views[view_index].Z += GET_ARG(1, GetDecimal); + return NULL_VAL; +} + /*** * View.SetPosition * \desc Sets the position of the camera for the specified view. @@ -15177,6 +15235,7 @@ PUBLIC STATIC void StandardLibrary::Link() { // #region Animator INIT_CLASS(Animator); DEF_NATIVE(Animator, Create); + DEF_NATIVE(Animator, Remove); DEF_NATIVE(Animator, SetAnimation); DEF_NATIVE(Animator, Animate); DEF_NATIVE(Animator, GetSprite); @@ -17072,6 +17131,9 @@ PUBLIC STATIC void StandardLibrary::Link() { DEF_NATIVE(View, SetX); DEF_NATIVE(View, SetY); DEF_NATIVE(View, SetZ); + DEF_NATIVE(View, AdjustX); + DEF_NATIVE(View, AdjustY); + DEF_NATIVE(View, AdjustZ); DEF_NATIVE(View, SetPosition); DEF_NATIVE(View, SetAngle); DEF_NATIVE(View, SetSize); diff --git a/source/Engine/Scene.cpp b/source/Engine/Scene.cpp index f4c2cfab..39984e1d 100644 --- a/source/Engine/Scene.cpp +++ b/source/Engine/Scene.cpp @@ -3566,7 +3566,7 @@ PUBLIC STATIC bool Scene::ObjectTileCollision(Entity* entity, int cLayers, int c } } -PUBLIC STATIC bool Scene::ObjectTileGrip(Entity* entity, int cLayers, int cMode, int cPlane, float xOffset, float yOffset, float tolerance) { +PUBLIC STATIC bool Scene::ObjectTileGrip(Entity* entity, int cLayers, int cMode, int cPlane, int xOffset, int yOffset, float tolerance) { int layerID = 1; bool collided = false; int posX = xOffset + entity->X;