Code Monkey home page Code Monkey logo

hyper's Introduction

๐Ÿ‘‹ Hi, Iโ€™m @coderoyalty

coderoyalty


ALX Certificate


coderoyalty

GitHub Streak


coderoyalty

Tech Stack:

C C++ CSS3 HTML5 Markdown JavaScript Python TypeScript Render Vercel Express.js NodeJS React Redux React Router TailwindCSS Vite MongoDB Postman

Connect with me:

hyper's People

Contributors

coderoyalty avatar positron-dev avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

positron-dev

hyper's Issues

GUI Layer not updated before every other layers

The engine by default owns few layers which includes the GUI Layer. The GUI Layer creates the necessary initialization and specifications required for having a working GUI system setup!

Since, the GUI layer is guaranteed to be the first created layer in layer stack (so far the Application creates it), it should also be the first updated layer (basically any layer created by the engine itself, should be updated earlier than the other layers).

auto& gameLayer = new GameLayer(...);
auto& gameXXXLayer = new GameXXXLayer(...);

hyp::Application app(...); // the GUI Layer had been created and added internally
app.pushLayer(gameLayer);
app.pushLayer(gameXXXLayer);

Since the layer stack is updated this way:

gameXXXLayer.update(...);
gameLayer.update(...);
//guiLayer.update(...);

Technically this is right, as it's doing what a stack does best! But logically the GUI Layer supersedes the other layers (and more layers could also exists in this manner), and should be updated first.

It's this issue of being updated last, that makes the editor-layer event blocking wrong!

Documentation

Script Reference

Hyper is still a work-in-progress engine at this time. The scripting system is in its alpha stage, and changes might happen without order; however, this guide remains viable for the scripting basics of the engine.

To attach a script to an entity, create a .lua

-- Player.lua
local Player = {}

return Player

The script must return a table. It is used to access other parts of the system. A script file has three primary methods.

-- called once, when the script was loaded
function Player:init()
end

-- called for every frame
function Player:update(dt)
end

-- called when the scene ends
function Player:destroy()
end

the init and destroy methods can be omitted, but the update method is required and compulsory; In other words, there should be no script file if there's no update method.

How to interact with the entity's component

Each script is attached to an entity, as a component. An entity can have many elements, and by default has an ID, tag and transform component. Presumably, these components are always existing for an entity.

Here's how we can interact with components from the script:

function Player:init()
  self.velocity = 10
  transform = self.owner:get(self.id(), Transform)
  print(transform.position)
  print(transform.scale)
  print(transform.rotation)
end

function Player:update(dt)
  transform = self.owner:get(self.id(), Transform)
  transform.position.x = transform.position.x + self.velocity * dt -- continue moving to the right
end

self.owner: The S in ECS. It's an interface to the scene's registry where entities and their components are managed. It provides methods such as has, get, valid, remove, clear and emplace. These methods take two parameters, an entity ID, and the component type.
self.id: The script's entity ID.

Available Components:

  • IDComponent
  • TagComponent
  • Transform
  • SpriteComponent
  • CircleComponent
  • TextComponent

reference /hyper/src/scene/components.hpp to see the component structures

The application crashes when an empty texture is passed to the renderer

This should reproduce the bug:

// equivalent to nullptr
hyp::Ref<hyp::Texture2D> texture;

hyp::Renderer2D::drawQuad(transform, texture, 1.f, glm::vec4(1.0));

Potential reason:
The renderer is not checking if the passed texture is empty or not. crashes because it was trying to bind to an invalid texture, (opengl's side)

Project goal

          Hyper hasn't been tested on other platforms. But, the goal is for the engine not to be platform-specific. To achieve this, we use libraries/packages that are not platform-specific. Development is actively happening on Windows, and the application is not expected to run on other platforms successfully.

Originally posted by @coderoyalty in #23 (comment)

File dialogs for all platform

File dialogs are only available for windows.

#if defined(_WIN32)
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
std::string hyp::FileDialog::openFile(const char* filter) {
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
CHAR currentDir[256] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)hyp::Application::get().getWindow()->getNativeWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
if (GetCurrentDirectoryA(256, currentDir))
ofn.lpstrInitialDir = currentDir;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
// Display the Open dialog box
if (GetOpenFileNameA(&ofn) == TRUE)
{
return ofn.lpstrFile;
}
return "";
}
std::string hyp::FileDialog::saveFile(const char* filter) {
OPENFILENAMEA ofn;
CHAR szFile[260] = { 0 };
CHAR currentDir[256] = { 0 };
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = glfwGetWin32Window((GLFWwindow*)hyp::Application::get().getWindow()->getNativeWindow());
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
if (GetCurrentDirectoryA(256, currentDir))
ofn.lpstrInitialDir = currentDir;
ofn.lpstrFilter = filter;
ofn.nFilterIndex = 1;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR;
// Sets the default extension by extracting it from the filter
ofn.lpstrDefExt = strchr(filter, '\0') + 1;
if (GetSaveFileNameA(&ofn) == TRUE)
return ofn.lpstrFile;
return std::string();
}
#else
std::string hyp::FileDialog::openFile(const char* filter) {
HYP_ASSERT_CORE(false, "Platform not supported");
return std::string();
}
std::string hyp::FileDialog::saveFile(const char* filter) {
HYP_ASSERT_CORE(false, "Platform not supported");
return std::string();
}
#endif

It'll be cumbersome to write codes for all platforms... best to use a package that already abstracts this..

high initial delta-time at first frame

class GameLayer: public Layer {
 ...
}

//... in layer::onUpdate method
{
  std::cout << dt << std::endl;
}

output (may vary):

1854532.50
//...

every other value looks great for a delta-time

dispatch circle renderer when its batch capacity is at maximum

//TODO: call next circle batch if the batch capacity is filled
for (size_t i = 0; i < 4; i++)
{
CircleVertex vertex{};
vertex.color = color;
vertex.worldPosition = transform * s_renderer.quad.vertexPos[i]; // TODO: create circle's vertexPos to avoid coupled code
vertex.localPosition = s_renderer.quad.vertexPos[i] * 2.f;
vertex.thickness = thickness;
vertex.fade = fade;
s_renderer.circle.vertices.push_back(vertex);
}

This was marked as a TODO flag in the renderer code, but it'll be great to have it as an issue (so we don't forget)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.