GithubHelp home page GithubHelp logo

fallahn / xygine Goto Github PK

View Code? Open in Web Editor NEW
217.0 20.0 18.0 173.56 MB

2D engine / framework built around SFML

CMake 0.33% C++ 88.78% C 10.80% Objective-C 0.07% Objective-C++ 0.02% GLSL 0.01%
2d-framework sfml ecs gamedev gamedev-framework

xygine's Introduction

xygineXT

Github Actions

The next iteration of xygine....

Logo by Baard

2D Game Engine Framework built around SFML. xygine implements a scene graph along with an Entity Component System. I use this as the starting point for new projects, as it evolves slowly over time. The source for xygine is released under the zlib license in the hope that it may be useful for other people - but offers no warranty that it is fit for any particular purpose, even those for which it was specifically written...

This version provides an overhauled API and, as such, is not compatible with existing versions of xygine - hence the slightly different naming. The biggest changes are to the Entity Component System for flexible, modular development of systems with a data-driven approach, as well as the removal of 3D support. If you're interested in a 3D, crossplatform, mobile compatible framework with a very similar API, check out crogine.

xygine uses C++17 features so an up to date compiler is required, for example XCode 10 on macOS, Visual Studio 2017 on windows or recent versions of gcc and clang.

A full tutorial covering the process of creating a xygine game can be found in the tutorial directory of the repository.

See some of the games I've made with xygine here!

What's new?

All new modular ECS providing a flexible and performant API for implementing custom components and systems, which compliment the systems included in the library

Reworked CMake build system, courtesy of Jonny 'The Machine' Paton, using modern CMake syntax as well as being Visual Studio compatible.

All new reliable network connection classes dedicated to creating gameplay oriented connections based upon the indomitable Enet

There is also a collection of utilites which may be useful for development of projects in the 'extras' directory.

Contributions

Contributions should be acknowledged and are gratefully accepted from:
Jonny Paton (Build system and CI setup and many usability improvements)
Jean-Sebastien Fauteux (macOS Testing)
Baard (Awesome Logo)

FAQ

Where's the 3D stuff gone?

While it had the potential to look very pretty the 3D API did not mesh (pun intended ;) ) well with the 2D rendering. Mixing custom OpenGL, particularly non-core 2.1 level, with SFML meant that it did not perform optimally, as well as not working on macOS which doesn't support compatibility profiles. If you really want 3D there are many better engines/frameworks out there, including crogine, another framework by myself which is optimised for 3D, particularly on mobile devices. It features a very similar API to xygine too.

What about physics stuff?

The physics binding of Box2D has been removed, mostly because I wasn't using it. It may return in the future, but thanks to the new ECS API implementing your own binding to any physics engine of choice, or even implementing your own collision detection is super easy. There's an example of a Chipmunk2D binding in the 'extras' directory.

...and the Tiled map support?

This had already been spun out into tmxlite and maintaining two versions of it seemed an unnecessary amount of work. Tmxlite works easily with any project, and is even used in the demo project included in this repository.

So I can't use the old version any more?

Sure you can. From now on the old revision is referred to in the documentation as 'legacy', and can be found in its own branch. The wiki pages remain available, although the doxy generated content is offline and will need to be generated from the docs directory using doxygen.

Why xygine?

