turtle 0.0.3

Tiny game engine for creative Friday programming.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

<img alt="logo" src="https://raw.githubusercontent.com/p0nce/turtle/master/logo.png" width="200">

turtle

The turtle package provides a friendly, software-rendered, and hi-DPI drawing solution, for when all you want is a Canvas API. It depends on SDL for windowing.

Example

#!/usr/bin/env dub
/+ dub.sdl:
    name "minimal"
    dependency "turtle" version="~>0.0"
+/
import turtle;

int main(string[] args)
{
    runGame(new Minimal);
    return 0;
}

class Minimal : TurtleGame
{
    override void load()
    {
        setBackgroundColor( color("#6A0035") );
    }

    override void draw()
    {
        foreach(layer; 0..8)
            with(canvas)
            {
                save();

                translate(windowWidth / 2, windowHeight / 2);
                float zoom = windowHeight/4 * (1.0 - layer / 7.0) ^^ (1.0 + 0.2 * cos(elapsedTime));
                scale(zoom, zoom);
                rotate(layer + elapsedTime * (0.5 + layer * 0.1));
                fillStyle = color( 255 - layer * 32, 64 + layer * 16, 128, 255);

                beginPath();
                    moveTo(-1, -1);
                    lineTo( 0, -3);
                    lineTo(+1, -1);
                    lineTo(+3,  0);
                    lineTo(+1, +1);
                    lineTo( 0, +3);
                    lineTo(-1, +1);
                    lineTo(-3,  0);
                closePath();
                fill();

                restore();
            }
    }
}
Dependencies:
dplug:canvas, dplug:math, bindbc-sdl
Versions:
0.0.5 2021-Apr-10
0.0.4 2021-Apr-10
0.0.3 2021-Apr-10
0.0.2 2021-Apr-09
~master 2021-May-03
Show all 5 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 3 downloads this month

  • 5 downloads total

Score:
0.5
Short URL:
turtle.dub.pm