Skip to content

LiquidityC/flat

Repository files navigation

Flat

maintenance Build Status Build status codecov Codacy Badge CodeFactor Join the chat at https://gitter.im/flat2d/Lobby HitCount

About

Flat is a 2D game engine based on SDL2. It's currently in progress with no deadline for completion. It will be completed when I'm happy with it. The main goal was to create an engine where writing code was what you mainly did. No drag and drop UIs no autogenerated code. Just pure C++ to make your game. The engine is growing rather frequently and the API changes a lot. But the API should be kept up to date if I'm doing my job right.

Features

  • Simple collision handling
  • Parallax effects
  • Music and sound
  • Game controller support
  • hiDPI screen support

Compiling

Before compiling you need to install SDL2, SDL2_image, SDL2_mixer and SDL2_ttf

  • Clone the project and navigate to the root folder
  • mkdir build
  • cd build
  • cmake ..
  • make

Getting started

#include <iostream>
#include <flat/flat.h>

int main(int argc, char* argv[])
{
	std::cout << "Loading Flat" << std::endl;
	flat2d::FlatBuilder *flat = new flat2d::FlatBuilder();
	flat->loadSDL("Flat Demo", 60, 800, 600);
	flat2d::GameEngine *engine = flat->getGameEngine();

	flat2d::EntityContainer *container = flat->getGameData()->getEntityContainer();
	// You can register your objects to the container here. Objects extend the Entity class in flat

	// Create the callback methods
	auto stateCallback = [](flat2d::GameData *gameData) -> flat2d::GameStateAction {
		return flat2d::GameStateAction::NOOP;
	};
	auto handleCallback = [](const SDL_Event& event) -> void {
		// Nothing to do here
	};

	std::cout << "Starting the engine" << std::endl;
	// stateCallback and handleCallback can be omitted if you don't need them
	engine->run(stateCallback, handleCallback);
	std::cout << "Exiting" << std::endl;

	delete flat;
}

Contributing

If you have some feature idea that you'd like to see added to flat you are most welcome to fork the project and create a pull request with your idea in code form or create an issue and I'll have a look at it.

At the moment of writing (2018-02-20) I'm working on a good old C game project and flat isn't getting the frequent updates that one might expect. But I love to code so I don't mind some ideas thrown into the mix. The project isn't dead is the point I want to make by this.

Demos

Just Don't Die

Examples

Documentation