The name is simply derived from the fact that this is a 2D framework - hence xy, followed by the gine part of engine (although technically xygine isn't really an engine).

xygine uses native file dialogue
https://github.com/mlabbe/nativefiledialog
and dear imgui
https://github.com/ocornut/imgui
https://github.com/eliasdaler/imgui-sfml

/*********************************************************************
(c) Matt Marchant & contributors 2017 - 2021
http://trederia.blogspot.com

xygineXT - Zlib license.

This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented;
    you must not claim that you wrote the original software.
    If you use this software in a product, an acknowledgment
    in the product documentation would be appreciated but
    is not required.

  2. Altered source versions must be plainly marked as such,
    and must not be misrepresented as being the original software.

  3. This notice may not be removed or altered from any
    source distribution.
    *********************************************************************/

xygine's People

Contributors

fallahn avatar jonnyptn avatar rosme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xygine's Issues

Don't use system include paths when including xyginext headers

Minor issue I've had for a while - xyginext source files include xyginext headers using '#include <.hpp>' instead of '#include ""' which means when I'm working on xyginext itself, it includes the installed headers (which will almost always be out of date) instead of the project ones, so I have to clear out my /usr/local/include/xyginext folder whenever I make changes to the xyginext headers

Like I said, it's not a huge issue, but if it has no other negative effects (which I don't believe it should?) then it would be a helpful change. I can easily roll it into the other changes I'm making for the editor if you don't have any objections?

Add programatically selecting active console tab

The ImGui API appears to support this, but it's possible the currently included version of ImGui is buggy or out of date as the behaviour of ImGuiTabItemFlags_SetSelected is not as expected - and the documented function SetTabItemSelected() doesn't exist. Ultimately the ImGui implementation in xygine needs to be updated to the latest reasonable version but care needs to be taken to properly export the ImGui API from the shared library build, as well implement (the now possibly unmaintained) SFML renderer for ImGui.

Child entity quad tree components aren't recognised

Normally adding an entity to the scene which has point light or quad tree components will be automatically recognised by the scene, and those components added to their respective quad trees. If an entity has child entities and any of those has either a quad tree or point light component attached, the components are not recognised, and are therefore not correctly added to the scene. This is also true when adding either of these components to an entity which already belongs to a scene.

Particle manager component occasionally spawns multiple systems

When the component for spawning particle systems has a new spawn request occasionally it will spawn two systems - one at the requested position, and one at the position of the previously spawned system. This behaviour can be seen in the example application.

Expose ImGui theme settings via ConfigFile

It might be nice when integrating the ImGui classes with your own game to be able to more easily customise the appearance. As ImGui uses pretty simple theme settings I thought it might be nice to expose these via something like xy::Nim::loadTheme(const std::string& pathToConfig) where the config file contains a list of values (float - vec4 are currently supported) which can be mapped to various style properties. This way custom themes can be loaded at run time (and possibly included in the editor, hint hint ;) )

Cannot find enet members

Moved from here:

I took the latest master build of xygine and getting this error..

/Users/Projects/xygine/xyginext/src/network/NetHost.cpp:128:21: error: no member named 'connectedPeers' in
'_ENetHost'
if (m_host->connectedPeers > 0)
~~~~~~ ^
/Users/Projects/xygine/xyginext/src/network/NetHost.cpp:130:43: error: no member named 'connectedPeers' in
'_ENetHost'
for (auto i = 0u; i < m_host->connectedPeers; ++i)
~~~~~~ ^
/Users/Projects/xygine/xyginext/src/network/NetHost.cpp:213:31: error: no member named 'connectedPeers' in
'_ENetHost'
return (m_host) ? m_host->connectedPeers : 0;
~~~~~~ ^
3 errors generated.
make[2]: *** [CMakeFiles/xyginext.dir/src/network/NetHost.cpp.o] Error 1
make[1]: *** [CMakeFiles/xyginext.dir/all] Error 2
make: *** [all] Error 2

Convar Improvements

Currently the convar configuration file always reads/writes the default configuration directory instead of the working application directory - this is a bug. Convars also need a better public facing interface so developers can more easily read loaded values at runtime.

Mobile-support

Hi,
Are you planning to add mobile support or are you going to keep the engine desktop only?
Thanks.

Predictive text in console window

Currently the only way to view registered console commands is with the list_all command. imgui provides a mechanism for displaying predictive text in text input boxes which, so far, I've been too lazy to implement.

Add set framerate limit to video options

