Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Lactozilla committed Dec 13, 2023
2 parents a2e2d75 + 27adf05 commit d53f603
Show file tree
Hide file tree
Showing 49 changed files with 4,268 additions and 1,468 deletions.
3 changes: 3 additions & 0 deletions VisualC/HatchGameEngine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ CD ..</Command>
<ClCompile Include="..\source\engine\Application.cpp" />
<ClCompile Include="..\source\engine\audio\AudioManager.cpp" />
<ClCompile Include="..\source\engine\audio\AudioPlayback.cpp" />
<ClCompile Include="..\source\engine\bytecode\TypeImpl\ArrayImpl.cpp" />
<ClCompile Include="..\source\engine\bytecode\TypeImpl\FunctionImpl.cpp" />
<ClCompile Include="..\source\engine\bytecode\TypeImpl\MapImpl.cpp" />
<ClCompile Include="..\source\engine\bytecode\BytecodeObject.cpp" />
<ClCompile Include="..\source\engine\bytecode\BytecodeObjectManager.cpp" />
<ClCompile Include="..\source\engine\bytecode\Compiler.cpp" />
Expand Down
9 changes: 9 additions & 0 deletions VisualC/HatchGameEngine.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
<ClCompile Include="..\source\engine\audio\AudioPlayback.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\source\engine\bytecode\TypeImpl\ArrayImpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\source\engine\bytecode\TypeImpl\FunctionImpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\source\engine\bytecode\TypeImpl\MapImpl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\source\engine\bytecode\BytecodeObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down
472 changes: 431 additions & 41 deletions guides/Documentation.htm

Large diffs are not rendered by default.

