Git Product home page Git Product logo

playdate_util_libs's Introduction

Utility library bundle for Playdate

What's included

How to build / use

On macOS/Linux

Run install.sh to get libraries for both device and simulator.

On Windows

Untested, but you should be able to use cygwin to run the above.

TODO: Add 'Windows' way to get the project running.

Documentation

After building (see previous section), run doxygen at the root of this repository.

To use (include header, link libraries) the lib to the game

Add the following lines to your CMakeLists.txt, or adjust them if you already have those.

# Having this repo as a submodule might help.
set(UTIL_LIBS_PATH /path/to/playdate_util_libs)
# Then include this cmake file to bulk-link the library.
include(support.cmake)
if (TOOLCHAIN STREQUAL "armgcc")
    # Playdate build
    add_executable(MyPlaydateGame main.c) # you may have more than main.c
    # other stuff...
    target_include_directories(MyPlaydateGame PRIVATE ${UTIL_LIBS_PATH}/include)
    target_link_directories(MyPlaydateGame PRIVATE ${UTIL_LIBS_PATH}/lib)
    target_link_libraries(MyPlaydateGame ${PD_UTILS_LIBS})
    # more stuff...
else ()
    # Simulator build
    add_library(MyPlaydateSimGame main.c) # you may have more than main.c
    # other stuff...
    target_include_directories(MyPlaydateSimGame PRIVATE ${UTIL_LIBS_PATH}/include)
    target_link_directories(MyPlaydateSimGame PRIVATE ${UTIL_LIBS_PATH}/lib)
    # Append "_Sim" for simulator build.
    target_link_libraries(MyPlaydateSimGame ${PD_UTILS_LIBS_SIM})
    # more stuff...
endif ()

To access the features of this library

The easiest way is to include pd_utils.h. Call pdUtil_InitializeAll(void*) to initialize the library and pdUtil_FinalizeAll(void) to perform cleanup at kEventInit and kEventTerminate events, respectively.

#include <pd_utils.h>

int eventHandler(PlaydateAPI *pd, PDSystemEvent eventType, uint32_t arg) {
    switch (eventType)
    {
        case kEventInit:
            pdUtils_InitializeAll(pd);
            break;
        case kEventTerminate:
            pdUtils_FinalizeAll();
            break;
    }
}

License

MIT

playdate_util_libs's People

Contributors

clpsplug avatar

Watchers

 avatar

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.