In order to address using max CPU when xy windows lose focus this should be added next to the v-sync button in the options menu (along with some value box to set the max frame rate?). Probably needs to auto-uncheck the v-sync button when selected and vice versa to prevent both being enabled at once.

Audioscape class needs to be updated for ResourceHolder

Currently still requires construction with AudioResource class. Would be nice to add mixer channel as a property to the audioscape file format also. Apparently past me thought this was such a good idea he already implemented it.

Fallback font should be stored outside of TU

Currently the fallback font for the font resource is stored as a binary array in the .cpp file... This should really be external, at the very least in its own header to prevent IDEs/text editors struggling with a large file or ideally completely separate as it bloats the library dll with often unused data.

Stop escape key quitting game in debug

It was super useful in the really early stages, but now I want to use escape for my pause key, it means the game quits whenever I try and pause in debug.

I'd propose one of:

  1. Change the key to something less likely to clash, or add a modifier (e.g. shift + escape)
  2. Remove the key and replace with a "quit" option in the debug menu
  3. Modify the xy::app::handleEvent function to return a bool whether the event has been processed or not, so the engine can ignore key presses which are consumed by the game

Change resolution

Hi,
It looks like the default internal resolution is 1920X1080 and I haven't been able to change it. If I change the renderWindow size it just resizes de window and everything inside it, if I try to change the contex view, then it doesn't render everything in the screen. So how can I change this resolution?.
Thanks

Rendered content is offset on the y axis and gets cut off if moved up

I just started trying out xygine and if i draw a sf::RectangleShape at position (0,0) the shape does not appear in the top left corner of the window. Instead it is move down a little and if i move it up (eg. to (0, -10)) it gets cut off.
The console window renders as expected though and this also happens if i draw text using the Text component to the window.
I am on Fedora 31 and am using SFML 2.5 and the master branch of xygine. I also added a screenshot:
rendering_test

Drawable::updateLocalBounds() does not account for negative sized AABBs

Depending on winding order of vertices some AABBs may be calculated with a negative width or height - the current implementation only expects positive numbers so in these cases an AABB with zero width and height may be generated, causing the drawable to be permanently culled from rendering. Current workarounds are to either ensure the first vertex in the drawable's array is the closest to the origin, or to manually disable culling on the drawable.

getRelativePath query

I've noticed when using xy::Filesystem::getRelativePath() that the input has to be correctly formatted to get the expected results (unless my expectations are wrong... which I wouldn't rule out)

Say there's a file at /some/file/path/file.thing, I'd expect the relative path to the be the same when given these three "root" paths:

  1. /some/file/otherpath
  2. /some/file/otherpath/
  3. /some/file/otherpath/otherfile.thing

However 2 & 3 both return an extra directory higher (e.g. ../../path/file.thing instead of ../path/file.thing)

I could understand if 3 was left as it is, but I'd think 1 & 2 should return the same?

Slightly related to this - getFilePath() returns the directory path including the final /, so depending on your thoughts on this issue I'd maybe request to change that too, so it can be used as such: getRelativePath(somePath, getFilePath(rootFile))

App constructor is missing context settings parameter

This existed in the previous version and is still referred to in the doxy comments, but doesn't actually exist. On a related note, applying updated context settings appears to not recreate the window with, for example, a depth buffer.

Some undefined behaviour with ImGui windows

Currently only confirmed on windows: Registering then executing a custom console command which launches a NFD window via xy::FileSystem::openFileDialog() causes the console to immediately and continually return true at this line. The result is perpetual input of empty commands and resulting error message in the console. So far I've ruled out the creation of phantom events, so possibly a memory corruption issue by NFD?

GPU accelerate particle systems

while fine for most projects large number of particles generated with the current particle system can become slow to calculate CPU side. Hopefully moving some of the work to the GPU will improve performance - a new branch should be created to test this.

Issue with Box2D collisions not aligning

Hi there!

