Merge branch 'master' into dev

This commit is contained in:
sam-astro 2022-05-24 21:12:47 -04:00
commit 725ec88fd5
4 changed files with 27 additions and 34 deletions

View File

@ -4,7 +4,7 @@
#include <string>
#define DEVELOPER_MESSAGES false
#define EXAMPLE_PROJECT false
#define NAMEVERSION "ZSharp v2.0.2"
#define NAMEVERSION "ZSharp v2.1.0-alpha"
#if defined(__unix__)
#define UNIX true
@ -803,13 +803,12 @@ 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
#if DEVELOPER_MESSAGES
string newPath = filesystem::current_path();
#endif
#elif WINDOWS
// Get script contents as single string
ifstream script(scriptPath);

View File

@ -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-alpha"
#define MyAppPublisher "AstroSam"
#define MyAppURL "https://github.com/sam-astro/Z-Sharp"
#define MyAppExeName "ZSharp.exe"

View File

@ -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<string> split(const string& str, const char& del);
string betweenChars(const string& str, const char& openChar, const char& closeChar);
vector<string> 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<string> splitNoOverlap(const string& str, const char& splitBy, const char& openChar, const char& closeChar);
#endif

View File

@ -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
{
float newX = rPaddle.position.x
if GetKey("UP") == true
{
// 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
{
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