c++ library

KLibrary Documentation

KLibrary is a simple C++ library providing resources to easily create programs like games.

The philosophy of this library is to be uncluttered and nice.

KWindow creates a window, KControl gives you pressed keys and mouse position, KSocketUdp creates an UDP network socket, and so on...

This library uses the SDL2 library↗. If you are experienced, you better use the SFML library↗.
KLibrary is for you only if SDL and SFML are too complicated to you.
Note that using the SDL2 library is great for practicing and learn how C language works.


Example

This is a basic example, which can be understood without comments.

#include "KLibrary.hpp"

int main() {
    KWindow window("hello world", 400, 260);

    struct {
        KRect<> rectangle{30, 30, 10, 10};
        KColor color{100, 255, 150};
    } square;

    KTimer timer(KTimer::Fps60);
    while (not window.event.close and not window.event.quit) {
        window.fill(KColor::Black);
        window.fill(square.rectangle, square.color);
        window.display();

        timer.wait();
        window.event.update();
    }

    return 0;
}

Get Started

Download or clone from gitlab the library, try to compile it with the Makefile, see which packages are missing, install the missing packages.
These packages have to be installed: libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev

Create a project directory, copy the library sources in this directory (or in a subdirectory), include the necessary headers (KLibrary.hpp will include all modules).

Make sure the compilation arguments are compatible with the library (check the KLibrary Makefile to see the used arguments).

To see an implementation of this library, have a look to this pong game↗.

Rules

All members of class shown in the documentation are publics (useless to show private member, then, useless to say that shown members are publics, logic!).

All module pages have sections, the order will always be : Template, Constructor, Member, Method, Predefined, Operator, Example.

In sections, the description always come after the code.

License

MIT License

Copyright (c) 2018 Gerbais-Nief	Eddie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.