I'm using Box2D to implement the collision in my game, and so far it's going great! (As an aside, I was able to use the xygine framework and integrate it with the Tiled "Tile Collision Editor", so that collision bodies are automatically generated from the Tilesets internal object groups)

I'm having a slight issue now where the collision seems to be off by a few pixels and I can't seem to figure out why. When I use the debug drawing of the physics world, it doesn't seem like there should be any collisions. Any help is appreciated!

In the screenshots below, the cyan box is a Dynamic Rigidbody (controlled by keyboard input), and the rest are static bodies.

collisionissue2
collisionissue

Rendering a Scene multiple times for split screen with PostProcessing enabled is broken

By default a Scene can be rendered multiple times with different Camera components to create effects such as split screen or picture in picture. This breaks when PostProcess is enabled as the post process buffer gets cleared between draw calls. The fix for this is to submit a list of Camera component carrying entities to the Scene when drawing - see the crogine repository for potential implementation.

Optimise the reflection map buffer for MeshRenderer

Currently the Scene object renders the two farthest layers to a downsampled buffer, which is then used by the MeshRenderer as a reflection map. This is sub-optimal, as the MeshRenderer may not be using any materials which require a reflection map, or the Scene may not contain drawables on the rear layers - making any buffering moot. Suggestion is to create a specialised componented for rendering reflection maps so that the map is only drawn if it explicitly requested. This means the MeshRenderer can also be made more flexible by requiring the texture to be used as the reflection map to be explicitly stated. By default it would have a reflection map component target passed to it, but for situations where the far layers of the scene don't make sense (for example in a top down view the reflection would be that of the sky behind the camera, not the ground in front of it) custom reflection maps can be supplied to the MeshRenderer.

xy::Util::Vector::normalise fails assertion on 0 length vectors

calling xy::Util::Vector::normalise(vec) where vec is 0,0 causes an assert to fail. I'd expect it to just return 0,0?

Not a major issue, as I can adjust my code to handle these special cases, just seems like it would add some convenience without any downsides?

Text should be rendered via drawable component

Currently text components contain their own vertices instead of implementing the drawable component, and therefore get rendered with their own text render system. The only current advantage of this is the ability to crop texts - although this property could be moved to the drawable component. Ideally text would be drawn as other drawables, allowing it to be depth sorted with sprites and custom drawable implementations.

Particle system culling is broken

Seems the local bounds of particle systems is calculated incorrectly causing flickering when rendering. Culling should be performed in the system's draw function rather than processing to ensure the current render target view is up to date.

Spritesheet texture path must be quoted in .spt file

I haven't had a chance to investigate yet, just noting this down as it's caught me out a few times and I don't want to forget:

If the src parameter in the sprite file doesn't have quotes it will not load the texture correctly, e.g:

  • src=some/path.png doesn't work
  • src = "some/path.png" does work

Make xygine depend on a release build of Box2D (preferably 2.3.2)

Getting some build errors in g++ 5.4.1 on Linux; just wanted to make you aware just in case you weren't already. I can create a pull request if you like but most likely won't be able to until the weekend.

include/xygine/MultiRenderTexture.hpp:142:14: error: ‘bool xy::MultiRenderTexture::activate(bool)’ marked ‘override’, but does not override
         bool activate(bool) override;
include/xygine/mesh/DepthRenderTexture.hpp:112:14: error: ‘bool xy::DepthRenderTexture::activate(bool)’ marked ‘override’, but does not override
         bool activate(bool) override;
include/xygine/physics/DebugDrawer.hpp:67:18: error: ‘void xy::Physics::DebugDraw::DrawPoint(const b2Vec2&, float32, const b2Color&)’ marked ‘override’, but does not override
             void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) override;
src/mesh/DepthRenderTexture.cpp:51:21: error: ‘ensureGlContext’ was not declared in this scope
     ensureGlContext();
