<commit_before>
# nspire-nd

a simple cross-platform (desktop+ndless) 2d graphics lib


## What, exactly?

`ndless` for the TI Nspire includes an implementation of SDL1.2.
This library provides an abstracted 2d rendering API allowing
you to write code that will run unmodified both natively
on your x86 desktop and on your TI Nspire. For example, I can
run the `bouncyball` program on both my Linux computer and
on my TI Nspire simply by changing the build target.

Features include a framerate-limited game loop and
cross-platform BMP loading and SDL rendering.

## Build/run this demo

Build for ndless:
`make DISTDIR=binspire XPLAT_TARGET=nspire`

Build for linux (or any desktop, really):
`make DISTDIR=linux XPLAT_TARGET=desktop`

## What the API looks like

`main.cpp`
```cpp
#include "nd/nd.h"
#include <memory>

#include "gamestate.h"

int main(int argc, char** argv)
{
    std::unique_ptr<NGame> game(new NGame());

    game->platform_init(argc, argv);

    // Initialize NGame at max screen size, 60FPS target
    game->init(0, 0, 60);
    game->switch_state(new GameState());
    game->start();

    return 0;
}
```

`gamestate.cpp`
```cpp
#include "gamestate.h"

void GameState::create() {
    // add sprite
    // TODO

    this->setClearColor(NColor(84, 84, 84));

    NSprite* ball = new NSprite(20, 20);
    ball->loadGraphic("ball.bmp.tns");
    this->add(ball);

    NState::create();
}

void GameState::update(float dt) {
    // TODO: add custom update logic
    NState::update(dt);
}
```
<commit_msg>update sample code to use smart pointers<commit_after>
# nspire-nd

a simple cross-platform (desktop+ndless) 2d graphics lib


## What, exactly?

`ndless` for the TI Nspire includes an implementation of SDL1.2.
This library provides an abstracted 2d rendering API allowing
you to write code that will run unmodified both natively
on your x86 desktop and on your TI Nspire. For example, I can
run the `bouncyball` program on both my Linux computer and
on my TI Nspire simply by changing the build target.

Features include a framerate-limited game loop and
cross-platform BMP loading and SDL rendering.

## Build/run this demo

Build for ndless:
`make DISTDIR=binspire XPLAT_TARGET=nspire`

Build for linux (or any desktop, really):
`make DISTDIR=linux XPLAT_TARGET=desktop`

## What the API looks like

`main.cpp`
```cpp
#include <memory>

#include "deps.h"

#include "states/gamestate.h"

int main(int argc, char **argv) {
    auto game = std::make_shared<NGame>();

    game->platform_init(argc, argv);

    // Initialize NGame at max screen size, 30FPS target
    game->init(0, 0, 30);
    game->switch_state(new GameState());
    game->start();

    return 0;
}
```

`gamestate.cpp`
```cpp
#include "gamestate.h"

void GameState::create() {

    this->setClearColor(NColor(84, 84, 84));

    auto ball = std::make_shared<Ball>(20, 20);
    ball->loadGraphic("ball.bmp.tns");
    this->add(ball);

    // TODO: Add more sprites and objects

    NState::create();
}

void GameState::update(float dt) {

    // TODO: Add additional custom update logic

    bool esc = this->game->keys->pressed(SDLK_ESCAPE);
    if (esc) {
        this->game->quit();
    }

    NState::update(dt);
}
```

{'fraction_non_alphanumeric': 0.11904019943907759, 'fraction_numerical': 0.014334683702087878, 'mean_word_length': 3.8710166919575113, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6140652', 'n_tokens_mistral': 1142, 'n_tokens_neox': 1053, 'n_words': 361}