From 92bc9ebea49cba76776657539301f6a8652341d7 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 18:25:20 -0400 Subject: [PATCH 1/6] Change from c_str to std::string --- ZSharp/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZSharp/Main.cpp b/ZSharp/Main.cpp index 24b673d..eab0dd3 100644 --- a/ZSharp/Main.cpp +++ b/ZSharp/Main.cpp @@ -803,7 +803,7 @@ int main(int argc, char* argv[]) // Change the current working directory to that of the script int chErr = chdir(projectDirectory.c_str()); if (chErr < 0) - LogCriticalError("Failed to change directory to: \"" + projectDirectory.c_str() + "\", error num: " + chErr); + LogCriticalError("Failed to change directory to: \"" + projectDirectory + "\", error num: " + chErr); #if DEVELOPER_MESSAGES InterpreterLog("Changed directory to " + projectDirectory + "..."); #endif From f6462291a7c33682bea325035d2b270f12f4e293 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 18:27:23 -0400 Subject: [PATCH 2/6] Convert int to string --- ZSharp/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZSharp/Main.cpp b/ZSharp/Main.cpp index eab0dd3..64e1a04 100644 --- a/ZSharp/Main.cpp +++ b/ZSharp/Main.cpp @@ -803,7 +803,7 @@ int main(int argc, char* argv[]) // Change the current working directory to that of the script int chErr = chdir(projectDirectory.c_str()); if (chErr < 0) - LogCriticalError("Failed to change directory to: \"" + projectDirectory + "\", error num: " + chErr); + LogCriticalError("Failed to change directory to: \"" + projectDirectory + "\", error num: " + to_string(chErr)); #if DEVELOPER_MESSAGES InterpreterLog("Changed directory to " + projectDirectory + "..."); #endif From 21bc7074327fd9356faca2cf93850d57eee2120d Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 18:40:11 -0400 Subject: [PATCH 3/6] Change version to `2.1.0` --- ZSharp/Main.cpp | 2 +- ZSharp/strops.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ZSharp/Main.cpp b/ZSharp/Main.cpp index 64e1a04..96bd677 100644 --- a/ZSharp/Main.cpp +++ b/ZSharp/Main.cpp @@ -4,7 +4,7 @@ #include #define DEVELOPER_MESSAGES false #define EXAMPLE_PROJECT false -#define NAMEVERSION "ZSharp v2.0.2" +#define NAMEVERSION "ZSharp v2.1.0" #if defined(__unix__) #define UNIX true diff --git a/ZSharp/strops.h b/ZSharp/strops.h index 59dd899..24a171d 100644 --- a/ZSharp/strops.h +++ b/ZSharp/strops.h @@ -12,6 +12,7 @@ int AnyAsInt(const boost::any& val); bool AnyAsBool(const boost::any& val); + bool isNumber(const string& str); bool stob(const string& str); @@ -30,12 +31,14 @@ string trim(const string& s); vector split(const string& str, const char& del); +string betweenChars(const string& str, const char& openChar, const char& closeChar); + +vector splitNoOverlap(const string& str, const char& splitBy, const char& openChar, const char& closeChar); + int count(const string& str, const char& ch); int countNoOverlap(const string& str, const char& searchFor, const char& ch1, const char& ch2); -string betweenChars(const string& str, const char& openChar, const char& closeChar); - int countOutsideParenthesis(const string& str, const char& searchFor); int indexInStr(const string& str, const char& ch); @@ -66,6 +69,4 @@ bool isEscaped(const string& str, int curChar); bool startsWith(const string& str, const string& lookFor); -vector splitNoOverlap(const string& str, const char& splitBy, const char& openChar, const char& closeChar); - #endif From 64149d31cab0b5039233f669033cb8e4c6ae2cf0 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 18:42:03 -0400 Subject: [PATCH 4/6] Update ZSharpInstallerMakerInnoSetup.iss --- ZSharp/ZSharpInstallerMakerInnoSetup.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZSharp/ZSharpInstallerMakerInnoSetup.iss b/ZSharp/ZSharpInstallerMakerInnoSetup.iss index eb965eb..503a3a4 100644 --- a/ZSharp/ZSharpInstallerMakerInnoSetup.iss +++ b/ZSharp/ZSharpInstallerMakerInnoSetup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Z-Sharp" -#define MyAppVersion "2.0.2" +#define MyAppVersion "2.1.0" #define MyAppPublisher "AstroSam" #define MyAppURL "https://github.com/sam-astro/Z-Sharp" #define MyAppExeName "ZSharp.exe" From 30d8bb5424ccfe2e6d683723e4fa6127f1db8036 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 19:01:05 -0400 Subject: [PATCH 5/6] Change version to alpha --- ZSharp/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ZSharp/Main.cpp b/ZSharp/Main.cpp index 96bd677..95cba74 100644 --- a/ZSharp/Main.cpp +++ b/ZSharp/Main.cpp @@ -4,7 +4,7 @@ #include #define DEVELOPER_MESSAGES false #define EXAMPLE_PROJECT false -#define NAMEVERSION "ZSharp v2.1.0" +#define NAMEVERSION "ZSharp v2.1.0-alpha" #if defined(__unix__) #define UNIX true From 4fd4964f57665fd7ceec31db1444387291c8f2bd Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Tue, 24 May 2022 19:08:51 -0400 Subject: [PATCH 6/6] Fix issues that make pong not run in 2.1.0-alpha --- ZSharp/ZSharpInstallerMakerInnoSetup.iss | 2 +- examples/Pong-Example-Project/script.zs | 41 ++++++++++-------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/ZSharp/ZSharpInstallerMakerInnoSetup.iss b/ZSharp/ZSharpInstallerMakerInnoSetup.iss index 503a3a4..729149a 100644 --- a/ZSharp/ZSharpInstallerMakerInnoSetup.iss +++ b/ZSharp/ZSharpInstallerMakerInnoSetup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Z-Sharp" -#define MyAppVersion "2.1.0" +#define MyAppVersion "2.1.0-alpha" #define MyAppPublisher "AstroSam" #define MyAppURL "https://github.com/sam-astro/Z-Sharp" #define MyAppExeName "ZSharp.exe" diff --git a/examples/Pong-Example-Project/script.zs b/examples/Pong-Example-Project/script.zs index 36a1ef0..7f75a3c 100644 --- a/examples/Pong-Example-Project/script.zs +++ b/examples/Pong-Example-Project/script.zs @@ -61,75 +61,66 @@ func Start() func Update(deltaTime) { - float FPS = 1 / deltaTime - print "FPS: " + FPS + //float FPS = 1 / deltaTime + //print "FPS: " + FPS // Handles Left Paddle Movement // if GetKey("W") == true { - float newX = lPaddle.position.x // Subtract from Y to move up, because vertical coordinates are reversed float newY = lPaddleTargetPosition.y - paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + lPaddle.scale.y / 2, SCREENH - lPaddle.scale.y / 2) - lPaddleTargetPosition = NVec2(newX, newY) + lPaddleTargetPosition.y = newY } if GetKey("S") == true { - float newX = lPaddle.position.x // Add to Y to move down, because vertical coordinates are reversed float newY = lPaddleTargetPosition.y + paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + lPaddle.scale.y / 2, SCREENH - lPaddle.scale.y / 2) - lPaddleTargetPosition = NVec2(newX, newY) + lPaddleTargetPosition.y = newY } // Lerps from old position to destination smoothly float oldY = lPaddle.position.y float stopSpeed = deltaTime * lerpSpeed float newY = lPaddleTargetPosition.y float lerpedY = Lerp(oldY, newY, stopSpeed) - lPaddle.position = NVec2(newX, lerpedY) + lPaddle.position = NVec2(lPaddle.position.x, lerpedY) // Handles Right Paddle Movement // - if GetKey("UP") == true + if aiOn == false { - if aiOn == false + if GetKey("UP") == true { - float newX = rPaddle.position.x // Subtract from Y to move up, because vertical coordinates are reversed float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2) - rPaddleTargetPosition = NVec2(newX, newY) + rPaddleTargetPosition.y = newY } - } - if GetKey("DOWN") == true - { - if aiOn == false + if GetKey("DOWN") == true { - float newX = rPaddle.position.x // Add to Y to move down, because vertical coordinates are reversed float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2) - rPaddleTargetPosition = NVec2(newX, newY) + rPaddleTargetPosition.y = newY } } if aiOn == true { if rPaddle.position.y < ballSpr.position.y { - float newX = rPaddle.position.x // Add to Y to move down, because vertical coordinates are reversed float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2) - rPaddleTargetPosition = NVec2(newX, newY) + rPaddleTargetPosition.y = newY } if rPaddle.position.y > ballSpr.position.y { - float newX = rPaddle.position.x // Subtract from Y to move up, because vertical coordinates are reversed float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2) - rPaddleTargetPosition = NVec2(newX, newY) + rPaddleTargetPosition.y = newY } } // Lerps from old position to destination smoothly @@ -137,18 +128,20 @@ func Update(deltaTime) float stopSpeed = deltaTime * lerpSpeed float newY = rPaddleTargetPosition.y float lerpedY = Lerp(oldY, newY, stopSpeed) - rPaddle.position = NVec2(newX, lerpedY) + rPaddle.position = NVec2(rPaddle.position.x, lerpedY) if GetKey("ENTER") == true { + bool changeTo = false if aiOn == true { - aiOn = false + changeTo = false } if aiOn == false { - aiOn = true + changeTo = true } + aiOn = changeTo } Vec2 scaledVelocity = ballVelocity