src/physics/PhysicsJointWheel.cpp:66:60: error: ‘class b2WheelJoint’ has no member named ‘GetJointAngularSpeed’
     return World::boxToSfFloat(getJointAs<b2WheelJoint>()->GetJointAngularSpeed());

I'm also getting some warnings - I can put those into a separate issue if you like or just create a pull request in the future.

Sort transparent pass objects by depth in MeshRenderer

Meshes drawn during the transparent pass need to be rendered back to front to be drawn correctly. This is, in general, OK when objects do not change depth and are added to the scene in the correct order - but is something the end user should not have to worry about. Objects can be sorted by the mesh renderer, preferably after view culling although could also be done via some sort of transform callback to reduce the total amount of sorting done

Create support tools

The repository contains two tools: a sprite animation editor and particle editor. These are used to preview and create the data files used by xygine's AnimatedSprite component and ParticleSystem component. It would be nice to replace these as, not only are they written using winforms - making them not particularly cross platform - they are missing features and could potentially be both part of the same software. With the addition of imgui to xygine I propose creating a single, cross platform application built on xygine itself which would also mean previews would be rendered accurately. This could also then be extended to provide support for materials used by the MeshRenderer, as well as a model viewer for previewing meshes to be used in xygine based games. As the mesh renderer has been dropped in the newest revision of xygine the current plan is for tools to target particle systems and sprite animations, using the new ConfigFile format. Potetially I'd like to create a scene graph editor too.

CMakeLists.txt missing from cmake template.

Steps to reproduce:

  1. cp cmake\ template ../xyginetest -r
  2. cd ../xyginetest
  3. mkdir build
  4. cd build
  5. cmake ..
  6. observe error
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/libX11.so
CMake Error at CMakeLists.txt:54 (add_subdirectory):
  The source directory

    /home/aria/projects/xyginetest/include

  does not contain a CMakeLists.txt file.


-- Configuring incomplete, errors occurred!

Stencil optimisation for MeshRenderer

The stencil buffer should be used during the geometry pass of the MeshRenderer so that the lighting pass can immediately discard unwritten fragments

Tiles Tearing when using xy::tmx::Map

Hello,

I've been using xygine for a game I'm making and first I just want to say thanks so much @fallahn for the work you've done. It's really amazing.

I ran into a problem today though: after following the documentation here, I have my TMX file being displayed on screen, and it's working great except for one major issue. While moving the screen around, lines (about 1 pixel wide as far as I can tell) often appear in between row/columns of tiles. Examples:
After startup
After moving camera.

So far what I've tried is making sure that my player's position (and as such the scene's camera's center pos) is always floored. Didn't seem to help any though. I'm not really sure what else to try.

My implementation can be found here.

Any help is greatly appreciated!

Config File doesn't like spaces

I'm not 100% clear what's happening, but it seems spaces can spanner up the config file parsing.

My particular scenario was using xy::Spritesheet - It didn't pick up some of my animations because it thought the object name was "animationx", whereas it should have been name="animation", id="x". Using tabs makes it work fine...

Improve gamepad/mouse support in UISystem

The current hack is to parse joystick move events and turn them to mouse move events, moving the mouse cursor around the screen when navigating menus. Ideally UI components should be auto assigned an index (which can be manually updated) so that joystick and dpad events can be used to select the prev/next control based on the current index - I assume this also affects the keyboard input too.

State stack cannot be initialised with more than one state

Currently adding more than one state before the state stack's first update will cause existing states to be removed. This should be fixed so that the stack can be initialised with multiple states, for example a background state with a menu state on top.

Wiki Maintenence (leave suggestions here)

While I try to keep the wiki as up to date as possible it is likely that the information is incomplete based on my personal assumptions of the reader's knowledge of the library, or possibly because it is out of date. Wiki pages are currently public in the hope that users will submit any missing information they might find or even add their own pages. Alternatively I encourage people to comment or place requests for the wiki in this thread.

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.