mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2026-02-04 07:02:11 +00:00
Merge branch 'master' into dev
This commit is contained in:
commit
725ec88fd5
@ -4,7 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#define DEVELOPER_MESSAGES false
|
#define DEVELOPER_MESSAGES false
|
||||||
#define EXAMPLE_PROJECT false
|
#define EXAMPLE_PROJECT false
|
||||||
#define NAMEVERSION "ZSharp v2.0.2"
|
#define NAMEVERSION "ZSharp v2.1.0-alpha"
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
#define UNIX true
|
#define UNIX true
|
||||||
@ -803,13 +803,12 @@ int main(int argc, char* argv[])
|
|||||||
// Change the current working directory to that of the script
|
// Change the current working directory to that of the script
|
||||||
int chErr = chdir(projectDirectory.c_str());
|
int chErr = chdir(projectDirectory.c_str());
|
||||||
if (chErr < 0)
|
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
|
#if DEVELOPER_MESSAGES
|
||||||
InterpreterLog("Changed directory to " + projectDirectory + "...");
|
InterpreterLog("Changed directory to " + projectDirectory + "...");
|
||||||
#endif
|
#endif
|
||||||
#if DEVELOPER_MESSAGES
|
|
||||||
string newPath = filesystem::current_path();
|
|
||||||
#endif
|
|
||||||
#elif WINDOWS
|
#elif WINDOWS
|
||||||
// Get script contents as single string
|
// Get script contents as single string
|
||||||
ifstream script(scriptPath);
|
ifstream script(scriptPath);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
|
||||||
|
|
||||||
#define MyAppName "Z-Sharp"
|
#define MyAppName "Z-Sharp"
|
||||||
#define MyAppVersion "2.0.2"
|
#define MyAppVersion "2.1.0-alpha"
|
||||||
#define MyAppPublisher "AstroSam"
|
#define MyAppPublisher "AstroSam"
|
||||||
#define MyAppURL "https://github.com/sam-astro/Z-Sharp"
|
#define MyAppURL "https://github.com/sam-astro/Z-Sharp"
|
||||||
#define MyAppExeName "ZSharp.exe"
|
#define MyAppExeName "ZSharp.exe"
|
||||||
|
|||||||
@ -12,6 +12,7 @@ int AnyAsInt(const boost::any& val);
|
|||||||
bool AnyAsBool(const boost::any& val);
|
bool AnyAsBool(const boost::any& val);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool isNumber(const string& str);
|
bool isNumber(const string& str);
|
||||||
|
|
||||||
bool stob(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);
|
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 count(const string& str, const char& ch);
|
||||||
|
|
||||||
int countNoOverlap(const string& str, const char& searchFor, const char& ch1, const char& ch2);
|
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 countOutsideParenthesis(const string& str, const char& searchFor);
|
||||||
|
|
||||||
int indexInStr(const string& str, const char& ch);
|
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);
|
bool startsWith(const string& str, const string& lookFor);
|
||||||
|
|
||||||
vector<string> splitNoOverlap(const string& str, const char& splitBy, const char& openChar, const char& closeChar);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -61,75 +61,66 @@ func Start()
|
|||||||
|
|
||||||
func Update(deltaTime)
|
func Update(deltaTime)
|
||||||
{
|
{
|
||||||
float FPS = 1 / deltaTime
|
//float FPS = 1 / deltaTime
|
||||||
print "FPS: " + FPS
|
//print "FPS: " + FPS
|
||||||
|
|
||||||
// Handles Left Paddle Movement
|
// Handles Left Paddle Movement
|
||||||
//
|
//
|
||||||
if GetKey("W") == true
|
if GetKey("W") == true
|
||||||
{
|
{
|
||||||
float newX = lPaddle.position.x
|
|
||||||
// Subtract from Y to move up, because vertical coordinates are reversed
|
// Subtract from Y to move up, because vertical coordinates are reversed
|
||||||
float newY = lPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
float newY = lPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + lPaddle.scale.y / 2, SCREENH - lPaddle.scale.y / 2)
|
newY = Clamp(newY, 0 + lPaddle.scale.y / 2, SCREENH - lPaddle.scale.y / 2)
|
||||||
lPaddleTargetPosition = NVec2(newX, newY)
|
lPaddleTargetPosition.y = newY
|
||||||
}
|
}
|
||||||
if GetKey("S") == true
|
if GetKey("S") == true
|
||||||
{
|
{
|
||||||
float newX = lPaddle.position.x
|
|
||||||
// Add to Y to move down, because vertical coordinates are reversed
|
// Add to Y to move down, because vertical coordinates are reversed
|
||||||
float newY = lPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
float newY = lPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + lPaddle.scale.y / 2, SCREENH - lPaddle.scale.y / 2)
|
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
|
// Lerps from old position to destination smoothly
|
||||||
float oldY = lPaddle.position.y
|
float oldY = lPaddle.position.y
|
||||||
float stopSpeed = deltaTime * lerpSpeed
|
float stopSpeed = deltaTime * lerpSpeed
|
||||||
float newY = lPaddleTargetPosition.y
|
float newY = lPaddleTargetPosition.y
|
||||||
float lerpedY = Lerp(oldY, newY, stopSpeed)
|
float lerpedY = Lerp(oldY, newY, stopSpeed)
|
||||||
lPaddle.position = NVec2(newX, lerpedY)
|
lPaddle.position = NVec2(lPaddle.position.x, lerpedY)
|
||||||
|
|
||||||
// Handles Right Paddle Movement
|
// 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
|
// Subtract from Y to move up, because vertical coordinates are reversed
|
||||||
float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2)
|
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 GetKey("DOWN") == true
|
|
||||||
{
|
|
||||||
if aiOn == false
|
|
||||||
{
|
{
|
||||||
float newX = rPaddle.position.x
|
|
||||||
// Add to Y to move down, because vertical coordinates are reversed
|
// Add to Y to move down, because vertical coordinates are reversed
|
||||||
float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2)
|
newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2)
|
||||||
rPaddleTargetPosition = NVec2(newX, newY)
|
rPaddleTargetPosition.y = newY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if aiOn == true
|
if aiOn == true
|
||||||
{
|
{
|
||||||
if rPaddle.position.y < ballSpr.position.y
|
if rPaddle.position.y < ballSpr.position.y
|
||||||
{
|
{
|
||||||
float newX = rPaddle.position.x
|
|
||||||
// Add to Y to move down, because vertical coordinates are reversed
|
// Add to Y to move down, because vertical coordinates are reversed
|
||||||
float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
float newY = rPaddleTargetPosition.y + paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2)
|
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
|
if rPaddle.position.y > ballSpr.position.y
|
||||||
{
|
{
|
||||||
float newX = rPaddle.position.x
|
|
||||||
// Subtract from Y to move up, because vertical coordinates are reversed
|
// Subtract from Y to move up, because vertical coordinates are reversed
|
||||||
float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
float newY = rPaddleTargetPosition.y - paddleMoveSpeed * deltaTime
|
||||||
newY = Clamp(newY, 0 + rPaddle.scale.y / 2, SCREENH - rPaddle.scale.y / 2)
|
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
|
// Lerps from old position to destination smoothly
|
||||||
@ -137,18 +128,20 @@ func Update(deltaTime)
|
|||||||
float stopSpeed = deltaTime * lerpSpeed
|
float stopSpeed = deltaTime * lerpSpeed
|
||||||
float newY = rPaddleTargetPosition.y
|
float newY = rPaddleTargetPosition.y
|
||||||
float lerpedY = Lerp(oldY, newY, stopSpeed)
|
float lerpedY = Lerp(oldY, newY, stopSpeed)
|
||||||
rPaddle.position = NVec2(newX, lerpedY)
|
rPaddle.position = NVec2(rPaddle.position.x, lerpedY)
|
||||||
|
|
||||||
if GetKey("ENTER") == true
|
if GetKey("ENTER") == true
|
||||||
{
|
{
|
||||||
|
bool changeTo = false
|
||||||
if aiOn == true
|
if aiOn == true
|
||||||
{
|
{
|
||||||
aiOn = false
|
changeTo = false
|
||||||
}
|
}
|
||||||
if aiOn == false
|
if aiOn == false
|
||||||
{
|
{
|
||||||
aiOn = true
|
changeTo = true
|
||||||
}
|
}
|
||||||
|
aiOn = changeTo
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2 scaledVelocity = ballVelocity
|
Vec2 scaledVelocity = ballVelocity
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user