mirror of
https://github.com/sam-astro/Z-Sharp.git
synced 2025-12-16 10:22:12 +00:00
Compare commits
No commits in common. "master" and "v2.1.1" have entirely different histories.
42
README.md
42
README.md
@ -1,17 +1,12 @@
|
|||||||
<img src="https://raw.githubusercontent.com/sam-astro/Z-Sharp/master/ExtraResources/ZS-Gem-Icon-Small.png"/><img src="https://raw.githubusercontent.com/sam-astro/Z-Sharp/master/ExtraResources/ZS-Logo-Light-Small.png"/>
|
<img src="https://raw.githubusercontent.com/sam-astro/Z-Sharp/master/ExtraResources/ZS-Gem-Icon-Small.png"/><img src="https://raw.githubusercontent.com/sam-astro/Z-Sharp/master/ExtraResources/ZS-Logo-Light-Small.png"/>
|
||||||
|
|
||||||
> Z-Sharp is no longer in development! This project was never meant to go beyond the scope of a simple thing I could make pong in, yet people continue to ask for features and fixes, and I continue to oblige. So sadly, even though this was a cool project in which I learned a lot, it will be ending now. I will eventually make some docs and standards for the syntax, and will still leave this repository open. This way anybody can make their own interpreter or compiler for it. I will also still accept pull requests for any changes to this repository.
|
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
Z-Sharp is a custom programming language I made because I don't like c++ very much (Z-Sharp's interpreter is written in c++ though). Z-Sharp scripts have the file extension .ZS. The base syntax and formatting I would say is quite similar to C# or Python, but differs as task complexity increases. It also has support for graphics using SDL2.
|
Z-Sharp is a custom programming language I made because I don't like c++ very much (Z-Sharp's interpreter is written in c++ though). Z-Sharp scripts have the file extension .ZS. The base syntax and formatting I would say is quite similar to C# or Python, but differs as task complexity increases. It has support for graphics using SDL2, and by default is not enabled.
|
||||||
|
|
||||||
Before using Z#:
|
Before using Z#:
|
||||||
There is ***no documentation***, ***strings*** barely work, ***performance*** isn't great, the syntax is ***very specific***, and most errors just cause it to ***crash without warning***. I am just a *single developer* working on this during my free time; between school, other projects, and YouTube. Z-Sharp will most likely never be finished, since it was really supposed to end when the video was published about it.
|
There is ***no documentation***, ***strings*** barely work, ***performance*** isn't great, the syntax is ***very specific***, and most errors just cause it to ***crash without warning***. I am just a *single developer* working on this during my free time; between school, other projects, and YouTube. Z-Sharp will most likely never be finished, since it was really supposed to end when the video was published about it.
|
||||||
If you are trying to use a common programming language feature, ask yourself this: ***Is this feature required to play pong?*** If not, then most likely that feature ***has not been implemented yet***. I initially only made the language so I could create pong and make a video about it, so it really is the ***bare minimum***.
|
If you are trying to use a common programming language feature, ask yourself this: ***Is this feature required to play pong?*** If not, then most likely that feature ***has not been implemented yet***. I initially only made the language so I could create pong and make a video about it, so it really is the ***bare minimum***.
|
||||||
|
|
||||||
## Documentation and getting started:
|
|
||||||
[The docs and tutorial](https://spazelectro.github.io/ZSharpDocs/#/README)
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Downloading or installing is very simple, here is how depending on your version and operating system:
|
Downloading or installing is very simple, here is how depending on your version and operating system:
|
||||||
### Windows
|
### Windows
|
||||||
@ -27,19 +22,36 @@ Downloading or installing is very simple, here is how depending on your version
|
|||||||
6. Feel free to use and edit the `Pong-Example-Project`. It is a single script called `script.zs`, and you can open it with any of the methods above. It is also located on the releases page.
|
6. Feel free to use and edit the `Pong-Example-Project`. It is a single script called `script.zs`, and you can open it with any of the methods above. It is also located on the releases page.
|
||||||
> If you don't want to install ZSharp on your device, or you want easier acces to the executable and .DLLs, another version is provided called `ZS_Win_Base_Raw.zip`. This just contains all of the files the installer puts on your computer.
|
> If you don't want to install ZSharp on your device, or you want easier acces to the executable and .DLLs, another version is provided called `ZS_Win_Base_Raw.zip`. This just contains all of the files the installer puts on your computer.
|
||||||
### Linux
|
### Linux
|
||||||
1. Install requirements: `SDL2, SDL2 Image, SDL2 TTF` Commands for `apt` and `pacman` below:
|
1. Install requirements:
|
||||||
|
* You need the package ***libsdl2-dev***.
|
||||||
|
|
||||||
#### Debian
|
For Debian based operating systems you can install it with
|
||||||
|
|
||||||
```
|
```$ sudo apt install libsdl2-dev```
|
||||||
$ sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Arch
|
For Arch based operating systems you can install it with
|
||||||
|
|
||||||
```
|
```$ sudo pacman -S sdl2```
|
||||||
$ sudo pacman -S sdl2 sdl2_image sdl2_ttf
|
|
||||||
```
|
* You also need the package ***libsdl2-image-dev***.
|
||||||
|
|
||||||
|
For Debian based operating systems you can install it with
|
||||||
|
|
||||||
|
```$ sudo apt install libsdl2-image-dev```
|
||||||
|
|
||||||
|
For Arch based operating systems you can install it with
|
||||||
|
|
||||||
|
```$ sudo pacman -S sdl2_image```
|
||||||
|
|
||||||
|
* You also need the package ***libsdl2-ttf-dev***.
|
||||||
|
|
||||||
|
For Debian based operating systems you can install it with
|
||||||
|
|
||||||
|
```$ sudo apt install libsdl2-ttf-dev```
|
||||||
|
|
||||||
|
For Arch based operating systems you can install it with
|
||||||
|
|
||||||
|
```$ sudo pacman -S sdl2_ttf```
|
||||||
|
|
||||||
2. Navigate to [the most recent release](https://github.com/sam-astro/Z-Sharp/releases) and download `ZSharp-Linux.zip`.
|
2. Navigate to [the most recent release](https://github.com/sam-astro/Z-Sharp/releases) and download `ZSharp-Linux.zip`.
|
||||||
3. Unzip `ZSharp-Linux.zip` and open the unzipped folder.
|
3. Unzip `ZSharp-Linux.zip` and open the unzipped folder.
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
//bool DEVELOPER_MESSAGES = true;
|
//bool DEVELOPER_MESSAGES = true;
|
||||||
#define DEVELOPER_MESSAGES false
|
#define DEVELOPER_MESSAGES false
|
||||||
#define EXAMPLE_PROJECT false
|
#define EXAMPLE_PROJECT false
|
||||||
#define NAMEVERSION "ZSharp v2.1.3-alpha"
|
#define NAMEVERSION "ZSharp v2.1.1-alpha"
|
||||||
|
|
||||||
#if defined(__unix__)
|
#if defined(__unix__)
|
||||||
#define UNIX true
|
#define UNIX true
|
||||||
@ -78,7 +78,7 @@ boost::any GetVariableValue(const string& varName, const unordered_map<string, b
|
|||||||
// Check if there is a variable with the specified name
|
// Check if there is a variable with the specified name
|
||||||
bool IsVar(const string& varName, const unordered_map<string, boost::any>& variableValues)
|
bool IsVar(const string& varName, const unordered_map<string, boost::any>& variableValues)
|
||||||
{
|
{
|
||||||
if (split(varName, '.')[0] == "ZS")
|
if(split(varName, '.')[0] == "ZS")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (variableValues.find(split(varName, '.')[0]) != variableValues.end())
|
if (variableValues.find(split(varName, '.')[0]) != variableValues.end())
|
||||||
@ -163,7 +163,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
string insideFunArgs = betweenChars(expression, '(', ')');
|
string insideFunArgs = betweenChars(expression, '(', ')');
|
||||||
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
||||||
#if DEVELOPER_MESSAGES == true
|
#if DEVELOPER_MESSAGES == true
|
||||||
cout << split(expression, '(')[0] << " [" << unWrapVec(argList) << "]" << endl;
|
cout << "[" << unWrapVec(argList) << "]" << endl;
|
||||||
printVarValues(argList, variableValues);
|
printVarValues(argList, variableValues);
|
||||||
#endif
|
#endif
|
||||||
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
||||||
@ -176,7 +176,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
|
|||||||
string insideFunArgs = betweenChars(expression, '(', ')');
|
string insideFunArgs = betweenChars(expression, '(', ')');
|
||||||
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
||||||
#if DEVELOPER_MESSAGES == true
|
#if DEVELOPER_MESSAGES == true
|
||||||
cout << split(expression, '(')[0] << " [" << unWrapVec(argList) << "]" << endl;
|
cout << split(expression, '(')[0]<< " [" << unWrapVec(argList) << "]" << endl;
|
||||||
printVarValues(argList, variableValues);
|
printVarValues(argList, variableValues);
|
||||||
#endif
|
#endif
|
||||||
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
||||||
@ -288,9 +288,9 @@ bool BooleanLogic(const string& valA, const string& comparer, const string& valB
|
|||||||
{
|
{
|
||||||
boost::any valARealValue;
|
boost::any valARealValue;
|
||||||
boost::any valBRealValue;
|
boost::any valBRealValue;
|
||||||
if (valA != "")
|
if(valA != "")
|
||||||
valARealValue = EvalExpression(valA, variableValues);
|
valARealValue = EvalExpression(valA, variableValues);
|
||||||
if (valB != "")
|
if(valB != "")
|
||||||
valBRealValue = EvalExpression(valB, variableValues);
|
valBRealValue = EvalExpression(valB, variableValues);
|
||||||
#if DEVELOPER_MESSAGES == true
|
#if DEVELOPER_MESSAGES == true
|
||||||
InterpreterLog(AnyAsString(valARealValue) + " " + comparer + " " + AnyAsString(valBRealValue) + " : " + AnyAsString(valA) + " " + comparer + " " + AnyAsString(valB) + " : " + to_string(AnyAsString(valARealValue) == AnyAsString(valBRealValue)));
|
InterpreterLog(AnyAsString(valARealValue) + " " + comparer + " " + AnyAsString(valBRealValue) + " : " + AnyAsString(valA) + " " + comparer + " " + AnyAsString(valB) + " : " + to_string(AnyAsString(valARealValue) == AnyAsString(valBRealValue)));
|
||||||
@ -419,16 +419,22 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
|||||||
// Check if it is function call
|
// Check if it is function call
|
||||||
else if (IsFunction(split(words.at(lineNum).at(0), '(')[0]))
|
else if (IsFunction(split(words.at(lineNum).at(0), '(')[0]))
|
||||||
{
|
{
|
||||||
// start -> FuncCall(0, x, OtherFunc(a))
|
// No args provided
|
||||||
// changeto -> 0, x, OtherFunc(a)
|
if (indexInStr(words.at(lineNum).at(0), ')') - indexInStr(words.at(lineNum).at(0), '(')<=1)
|
||||||
string insideFunArgs = betweenChars(unWrapVec(words.at(lineNum)), '(', ')');
|
ExecuteFunction(split(words.at(lineNum).at(0), '(')[0], vector<boost::any>());
|
||||||
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
else
|
||||||
|
{ // Args provided, parse them first
|
||||||
|
// start -> FuncCall(0, x, OtherFunc(a))
|
||||||
|
// changeto -> 0, x, OtherFunc(a)
|
||||||
|
string insideFunArgs = betweenChars(unWrapVec(words.at(lineNum)), '(', ')');
|
||||||
|
vector<string> argList = splitNoOverlap(insideFunArgs, ',', '(', ')');
|
||||||
#if DEVELOPER_MESSAGES == true
|
#if DEVELOPER_MESSAGES == true
|
||||||
cout << unWrapVec(argList) << endl;
|
cout << unWrapVec(argList) << endl;
|
||||||
printVarValues(argList, variableValues);
|
printVarValues(argList, variableValues);
|
||||||
#endif
|
#endif
|
||||||
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
vector<boost::any> funcArgs = VarValues(argList, variableValues);
|
||||||
ExecuteFunction(split(words.at(lineNum).at(0), '(')[0], funcArgs);
|
ExecuteFunction(split(words.at(lineNum).at(0), '(')[0], funcArgs);
|
||||||
|
}
|
||||||
return nullType;
|
return nullType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -516,7 +522,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the statement is already false, don't bother gathering the contents
|
// If the statement is already false, don't bother gathering the contents
|
||||||
if (BooleanLogic(whileParameters.at(0), whileParameters.at(1), whileParameters.at(2), variableValues) == false) {
|
if(BooleanLogic(whileParameters.at(0), whileParameters.at(1), whileParameters.at(2), variableValues) == false){
|
||||||
lineNum++;
|
lineNum++;
|
||||||
while (lineNum < (int)words.size())
|
while (lineNum < (int)words.size())
|
||||||
{
|
{
|
||||||
@ -547,9 +553,9 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
|||||||
//Iterate through all lines in while loop
|
//Iterate through all lines in while loop
|
||||||
for (int lineNum = 0; lineNum < (int)whileContents.size(); lineNum++)
|
for (int lineNum = 0; lineNum < (int)whileContents.size(); lineNum++)
|
||||||
{
|
{
|
||||||
if (whileContents.at(lineNum).at(0) == "continue")
|
if(whileContents.at(lineNum).at(0)== "continue")
|
||||||
break; // Stops iterating through lines and return to beginning
|
break; // Stops iterating through lines and return to beginning
|
||||||
if (whileContents.at(lineNum).at(0) == "break")
|
if(whileContents.at(lineNum).at(0)== "break")
|
||||||
return nullType; // Stops iterating through lines and leave while loop
|
return nullType; // Stops iterating through lines and leave while loop
|
||||||
boost::any returnVal = ProcessLine(whileContents, lineNum, variableValues);
|
boost::any returnVal = ProcessLine(whileContents, lineNum, variableValues);
|
||||||
if (!returnVal.empty()) {
|
if (!returnVal.empty()) {
|
||||||
@ -588,7 +594,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the statement is already false, don't bother gathering the contents
|
// If the statement is already false, don't bother gathering the contents
|
||||||
if (BooleanLogic(ifParameters.at(0), ifParameters.at(1), ifParameters.at(2), variableValues) == false) {
|
if(BooleanLogic(ifParameters.at(0), ifParameters.at(1), ifParameters.at(2), variableValues) == false){
|
||||||
lineNum++;
|
lineNum++;
|
||||||
while (lineNum < (int)words.size())
|
while (lineNum < (int)words.size())
|
||||||
{
|
{
|
||||||
@ -618,7 +624,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int& lineNum, unorde
|
|||||||
//Iterate through all lines in if statement
|
//Iterate through all lines in if statement
|
||||||
for (int l = 0; l < (int)ifContents.size(); l++)
|
for (int l = 0; l < (int)ifContents.size(); l++)
|
||||||
{
|
{
|
||||||
if (ifContents.at(l).at(0) == "break")
|
if(ifContents.at(l).at(0)== "break")
|
||||||
return breakReOp; // Stops iterating through lines and leave while loop
|
return breakReOp; // Stops iterating through lines and leave while loop
|
||||||
boost::any returnVal = ProcessLine(ifContents, l, variableValues);
|
boost::any returnVal = ProcessLine(ifContents, l, variableValues);
|
||||||
if (!returnVal.empty())
|
if (!returnVal.empty())
|
||||||
@ -712,8 +718,8 @@ int parseZSharp(string script)
|
|||||||
// Split the script by newline, signifying a line ending
|
// Split the script by newline, signifying a line ending
|
||||||
vector<string> beforeProcessLines = split(script, '\n');
|
vector<string> beforeProcessLines = split(script, '\n');
|
||||||
vector<string> lines;
|
vector<string> lines;
|
||||||
for (int i = 0; i < (int)beforeProcessLines.size(); i++) { // Then split said lines into indiviual words
|
for (int i = 0; i < (int)beforeProcessLines.size(); i++){ // Then split said lines into indiviual words
|
||||||
if (!startsWith(trim(beforeProcessLines.at(i)), "//") && trim(beforeProcessLines.at(i)) != "")
|
if(!startsWith(trim(beforeProcessLines.at(i)), "//") && trim(beforeProcessLines.at(i)) != "")
|
||||||
{ // dont include line if it is a comment or if it is blank
|
{ // dont include line if it is a comment or if it is blank
|
||||||
lines.push_back(trim(beforeProcessLines.at(i)));
|
lines.push_back(trim(beforeProcessLines.at(i)));
|
||||||
}
|
}
|
||||||
@ -838,24 +844,24 @@ int parseZSharp(string script)
|
|||||||
//cout << words.at(lineNum).at(1) << "=" << unWrapVec(slice(words.at(lineNum), 3, -1)) << "=" << AnyAsString(EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), variableValues)) << endl;
|
//cout << words.at(lineNum).at(1) << "=" << unWrapVec(slice(words.at(lineNum), 3, -1)) << "=" << AnyAsString(EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), variableValues)) << endl;
|
||||||
globalVariableValues[words.at(lineNum).at(1)] = EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), globalVariableValues);
|
globalVariableValues[words.at(lineNum).at(1)] = EvalExpression(unWrapVec(slice(words.at(lineNum), 3, -1)), globalVariableValues);
|
||||||
}
|
}
|
||||||
// else if (words.at(lineNum).at(0) == "int") {
|
// else if (words.at(lineNum).at(0) == "int") {
|
||||||
// globalVariableValues[words.at(lineNum).at(1)] = stoi(words.at(lineNum).at(3));
|
// globalVariableValues[words.at(lineNum).at(1)] = stoi(words.at(lineNum).at(3));
|
||||||
//#if DEVELOPER_MESSAGES == true
|
//#if DEVELOPER_MESSAGES == true
|
||||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||||
//#endif
|
//#endif
|
||||||
// }
|
// }
|
||||||
// else if (words.at(lineNum).at(0) == "float") {
|
// else if (words.at(lineNum).at(0) == "float") {
|
||||||
// globalVariableValues[words.at(lineNum).at(1)] = stof(words.at(lineNum).at(3));
|
// globalVariableValues[words.at(lineNum).at(1)] = stof(words.at(lineNum).at(3));
|
||||||
//#if DEVELOPER_MESSAGES == true
|
//#if DEVELOPER_MESSAGES == true
|
||||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||||
//#endif
|
//#endif
|
||||||
// }
|
// }
|
||||||
// else if (words.at(lineNum).at(0) == "bool") {
|
// else if (words.at(lineNum).at(0) == "bool") {
|
||||||
// globalVariableValues[words.at(lineNum).at(1)] = stob(words.at(lineNum).at(3));
|
// globalVariableValues[words.at(lineNum).at(1)] = stob(words.at(lineNum).at(3));
|
||||||
//#if DEVELOPER_MESSAGES == true
|
//#if DEVELOPER_MESSAGES == true
|
||||||
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
// InterpreterLog("Load script variable " + words.at(lineNum).at(1) + "...");
|
||||||
//#endif
|
//#endif
|
||||||
// }
|
// }
|
||||||
else
|
else
|
||||||
LogWarning("unrecognized type \'" + words.at(lineNum).at(0) + "\' on line: " + to_string(lineNum));
|
LogWarning("unrecognized type \'" + words.at(lineNum).at(0) + "\' on line: " + to_string(lineNum));
|
||||||
}
|
}
|
||||||
|
|||||||
22
ZSharp/ZS.h
22
ZSharp/ZS.h
@ -145,6 +145,14 @@ func GetKey(keyName)
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WIP
|
||||||
|
//func SplitThread(function)
|
||||||
|
//{
|
||||||
|
// ZS.System.SplitThread(function)
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
// ↓ MADE BY KAPUTCHINO ↓ //
|
// ↓ MADE BY KAPUTCHINO ↓ //
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
@ -205,19 +213,5 @@ func Perm(n, r)
|
|||||||
return Fac(n) / Fac(n - r)
|
return Fac(n) / Fac(n - r)
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
|
||||||
// ↓ MADE BY CONCHETUMARE_PRODUCTIONS ↓ //
|
|
||||||
//////////////////////////////////////////
|
|
||||||
func GetPercent(value, percent)
|
|
||||||
{
|
|
||||||
float temp = value * percent / 100
|
|
||||||
return temp
|
|
||||||
}
|
|
||||||
//gets 100% of number
|
|
||||||
func PercentToHundred(value, percent)
|
|
||||||
{
|
|
||||||
float temp = value * 100 / percent
|
|
||||||
return temp
|
|
||||||
}
|
|
||||||
)"
|
)"
|
||||||
;
|
;
|
||||||
|
|||||||
@ -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.1.3-alpha"
|
#define MyAppVersion "2.1.1-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"
|
||||||
@ -25,7 +25,6 @@ DefaultDirName={autopf}\ZSharp
|
|||||||
DisableDirPage=yes
|
DisableDirPage=yes
|
||||||
ChangesAssociations=yes
|
ChangesAssociations=yes
|
||||||
DisableProgramGroupPage=yes
|
DisableProgramGroupPage=yes
|
||||||
ChangesEnvironment=true
|
|
||||||
LicenseFile=D:\Code\Z-Sharp\LICENSE
|
LicenseFile=D:\Code\Z-Sharp\LICENSE
|
||||||
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
; Uncomment the following line to run in non administrative install mode (install for current user only.)
|
||||||
;PrivilegesRequired=lowest
|
;PrivilegesRequired=lowest
|
||||||
@ -37,21 +36,6 @@ Compression=lzma
|
|||||||
SolidCompression=yes
|
SolidCompression=yes
|
||||||
WizardStyle=modern
|
WizardStyle=modern
|
||||||
|
|
||||||
[Tasks]
|
|
||||||
Name: modifypath; Description: Add application directory to your environmental path (This allows you to easily use from command line); Flags: unchecked
|
|
||||||
|
|
||||||
[Code]
|
|
||||||
const
|
|
||||||
ModPathName = 'modifypath';
|
|
||||||
ModPathType = 'system';
|
|
||||||
|
|
||||||
function ModPathDir(): TArrayOfString;
|
|
||||||
begin
|
|
||||||
setArrayLength(Result, 1)
|
|
||||||
Result[0] := ExpandConstant('{app}');
|
|
||||||
end;
|
|
||||||
#include "modpath.iss"
|
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
|
Name: "armenian"; MessagesFile: "compiler:Languages\Armenian.isl"
|
||||||
|
|||||||
@ -1,14 +1,6 @@
|
|||||||
#ifndef BUILTIN_H
|
#ifndef BUILTIN_H
|
||||||
#define BUILTIN_H
|
#define BUILTIN_H
|
||||||
|
|
||||||
#if defined(__unix__)
|
|
||||||
#define UNIX true
|
|
||||||
#define WINDOWS false
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#define UNIX false
|
|
||||||
#define WINDOWS true
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -21,7 +13,6 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <cstdlib> // for console command printing
|
|
||||||
|
|
||||||
#include "strops.h"
|
#include "strops.h"
|
||||||
#include "graphics.h"
|
#include "graphics.h"
|
||||||
@ -418,42 +409,29 @@ boost::any ZSFunction(const string& name, const vector<boost::any>& args)
|
|||||||
}
|
}
|
||||||
else if (name == "ZS.Graphics.Sprite")
|
else if (name == "ZS.Graphics.Sprite")
|
||||||
{
|
{
|
||||||
string path = StringRaw(AnyAsString(args.at(0)));
|
if (!fileExists(StringRaw(AnyAsString(args.at(0)))))
|
||||||
if (count(path, '/') == 0)
|
LogCriticalError("Failed to create 'Sprite' object: \"" + StringRaw(AnyAsString(args.at(0))) + "\"");
|
||||||
path = "./" + path;
|
|
||||||
if (!fileExists(path))
|
|
||||||
LogCriticalError("Failed to create 'Sprite' object: \"" + path + "\"");
|
|
||||||
|
|
||||||
Sprite s(StringRaw(AnyAsString(args.at(0))), any_cast<Vec2>(args.at(1)), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)));
|
Sprite s(StringRaw(AnyAsString(args.at(0))), any_cast<Vec2>(args.at(1)), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)));
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
else if (name == "ZS.Graphics.DrawPixel")
|
|
||||||
{
|
|
||||||
SDL_SetRenderDrawColor(gRenderer, AnyAsInt(args.at(2)), AnyAsInt(args.at(3)), AnyAsInt(args.at(4)), 255);
|
|
||||||
SDL_RenderDrawPoint(gRenderer, AnyAsInt(args.at(0)), AnyAsInt(args.at(1)));
|
|
||||||
SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
//DrawPixel(AnyAsInt(args.at(0)), AnyAsInt(args.at(1)), AnyAsInt(args.at(2)), AnyAsInt(args.at(3)), AnyAsInt(args.at(4)));
|
|
||||||
else if (name == "ZS.Graphics.Draw")
|
else if (name == "ZS.Graphics.Draw")
|
||||||
any_cast<Sprite>(args.at(0)).Draw();
|
any_cast<Sprite>(args.at(0)).Draw();
|
||||||
else if (name == "ZS.Graphics.Load")
|
else if (name == "ZS.Graphics.Load")
|
||||||
any_cast<Sprite>(args.at(0)).Load();
|
any_cast<Sprite>(args.at(0)).Load();
|
||||||
else if (name == "ZS.Graphics.Text")
|
else if (name == "ZS.Graphics.Text")
|
||||||
{
|
{
|
||||||
string path = StringRaw(AnyAsString(args.at(1)));
|
if (!fileExists(StringRaw(AnyAsString(args.at(1)))))
|
||||||
if (count(path, '/') == 0)
|
LogCriticalError("Failed to create 'Text' object: \"" + StringRaw(AnyAsString(args.at(1))) + "\"");
|
||||||
path = "./" + path;
|
|
||||||
if (!fileExists(path))
|
|
||||||
LogCriticalError("Failed to create 'Text' object: \"" + path + "\"");
|
|
||||||
|
|
||||||
if (args.size() <= 8)
|
if (args.size() <= 8)
|
||||||
{
|
{
|
||||||
Text t(StringRaw(AnyAsString(args.at(0))), path, any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7)), true);
|
Text t(StringRaw(AnyAsString(args.at(0))), StringRaw(AnyAsString(args.at(1))), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7)), true);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Text t(StringRaw(AnyAsString(args.at(0))), path, any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7)), AnyAsBool(args.at(8)));
|
Text t(StringRaw(AnyAsString(args.at(0))), StringRaw(AnyAsString(args.at(1))), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7)), AnyAsBool(args.at(8)));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,21 +446,14 @@ boost::any ZSFunction(const string& name, const vector<boost::any>& args)
|
|||||||
else if (name == "ZS.Input.GetKey")
|
else if (name == "ZS.Input.GetKey")
|
||||||
return KEYS[StringRaw(any_cast<string>(args.at(0)))] == 1;
|
return KEYS[StringRaw(any_cast<string>(args.at(0)))] == 1;
|
||||||
else if (name == "ZS.System.Print")
|
else if (name == "ZS.System.Print")
|
||||||
cout << StringRaw(AnyAsString(args.at(0)));
|
cout << StringRaw(AnyAsString(args.at(0))) << StringRaw(AnyAsString(args.at(0))).length();
|
||||||
else if (name == "ZS.System.PrintLine")
|
else if (name == "ZS.System.PrintLine")
|
||||||
cout << StringRaw(AnyAsString(args.at(0))) << endl;
|
cout << StringRaw(AnyAsString(args.at(0))) << StringRaw(AnyAsString(args.at(0))).length() << endl;
|
||||||
else if (name == "ZS.System.Vec2")
|
else if (name == "ZS.System.Vec2")
|
||||||
{
|
{
|
||||||
Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)));
|
Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)));
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
else if (name == "ZS.System.Command"){
|
|
||||||
string command = StringRaw(AnyAsString(args.at(0)));
|
|
||||||
//int command_len = command.length();
|
|
||||||
//char* command_char_arr=new char[command_len + 1];
|
|
||||||
//strcpy(command_char_arr, command.c_str()); // string into char arr
|
|
||||||
int k = system(command.c_str());
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
LogWarning("ZS function \'" + name + "\' does not exist.");
|
LogWarning("ZS function \'" + name + "\' does not exist.");
|
||||||
|
|
||||||
|
|||||||
@ -761,12 +761,6 @@ int cleanupGraphics()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void DrawPixel(int x, int y, int r, int g, int b) {
|
|
||||||
// SDL_SetRenderDrawColor(gRenderer, r, g, b, 255);
|
|
||||||
// SDL_RenderDrawPoint(gRenderer, x, y);
|
|
||||||
// SDL_SetRenderDrawColor(gRenderer, 0, 0, 0, 0);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
int updateLoop()
|
int updateLoop()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,219 +0,0 @@
|
|||||||
// ----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Inno Setup Ver: 5.4.2
|
|
||||||
// Script Version: 1.4.2
|
|
||||||
// Author: Jared Breland <jbreland@legroom.net>
|
|
||||||
// Homepage: http://www.legroom.net/software
|
|
||||||
// License: GNU Lesser General Public License (LGPL), version 3
|
|
||||||
// http://www.gnu.org/licenses/lgpl.html
|
|
||||||
//
|
|
||||||
// Script Function:
|
|
||||||
// Allow modification of environmental path directly from Inno Setup installers
|
|
||||||
//
|
|
||||||
// Instructions:
|
|
||||||
// Copy modpath.iss to the same directory as your setup script
|
|
||||||
//
|
|
||||||
// Add this statement to your [Setup] section
|
|
||||||
// ChangesEnvironment=true
|
|
||||||
//
|
|
||||||
// Add this statement to your [Tasks] section
|
|
||||||
// You can change the Description or Flags
|
|
||||||
// You can change the Name, but it must match the ModPathName setting below
|
|
||||||
// Name: modifypath; Description: &Add application directory to your environmental path; Flags: unchecked
|
|
||||||
//
|
|
||||||
// Add the following to the end of your [Code] section
|
|
||||||
// ModPathName defines the name of the task defined above
|
|
||||||
// ModPathType defines whether the 'user' or 'system' path will be modified;
|
|
||||||
// this will default to user if anything other than system is set
|
|
||||||
// setArrayLength must specify the total number of dirs to be added
|
|
||||||
// Result[0] contains first directory, Result[1] contains second, etc.
|
|
||||||
// const
|
|
||||||
// ModPathName = 'modifypath';
|
|
||||||
// ModPathType = 'user';
|
|
||||||
//
|
|
||||||
// function ModPathDir(): TArrayOfString;
|
|
||||||
// begin
|
|
||||||
// setArrayLength(Result, 1);
|
|
||||||
// Result[0] := ExpandConstant('{app}');
|
|
||||||
// end;
|
|
||||||
// #include "modpath.iss"
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
procedure ModPath();
|
|
||||||
var
|
|
||||||
oldpath: String;
|
|
||||||
newpath: String;
|
|
||||||
updatepath: Boolean;
|
|
||||||
pathArr: TArrayOfString;
|
|
||||||
aExecFile: String;
|
|
||||||
aExecArr: TArrayOfString;
|
|
||||||
i, d: Integer;
|
|
||||||
pathdir: TArrayOfString;
|
|
||||||
regroot: Integer;
|
|
||||||
regpath: String;
|
|
||||||
|
|
||||||
begin
|
|
||||||
// Get constants from main script and adjust behavior accordingly
|
|
||||||
// ModPathType MUST be 'system' or 'user'; force 'user' if invalid
|
|
||||||
if ModPathType = 'system' then begin
|
|
||||||
regroot := HKEY_LOCAL_MACHINE;
|
|
||||||
regpath := 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment';
|
|
||||||
end else begin
|
|
||||||
regroot := HKEY_CURRENT_USER;
|
|
||||||
regpath := 'Environment';
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Get array of new directories and act on each individually
|
|
||||||
pathdir := ModPathDir();
|
|
||||||
for d := 0 to GetArrayLength(pathdir)-1 do begin
|
|
||||||
updatepath := true;
|
|
||||||
|
|
||||||
// Modify WinNT path
|
|
||||||
if UsingWinNT() = true then begin
|
|
||||||
|
|
||||||
// Get current path, split into an array
|
|
||||||
RegQueryStringValue(regroot, regpath, 'Path', oldpath);
|
|
||||||
oldpath := oldpath + ';';
|
|
||||||
i := 0;
|
|
||||||
|
|
||||||
while (Pos(';', oldpath) > 0) do begin
|
|
||||||
SetArrayLength(pathArr, i+1);
|
|
||||||
pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1);
|
|
||||||
oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath));
|
|
||||||
i := i + 1;
|
|
||||||
|
|
||||||
// Check if current directory matches app dir
|
|
||||||
if pathdir[d] = pathArr[i-1] then begin
|
|
||||||
// if uninstalling, remove dir from path
|
|
||||||
if IsUninstaller() = true then begin
|
|
||||||
continue;
|
|
||||||
// if installing, flag that dir already exists in path
|
|
||||||
end else begin
|
|
||||||
updatepath := false;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Add current directory to new path
|
|
||||||
if i = 1 then begin
|
|
||||||
newpath := pathArr[i-1];
|
|
||||||
end else begin
|
|
||||||
newpath := newpath + ';' + pathArr[i-1];
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Append app dir to path if not already included
|
|
||||||
if (IsUninstaller() = false) AND (updatepath = true) then
|
|
||||||
newpath := newpath + ';' + pathdir[d];
|
|
||||||
|
|
||||||
// Write new path
|
|
||||||
RegWriteStringValue(regroot, regpath, 'Path', newpath);
|
|
||||||
|
|
||||||
// Modify Win9x path
|
|
||||||
end else begin
|
|
||||||
|
|
||||||
// Convert to shortened dirname
|
|
||||||
pathdir[d] := GetShortName(pathdir[d]);
|
|
||||||
|
|
||||||
// If autoexec.bat exists, check if app dir already exists in path
|
|
||||||
aExecFile := 'C:\AUTOEXEC.BAT';
|
|
||||||
if FileExists(aExecFile) then begin
|
|
||||||
LoadStringsFromFile(aExecFile, aExecArr);
|
|
||||||
for i := 0 to GetArrayLength(aExecArr)-1 do begin
|
|
||||||
if IsUninstaller() = false then begin
|
|
||||||
// If app dir already exists while installing, skip add
|
|
||||||
if (Pos(pathdir[d], aExecArr[i]) > 0) then
|
|
||||||
updatepath := false;
|
|
||||||
break;
|
|
||||||
end else begin
|
|
||||||
// If app dir exists and = what we originally set, then delete at uninstall
|
|
||||||
if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir[d] then
|
|
||||||
aExecArr[i] := '';
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path
|
|
||||||
if (IsUninstaller() = false) AND (updatepath = true) then begin
|
|
||||||
SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir[d], True);
|
|
||||||
|
|
||||||
// If uninstalling, write the full autoexec out
|
|
||||||
end else begin
|
|
||||||
SaveStringsToFile(aExecFile, aExecArr, False);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
// Split a string into an array using passed delimeter
|
|
||||||
procedure MPExplode(var Dest: TArrayOfString; Text: String; Separator: String);
|
|
||||||
var
|
|
||||||
i: Integer;
|
|
||||||
begin
|
|
||||||
i := 0;
|
|
||||||
repeat
|
|
||||||
SetArrayLength(Dest, i+1);
|
|
||||||
if Pos(Separator,Text) > 0 then begin
|
|
||||||
Dest[i] := Copy(Text, 1, Pos(Separator, Text)-1);
|
|
||||||
Text := Copy(Text, Pos(Separator,Text) + Length(Separator), Length(Text));
|
|
||||||
i := i + 1;
|
|
||||||
end else begin
|
|
||||||
Dest[i] := Text;
|
|
||||||
Text := '';
|
|
||||||
end;
|
|
||||||
until Length(Text)=0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure CurStepChanged(CurStep: TSetupStep);
|
|
||||||
var
|
|
||||||
taskname: String;
|
|
||||||
begin
|
|
||||||
taskname := ModPathName;
|
|
||||||
if CurStep = ssPostInstall then
|
|
||||||
if IsTaskSelected(taskname) then
|
|
||||||
ModPath();
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
|
|
||||||
var
|
|
||||||
aSelectedTasks: TArrayOfString;
|
|
||||||
i: Integer;
|
|
||||||
taskname: String;
|
|
||||||
regpath: String;
|
|
||||||
regstring: String;
|
|
||||||
appid: String;
|
|
||||||
begin
|
|
||||||
// only run during actual uninstall
|
|
||||||
if CurUninstallStep = usUninstall then begin
|
|
||||||
// get list of selected tasks saved in registry at install time
|
|
||||||
appid := '{#emit SetupSetting("AppId")}';
|
|
||||||
if appid = '' then appid := '{#emit SetupSetting("AppName")}';
|
|
||||||
regpath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\'+appid+'_is1');
|
|
||||||
RegQueryStringValue(HKLM, regpath, 'Inno Setup: Selected Tasks', regstring);
|
|
||||||
if regstring = '' then RegQueryStringValue(HKCU, regpath, 'Inno Setup: Selected Tasks', regstring);
|
|
||||||
|
|
||||||
// check each task; if matches modpath taskname, trigger patch removal
|
|
||||||
if regstring <> '' then begin
|
|
||||||
taskname := ModPathName;
|
|
||||||
MPExplode(aSelectedTasks, regstring, ',');
|
|
||||||
if GetArrayLength(aSelectedTasks) > 0 then begin
|
|
||||||
for i := 0 to GetArrayLength(aSelectedTasks)-1 do begin
|
|
||||||
if comparetext(aSelectedTasks[i], taskname) = 0 then
|
|
||||||
ModPath();
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function NeedRestart(): Boolean;
|
|
||||||
var
|
|
||||||
taskname: String;
|
|
||||||
begin
|
|
||||||
taskname := ModPathName;
|
|
||||||
if IsTaskSelected(taskname) and not UsingWinNT() then begin
|
|
||||||
Result := True;
|
|
||||||
end else begin
|
|
||||||
Result := False;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 297 B |
@ -1,157 +0,0 @@
|
|||||||
int g_screenw = 256
|
|
||||||
int g_screenh = 224
|
|
||||||
int g_resolutionScale = 3
|
|
||||||
|
|
||||||
float g_playerWalkSpeed = 150
|
|
||||||
float g_playerRunSpeed = 210
|
|
||||||
float g_jumpHeight = 200
|
|
||||||
float g_currPlayerSpeed = 400
|
|
||||||
|
|
||||||
bool g_running = false
|
|
||||||
bool g_colliding = false
|
|
||||||
|
|
||||||
float g_gravitySpeed = 86
|
|
||||||
|
|
||||||
bool g_jumping = false
|
|
||||||
float g_jumpingTime = 0
|
|
||||||
|
|
||||||
//include "./extra-include.zs"
|
|
||||||
|
|
||||||
func Main()
|
|
||||||
{
|
|
||||||
//SplitThread(ThreadedFunction())
|
|
||||||
EXIT_WHEN_DONE = false
|
|
||||||
|
|
||||||
// Immediately creates the window, then runs Start(), then the game loop. The game loop calls Update() every frame
|
|
||||||
ZS.Graphics.Init("Platformer game", g_screenw, g_screenh, g_resolutionScale)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Start()
|
|
||||||
{
|
|
||||||
float centerX = g_screenw / 2
|
|
||||||
float centerY = g_screenh / 2
|
|
||||||
|
|
||||||
|
|
||||||
global Vec2 v_aa = NVec2(g_screenw / 2 + -40, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_aa = ZS.Graphics.Sprite("./mariostill.png", v_aa, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ab = NVec2(g_screenw / 2 + -30, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ab = ZS.Graphics.Sprite("./mariostill.png", v_ab, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ac = NVec2(g_screenw / 2 + -20, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ac = ZS.Graphics.Sprite("./mariostill.png", v_ac, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ad = NVec2(g_screenw / 2 + -10, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ad = ZS.Graphics.Sprite("./mariostill.png", v_ad, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ae = NVec2(g_screenw / 2 + -0, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ae = ZS.Graphics.Sprite("./mariostill.png", v_ae, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_af = NVec2(g_screenw / 2 + 10, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_af = ZS.Graphics.Sprite("./mariostill.png", v_af, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ag = NVec2(g_screenw / 2 + 20, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ag = ZS.Graphics.Sprite("./mariostill.png", v_ag, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ah = NVec2(g_screenw / 2 + 30, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ah = ZS.Graphics.Sprite("./mariostill.png", v_ah, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ai = NVec2(g_screenw / 2 + 40, g_screenh / 2 + -40)
|
|
||||||
global Sprite s_ai = ZS.Graphics.Sprite("./mariostill.png", v_ai, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_aj = NVec2(g_screenw / 2 + -40, g_screenh / 2 + -30)
|
|
||||||
global Sprite s_aj = ZS.Graphics.Sprite("./mariostill.png", v_aj, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_ak = NVec2(g_screenw / 2 + -30, g_screenh / 2 + -30)
|
|
||||||
global Sprite s_ak = ZS.Graphics.Sprite("./mariostill.png", v_ak, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
global Vec2 v_al = NVec2(g_screenw / 2 + -20, g_screenh / 2 + -30)
|
|
||||||
global Sprite s_al = ZS.Graphics.Sprite("./mariostill.png", v_al, NVec2(16, 16), 0)
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func Update(deltaTime)
|
|
||||||
{
|
|
||||||
float fps = 1 / deltaTime
|
|
||||||
Printl("FPS: " + fps)
|
|
||||||
|
|
||||||
// // Shift key lets you sprint
|
|
||||||
// g_running = GetKey("SHIFT_L")
|
|
||||||
|
|
||||||
// if g_running == true
|
|
||||||
// {
|
|
||||||
// g_currPlayerSpeed = g_playerRunSpeed
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if g_running == false
|
|
||||||
// {
|
|
||||||
// g_currPlayerSpeed = g_playerWalkSpeed
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Move Left And Right
|
|
||||||
// if GetKey("D") == true
|
|
||||||
// {
|
|
||||||
// g_playerTargetPosition.x += g_currPlayerSpeed * deltaTime
|
|
||||||
// }
|
|
||||||
// if GetKey("A") == true
|
|
||||||
// {
|
|
||||||
// g_playerTargetPosition.x -= g_currPlayerSpeed * deltaTime
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// // Apply gravity
|
|
||||||
// g_colliding = Colliding(g_playerSprite, g_groundSprite)
|
|
||||||
// if g_colliding == false
|
|
||||||
// {
|
|
||||||
// if g_jumping == false
|
|
||||||
// {
|
|
||||||
// g_playerTargetPosition.y += deltaTime * g_gravitySpeed
|
|
||||||
// }
|
|
||||||
// if g_jumping == true
|
|
||||||
// {
|
|
||||||
// g_playerTargetPosition.y -= (g_jumpHeight * deltaTime) + (deltaTime * g_gravitySpeed * -g_jumpingTime * 5)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if g_colliding == true
|
|
||||||
// {
|
|
||||||
// if GetKey("SPACE") == false
|
|
||||||
// {
|
|
||||||
// if g_jumpingTime > 1
|
|
||||||
// {
|
|
||||||
// g_jumping = false
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if GetKey("SPACE") == true
|
|
||||||
// {
|
|
||||||
// g_jumping = true
|
|
||||||
// g_jumpingTime = 0
|
|
||||||
// g_playerTargetPosition.y -= 2
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Lerps from old position to destination smoothly
|
|
||||||
// float stopSpeed = deltaTime * 15
|
|
||||||
// float lerpedX = Lerp(g_playerSprite.position.x, g_playerTargetPosition.x, stopSpeed)
|
|
||||||
// s_aa.position = NVec2(lerpedX, g_playerTargetPosition.y)
|
|
||||||
|
|
||||||
// Finally draws all of the sprites
|
|
||||||
ZS.Graphics.Draw(s_aa)
|
|
||||||
ZS.Graphics.Draw(s_ab)
|
|
||||||
ZS.Graphics.Draw(s_ac)
|
|
||||||
ZS.Graphics.Draw(s_ad)
|
|
||||||
ZS.Graphics.Draw(s_ae)
|
|
||||||
ZS.Graphics.Draw(s_af)
|
|
||||||
ZS.Graphics.Draw(s_ag)
|
|
||||||
ZS.Graphics.Draw(s_ah)
|
|
||||||
ZS.Graphics.Draw(s_ai)
|
|
||||||
ZS.Graphics.Draw(s_aj)
|
|
||||||
ZS.Graphics.Draw(s_ak)
|
|
||||||
ZS.Graphics.Draw(s_al)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Colliding(a, b)
|
|
||||||
{
|
|
||||||
bool bo = ZS.Physics.AxisAlignedCollision(a, b)
|
|
||||||
return bo
|
|
||||||
}
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
func Main()
|
|
||||||
{
|
|
||||||
Printl("this is a test:")
|
|
||||||
ZS.System.Command("cls")
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user