• Stars
    star
    152
  • Rank 244,685 (Top 5 %)
  • Language
    C++
  • License
    Other
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An intuitive and beginner friendly 2D game framework for C++

NasNas-logo

An intuitive and beginner friendly 2D game framework for C++.

Features โ€ข How to build โ€ข Get Started โ€ข Screenshots โ€ข Showcase โ€ข Support

NasNas is a lightweight cross platform modular 2D game framework.

It is entirely written in modern C++17, and uses SFML2 for rendering.

It provides a clean and easy to use API.

The framework is separated in multiple modules :

  • Core is the only non-optional module. It is needed to create a NasNas application. It contains core classes and data needed by the framework.
  • ECS is an efficient data driven Entity Component System. It allows you to attach components to entities and run systems on specific sets of components.
  • Reslib contains the resource manager and resource loader. It handles resource loading and accessing in an elegant way.
  • Tilemapping is a Tiled Map loader (.tmx). It seamlessly integrates with NasNas and speeds up development for tile based games.
  • Tween allows you to animate any object using the provided or custom easing functions.
  • UI contains the User Interface utilities. (WIP)
  • More modules will be developed in the future !
Click to see platforms support
Core Ecs Reslib Tilemapping Tween Ui
Windows โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
Linux โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
MacOS โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
Android โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ โœ”๏ธ
iOS โ“ โ“ โ“ โ“ โ“ โ“

Features

Implemented :
  • Scene and Layers system
  • Cameras and Shaders
  • Application states (using StateStackApp or StateMachineApp)
  • Automatic resource loader and manager
  • Data oriented ECS inspired by entt with a bunch of provided components and defaults systems.
  • Tiled map loader (.tmx)
  • Text and bitmap fonts
  • Customizable Transitions
  • Flexible Tween and MultiTween utilities.
  • Extensible Particles system
  • Multi texture SpriteBatching
  • App configuration and settings
  • Debug text display in-game
  • Convenient console Logger
  • And more !
To do :
  • Menus and UI
Future :
  • Splash screens
  • Levels and game events management
  • In-game command line for debugging

You can find a global roadmap for the version 1.0 on the project board

Build

Desktop

Clone the repository.

git clone https://github.com/Madour/NasNas
cd NasNas

Then, you can build the static libraries with :

mkdir build && cd build
cmake ..
cmake --build . -j4

Finally, you can install those libraries using :

cmake --install .

Android

To build the framework for Android, please refer to the Android example's readme

Available CMake options :

  • -DNASNAS_BUILD_ECS=OFF to disable the ECS module

  • -DNASNAS_BUILD_RESLIB=OFF to disable the Reslib module

  • -DNASNAS_BUILD_TILEMAPPING=OFF to disable the Tilemapping module

  • -DNASNAS_BUILD_TWEEN=OFF to disable the Tween module

  • -DNASNAS_BUILD_UI=OFF to disable the UI module

  • -DNASNAS_EXAMPLES=ON to create the example applications targets

  • -DNASNAS_BUILD_SFML=ON to download and build SFML inside the project (enabled automatically if SFML package is not found)

  • -DNASNAS_STATIC_VCRT=ON to link the Visual C++ runtime statically (/MT) when using the Microsoft Visual C++ compiler

Get Started

Here is a sample code using NasNas framework, this will create a 720x480 window and log a string to the console :

#include <NasNas/Core.hpp>

class Game : public ns::App {
public:
    Game() : ns::App("My game", 720, 480) {
        ns_LOG("Created a NasNas app !");
    }
    void onEvent(const sf::Event& event) override {
        if (event.type == sf::Event::Closed)
            getWindow().close();
    }
    void update() override {}
};

int main() {
    Game g;
    g.run();
    return 0;
}

An introduction tutorial to learn how to use the framework can be found on the wiki.

Documentation can be found here.

You can also check examples source code for a small overview of what you can do with the framework.

Screenshots

All of these programs source code can be found in the examples folder.

Split View

2021-09-02_12-15-46

Line paint

2021-09-02_12-17-09

Tweening

2021-09-02_12-17-56

Animated sprites

animated_sprites-d_zZDAUUAIOb

Particles System

particles.mp4

Parallax platformer demo game

Desktop
platformer2.mp4
Android
platformer_android.mp4

Showcase

Games

The following games were created with NasNas :

  • Warp Runner on itch (Desktop)
  • History Leaks on itch and github (Desktop)
  • Cyber Slayer on github (Desktop and Android)

Other

A simple physics engine made with NasNas only
2021-07-14_21-06-10.mp4

Support

If you like the project, please consider starring this repository.

If you would like to discuss anything about the project, feel free to open a new discussion.

Author

  • Modar Nasser