-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47a2219
commit 962ad44
Showing
26 changed files
with
509 additions
and
442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[submodule "wrenbind17"] | ||
path = wrenbind17 | ||
url = https://github.com/matusnovak/wrenbind17 | ||
[submodule "Cube2D-Framework"] | ||
path = Cube2D-Framework | ||
url = https://github.com/mastercuber55/Cube2D-Framework | ||
[submodule "libtinyfiledialogs"] | ||
path = libtinyfiledialogs | ||
url = https://github.com/native-toolkit/libtinyfiledialogs |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <wrenbind17/wrenbind17.hpp> | ||
#include <raylib.h> | ||
#include "Rect.hpp" | ||
|
||
namespace Wren = wrenbind17; | ||
|
||
void BindEngine(Wren::VM & VM) { | ||
|
||
auto& Module = VM.module("Engine"); | ||
|
||
auto& RectCls = Module.klass<ForeignRect>("ForeignRect"); | ||
RectCls.ctor<float, float, float, float>(); | ||
|
||
// Transform | ||
RectCls.var<&ForeignRect::PositionAndScale>("PositionAndScale"); | ||
RectCls.var<&ForeignRect::Rotation>("Rotation"); | ||
|
||
RectCls.var<&ForeignRect::TextureFile>("TextureFile"); | ||
RectCls.var<&ForeignRect::Source>("Source"); | ||
RectCls.var<&ForeignRect::Tint>("Tint"); | ||
|
||
RectCls.func<&ForeignRect::SetPosition>("SetPosition"); | ||
RectCls.func<&ForeignRect::SetTextureFile>("SetTextureFile"); | ||
RectCls.func<&ForeignRect::Draw>("Draw"); | ||
|
||
RectCls.func<&ForeignRect::GetCenter>("GetCenter"); | ||
RectCls.func<&ForeignRect::GetPosition>("GetPosition"); | ||
|
||
RectCls.func<&ForeignRect::IsColliding>("IsColliding"); | ||
|
||
Module.append("import \"raylib\" for RL, COLOR, Color, KEY, Vector2"); | ||
|
||
Module.append( | ||
#include "Rect.wren" | ||
#include "Scene.wren" | ||
#include "SceneManager.wren" | ||
#include "Tools.wren" | ||
); | ||
Module.append("var Shared = {}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#define CGE_WHOLE_FILE { 0, 0, -1, -1 } | ||
std::unordered_map<std::string, Texture> Textures; | ||
|
||
struct ForeignRect { | ||
|
||
// Transformm | ||
Rectangle PositionAndScale; | ||
double Rotation; | ||
|
||
std::string TextureFile; | ||
Rectangle Source; | ||
Color Tint; | ||
|
||
// De-Constructers | ||
ForeignRect(float x, float y, float w, float h); | ||
~ForeignRect(); | ||
|
||
// Setters | ||
void SetTextureFile(std::string TextureFile); | ||
|
||
// Getters | ||
Vector2 GetCenter(); | ||
void SetPosition(Vector2 NewPosition); | ||
Vector2 GetPosition(); | ||
Vector2 GetRectangle(); | ||
|
||
// Utilities | ||
bool IsColliding(ForeignRect * Other); | ||
void Draw(); | ||
}; | ||
|
||
ForeignRect::ForeignRect(float x, float y, float w, float h) { | ||
this->PositionAndScale.x = x, this->PositionAndScale.y = y; | ||
this->PositionAndScale.width = w, this->PositionAndScale.height = h; | ||
this->Tint = WHITE; | ||
this->Source = CGE_WHOLE_FILE, | ||
this->Rotation = 0.0; | ||
} | ||
ForeignRect::~ForeignRect() {} | ||
void ForeignRect::SetTextureFile(std::string TextureFile) { | ||
|
||
this->TextureFile = TextureFile; | ||
if(Textures.find(TextureFile) != Textures.end()) return; | ||
Textures[TextureFile] = LoadTexture(TextureFile.c_str()); | ||
|
||
if( | ||
this->Source.x == 0 && | ||
this->Source.y == 0 && | ||
this->Source.width == -1 && | ||
this->Source.height == -1 | ||
) { | ||
this->Source.width = Textures[TextureFile].width, | ||
this->Source.height = Textures[TextureFile].height; | ||
} | ||
|
||
} | ||
void ForeignRect::Draw() { | ||
|
||
(this->TextureFile.empty()) ? | ||
DrawRectangleRec(this->PositionAndScale, this->Tint) | ||
: | ||
DrawTexturePro( | ||
Textures[this->TextureFile], | ||
this->Source, | ||
(Rectangle){ | ||
this->PositionAndScale.x + this->PositionAndScale.width / 2.0f, | ||
this->PositionAndScale.y + this->PositionAndScale.height / 2.0f, | ||
this->PositionAndScale.width, | ||
this->PositionAndScale.height | ||
}, | ||
(Vector2){ this->PositionAndScale.width / 2.0f, this->PositionAndScale.height / 2.0f }, | ||
this->Rotation, | ||
this->Tint | ||
); | ||
} | ||
bool ForeignRect::IsColliding(ForeignRect * Other) { | ||
return CheckCollisionRecs(PositionAndScale, Other->PositionAndScale); | ||
} | ||
void ForeignRect::SetPosition(Vector2 Position) { | ||
this->PositionAndScale.x = Position.x, this->PositionAndScale.y = Position.y; | ||
} | ||
Vector2 ForeignRect::GetCenter() { | ||
return { | ||
this->PositionAndScale.x + this->PositionAndScale.width / 2.0f, | ||
this->PositionAndScale.y + this->PositionAndScale.height / 2.0f | ||
}; | ||
} | ||
Vector2 ForeignRect::GetPosition() { | ||
return { this->PositionAndScale.x, this->PositionAndScale.y }; | ||
} |
Oops, something went wrong.