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.18 2024-Oct-16
0.0.17 2024-Jul-12
0.0.16 2024-May-24
0.0.15 2023-Aug-19
0.0.14 2022-Jul-22
Show all 18 versions
Download Stats:
  • 0 downloads today

  • 1 downloads this week

  • 9 downloads this month

  • 121 downloads total

Score:
1.5
Short URL:
turtle.dub.pm