56 changes: 44 additions & 12 deletions source/Engine/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#if INTERFACE
#include <Engine/Includes/Standard.h>
#include <Engine/Includes/Version.h>
#include <Engine/InputManager.h>
#include <Engine/Audio/AudioManager.h>
#include <Engine/Scene.h>
Expand Down Expand Up @@ -27,10 +28,12 @@ class Application {
static int DefaultMonitor;
static Platforms Platform;

static char EngineVersion[256];

static char GameTitle[256];
static char GameTitleShort[256];
static char Version[256];
static char Description[256];
static char GameVersion[256];
static char GameDescription[256];

static int UpdatesPerFrame;
static bool Stepper;
Expand All @@ -50,6 +53,7 @@ class Application {
#include <Engine/Graphics.h>

#include <Engine/Bytecode/BytecodeObjectManager.h>
#include <Engine/Bytecode/BytecodeObject.h>
#include <Engine/Bytecode/GarbageCollector.h>
#include <Engine/Bytecode/SourceFileMap.h>
#include <Engine/Diagnostics/Clock.h>
Expand Down Expand Up @@ -112,10 +116,12 @@ int Application::WindowWidth = 848;
int Application::WindowHeight = 480;
int Application::DefaultMonitor = 0;

char Application::EngineVersion[256];

char Application::GameTitle[256];
char Application::GameTitleShort[256];
char Application::Version[256];
char Application::Description[256];
char Application::GameVersion[256];
char Application::GameDescription[256];

int Application::UpdatesPerFrame = 1;
bool Application::Stepper = false;
Expand Down Expand Up @@ -162,7 +168,11 @@ PUBLIC STATIC void Application::Init(int argc, char* args[]) {
freopen_s((FILE **)stderr, "CONOUT$", "w", stderr);
#endif

Application::MakeEngineVersion();

Log::Init();
Log::Print(Log::LOG_INFO, "Hatch Game Engine %s", Application::EngineVersion);

MemoryPools::Init();

SDL_SetHint(SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
Expand Down Expand Up @@ -269,10 +279,32 @@ PUBLIC STATIC void Application::Init(int argc, char* args[]) {
Running = true;
}

PRIVATE STATIC void Application::MakeEngineVersion() {
std::string versionText = std::to_string(VERSION_MAJOR) + "." + std::to_string(VERSION_MINOR);

#ifdef VERSION_PATCH
versionText += ".";
versionText += std::to_string(VERSION_MINOR);
#endif

#ifdef VERSION_PRERELEASE
versionText += "-";
versionText += VERSION_PRERELEASE;
#endif

#ifdef VERSION_CODENAME
versionText += " (";
versionText += VERSION_CODENAME;
versionText += ")";
#endif

if (versionText.size() > 0)
StringUtils::Copy(Application::EngineVersion, versionText.c_str(), sizeof(Application::EngineVersion));
}

PUBLIC STATIC bool Application::IsPC() {
return Application::Platform == Platforms::Windows || Application::Platform == Platforms::MacOS || Application::Platform == Platforms::Linux;
}

PUBLIC STATIC bool Application::IsMobile() {
return Application::Platform == Platforms::iOS || Application::Platform == Platforms::Android;
}
Expand Down Expand Up @@ -485,9 +517,9 @@ PRIVATE STATIC void Application::Restart() {
Graphics::SpriteSheetTextureMap->Clear();

BytecodeObjectManager::LoadAllClasses = false;
BytecodeObjectManager::DisableAutoAnimate = false;
Graphics::UseSoftwareRenderer = false;
Graphics::UsePalettes = false;
BytecodeObject::DisableAutoAnimate = false;

Graphics::Reset();

Application::LoadGameConfig();
Application::LoadGameInfo();
Expand Down Expand Up @@ -1317,8 +1349,8 @@ PRIVATE STATIC string Application::ParseGameVersion(XMLNode* versionNode) {
PRIVATE STATIC void Application::LoadGameInfo() {
StringUtils::Copy(Application::GameTitle, "Hatch Game Engine", sizeof(Application::GameTitle));
StringUtils::Copy(Application::GameTitleShort, Application::GameTitle, sizeof(Application::GameTitleShort));
StringUtils::Copy(Application::Version, "1.0", sizeof(Application::Version));
StringUtils::Copy(Application::Description, "Those who dare to fail miserably can achieve greatly.", sizeof(Application::Description));
StringUtils::Copy(Application::GameVersion, "1.0", sizeof(Application::GameVersion));
StringUtils::Copy(Application::GameDescription, "Cluck cluck I'm a chicken", sizeof(Application::GameDescription));

if (Application::GameConfig) {
XMLNode* root = Application::GameConfig->children[0];
Expand All @@ -1339,12 +1371,12 @@ PRIVATE STATIC void Application::LoadGameInfo() {
if (node) {
std::string versionText = Application::ParseGameVersion(node);
if (versionText.size() > 0)
StringUtils::Copy(Application::Version, versionText.c_str(), sizeof(Application::Version));
StringUtils::Copy(Application::GameVersion, versionText.c_str(), sizeof(Application::GameVersion));
}

node = XMLParser::SearchNode(root, "description");
if (node)
XMLParser::CopyTokenToString(node->children[0]->name, Application::Description, sizeof(Application::Description));
XMLParser::CopyTokenToString(node->children[0]->name, Application::GameDescription, sizeof(Application::GameDescription));
}
}

Expand Down
105 changes: 93 additions & 12 deletions source/Engine/Bytecode/BytecodeObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class BytecodeObject : public Entity {
public:
static bool DisableAutoAnimate;

ObjInstance* Instance = NULL;
HashMap<VMValue>* Properties;
};
Expand All @@ -14,6 +16,8 @@ class BytecodeObject : public Entity {
#include <Engine/Bytecode/StandardLibrary.h>
#include <Engine/Scene.h>

bool BytecodeObject::DisableAutoAnimate = false;

#define LINK_INT(VAR) Instance->Fields->Put(#VAR, INTEGER_LINK_VAL(&VAR))
#define LINK_DEC(VAR) Instance->Fields->Put(#VAR, DECIMAL_LINK_VAL(&VAR))
#define LINK_BOOL(VAR) Instance->Fields->Put(#VAR, INTEGER_LINK_VAL(&VAR))
Expand Down Expand Up @@ -293,6 +297,14 @@ PUBLIC void BytecodeObject::LinkFields() {
*/
LINK_INT(OnScreen);
/***
* \field WasOffScreen
* \type Boolean
* \default false
* \ns Instance
* \desc Indicates if the entity was previously off-screen.
*/
LINK_INT(WasOffScreen);
/***
* \field OnScreenHitboxW
* \type Decimal
* \default 0.0
Expand Down Expand Up @@ -321,7 +333,7 @@ PUBLIC void BytecodeObject::LinkFields() {
* \type Integer
* \default 0
* \ns Instance
* \desc A bitfield similar to <linkto ref="instance.ViewRenderFlag"></linkto>. Bypasses each view's entity rendering toggle set by <code>Scene.SetObjectViewRender</code>.
* \desc A bitfield similar to <linkto ref="instance.ViewRenderFlag"></linkto>. Bypasses each view's entity rendering toggle set by <linkto ref="Scene.SetObjectViewRender"></linkto>.
*/
LINK_INT(ViewOverrideFlag);

Expand All @@ -330,18 +342,50 @@ PUBLIC void BytecodeObject::LinkFields() {
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The horizontal on-screen range where the entity can update. If this and <linkto ref="instance.UpdateRegionH"></linkto> are set to <code>0.0</code>, the entity will update regardless of the camera's position.
* \desc The horizontal on-screen range where the entity can update. If this is set to <code>0.0</code>, the entity will update regardless of the camera's horizontal position.
*/
Instance->Fields->Put("UpdateRegionW", DECIMAL_LINK_VAL(&OnScreenHitboxW));
/***
* \field UpdateRegionH
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The vertical on-screen range where the entity can update. If this and <linkto ref="instance.UpdateRegionW"></linkto> are set to <code>0.0</code>, the entity will update regardless of the camera's position.
* \desc The vertical on-screen range where the entity can update. If this is set to <code>0.0</code>, the entity will update regardless of the camera's vertical position.
*/
Instance->Fields->Put("UpdateRegionH", DECIMAL_LINK_VAL(&OnScreenHitboxH));
/***
* \field UpdateRegionTop
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The top on-screen range where the entity can update. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.UpdateRegionH">UpdateRegionH</linkto> instead.
*/
Instance->Fields->Put("UpdateRegionTop", DECIMAL_LINK_VAL(&OnScreenRegionTop));
/***
* \field UpdateRegionLeft
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The left on-screen range where the entity can update. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.UpdateRegionW">UpdateRegionW</linkto> instead.
*/
Instance->Fields->Put("UpdateRegionLeft", DECIMAL_LINK_VAL(&OnScreenRegionLeft));
/***
* \field UpdateRegionRight
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The left on-screen range where the entity can update. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.UpdateRegionW">UpdateRegionW</linkto> instead.
*/
Instance->Fields->Put("UpdateRegionRight", DECIMAL_LINK_VAL(&OnScreenRegionRight));
/***
* \field UpdateRegionBottom
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The bottom on-screen range where the entity can update. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.UpdateRegionH">UpdateRegionH</linkto> instead.
*/
Instance->Fields->Put("UpdateRegionBottom", DECIMAL_LINK_VAL(&OnScreenRegionBottom));
/***
* \field RenderRegionW
* \type Decimal
* \default 0.0
Expand All @@ -357,6 +401,38 @@ PUBLIC void BytecodeObject::LinkFields() {
* \desc The vertical on-screen range where the entity can render. If set to <code>0.0</code>, the entity will render regardless of the camera's vertical position.
*/
LINK_DEC(RenderRegionH);
/***
* \field RenderRegionTop
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The top on-screen range where the entity can render. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.RenderRegionH">RenderRegionH</linkto> instead.
*/
LINK_DEC(RenderRegionTop);
/***
* \field RenderRegionLeft
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The left on-screen range where the entity can render. If this and <linkto ref="instance.RenderRegionRight"></linkto> are set to <code>0.0</code>, the entity will use its <linkto ref="instance.RenderRegionW">RenderRegionW</linkto> instead.
*/
LINK_DEC(RenderRegionLeft);
/***
* \field RenderRegionRight
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The left on-screen range where the entity can render. If this and <linkto ref="instance.RenderRegionLeft"></linkto> are set to <code>0.0</code>, the entity will use its <linkto ref="instance.RenderRegionW">RenderRegionW</linkto> instead.
*/
LINK_DEC(RenderRegionRight);
/***
* \field RenderRegionBottom
* \type Decimal
* \default 0.0
* \ns Instance
* \desc The bottom on-screen range where the entity can render. If set to <code>0.0</code>, the entity will use its <linkto ref="instance.RenderRegionH">RenderRegionH</linkto> instead.
*/
LINK_DEC(RenderRegionBottom);

/***
* \field HitboxW
Expand Down Expand Up @@ -597,13 +673,9 @@ PRIVATE bool BytecodeObject::GetCallableValue(Uint32 hash, VMValue& value) {
return true;
}
else {
if (!klass->Parent && klass->ParentHash) {
BytecodeObjectManager::SetClassParent(klass);
}
if (klass->Parent && klass->Parent->Methods->GetIfExists(hash, &result)) {
value = result;
value = BytecodeObjectManager::GetClassMethod(klass, hash);
if (!IS_NULL(value))
return true;
}
}

return false;
Expand Down Expand Up @@ -739,13 +811,22 @@ PUBLIC void BytecodeObject::Initialize() {
Gravity = 0.0f;
Ground = false;

WasOffScreen = false;
OnScreen = true;
OnScreenHitboxW = 0.0f;
OnScreenHitboxH = 0.0f;
OnScreenRegionTop = 0.0f;
OnScreenRegionLeft = 0.0f;
OnScreenRegionRight = 0.0f;
OnScreenRegionBottom = 0.0f;
ViewRenderFlag = 0xFFFFFFFF;
ViewOverrideFlag = 0;
RenderRegionW = 0.0f;
RenderRegionH = 0.0f;
RenderRegionTop = 0.0f;
RenderRegionLeft = 0.0f;
RenderRegionRight = 0.0f;
RenderRegionBottom = 0.0f;

Angle = 0;
AngleMode = 0;
Expand All @@ -754,15 +835,15 @@ PUBLIC void BytecodeObject::Initialize() {

Priority = 0;
PriorityListIndex = -1;
PriorityOld = 0;
PriorityOld = -1;

Sprite = -1;
CurrentAnimation = -1;
CurrentFrame = -1;
CurrentFrameCount = 0;
AnimationSpeedMult = 1.0;
AnimationSpeedAdd = 0;
AutoAnimate = BytecodeObjectManager::DisableAutoAnimate ? false : true;
AutoAnimate = BytecodeObject::DisableAutoAnimate ? false : true;
AnimationSpeed = 0;
AnimationTimer = 0.0;
AnimationFrameDuration = 0;
Expand Down Expand Up @@ -1326,7 +1407,7 @@ PUBLIC STATIC VMValue BytecodeObject::VM_SetViewVisibility(int argCount, VMValue
}
/***
* \method SetViewOverride
* \desc Toggles the bypass for each view's entity rendering toggle set by <code>Scene.SetObjectViewRender</code>.
* \desc Toggles the bypass for each view's entity rendering toggle set by <linkto ref="Scene.SetObjectViewRender"></linkto>.
* \param viewIndex (Integer): The view index.
* \param visible (Boolean): Whether the entity will always be visible or not on the specified view.
* \ns Instance
Expand Down
Loading

0 comments on commit d53f603

Please sign in to comment.