Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull #4

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/Engine/Bytecode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
70 changes: 66 additions & 4 deletions source/Engine/Bytecode/StandardLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion source/Engine/Scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading