Skip to content

Small 2D Library to make pixel art game by code with Unity. API is heavily inspired by Pico-8.

License

Notifications You must be signed in to change notification settings

lochrist/UniSpritz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spritz

What?

This is a 2D Library that can be used to create simple Pixel Art Games. The API is heavily influenced by Pico-8.

Why?

I like to code. I like Pixel Art games. Unity is a tremendous editor but its workflows are based on a lot of implicit systems. A few years ago I discovered Pico-8 which is a whole development environment for a Fantasy Console. I immedialy liked how tight and focus the Pico-8 API was. You have control over everything. And you need to code everything! That said, I am not the biggest fan of Pico-8 development environment (and of Lua). I prefer C# and Visual Studio if I need to debug complicated code.

Hence why I created Spritz. This is a simple API to create Pixel Art games. It supports drawing pixels, sprites and basic shapes. It also supports playing sounds and that's about it!

What it is not?

This is not a straight port of Pico-8. There are no sprite editor, tile map editor or integrated development environment. Unity already supports this kind of tooling. There are no restriction on the game resolution, code tokens, sprite size or anything. In Fantasy Console world these arbitrary limitations help breed creativity. For myself I wanted to have a small code driven library to create any kind of pixel art games. I will chose my own restrictions :)

Why Spritz?

Since Spritz is mainly used to make games with Sprites:

Sprites -> Spritez -> Spritz

How?

If you want to create a new SpritzGame you can use the specifically designed Spritz Game Scene Template:

  1. Go to Menu -> New Scene (or press Ctrl + N)
  2. Chose the New Spritz Game scene template.
  3. Select a folder to save your game and give it a name. This will create a new scene and a new script (with the same name) that will allow you to start coding your game.
  4. Open the script, override the functions InitializeSpritz, UpdateSpritz, DrawSpritz and start coding!

this is it

Show me the code:

Here is the code of the Hello World example:

using UniMini;
using UnityEngine;

public class HelloWorld : SpritzGame
{
    SpriteId m_Heart;
    AudioClipId m_Music;
    string[] text = { "H", "e", "l", "l", "o", " ", "W", "o", "r", "l", "d", "!" };
    public override void InitializeSpritz()
    {
        Spritz.CreateLayer("Spritesheets/hello_spritesheet");
        Spritz.LoadSoundbankFolder("Audio");
        m_Music = new AudioClipId("hello");
        m_Heart = new SpriteId("heart");

        Spritz.PlayMusic(m_Music, 0.5f, true);
    }

    public override void UpdateSpritz()
    {
        
    }

    // This is the same Hello World as Pico-8. Thanks Zep.
    public override void DrawSpritz()
    {
        Spritz.Clear(Color.black);
        var pal = Spritz.palette;
        for (var col = 14; col >= 7; --col)
        {
            for (var i = 0; i < text.Length; ++i)
            {
                var t1 = Time.realtimeSinceStartup * 30 + i*4 - col*2;
                var x = 8 + (i + 1) * 8 + SpritzUtil.Cosp8(t1/90) * 3;
                var y = 38 + (col - 7) + SpritzUtil.Cosp8(t1/50) * 5;
                Spritz.Print(text[i], (int)x, (int)y, pal[col]);
            }
        }

        Spritz.Print("This is Spritz", 34, 70, pal[14]);
        Spritz.Print("Keep it fresh", 34, 80, pal[12]);
        Spritz.DrawSprite(m_Heart, 60, 90);
    }
}

Inspirations

This small project owns a lot of inspiration to some truly superb projects over the web:

  • Pico-8 : The original Fantasy Console. Thriving communities full of new games. I ported a lot of the builtin demos of Pico-8 as Spritz examples.
  • RetroBlit: this incredible Unity Asset does everything Spritz does and more! It showed me that Unity can be a good host to code driven Pixel Art game development. Go and buy this package!
  • Oryx Design lab : This creator sells a lot of cool and inspirationnal sprites.

Credits

About

Small 2D Library to make pixel art game by code with Unity. API is heavily inspired by Pico-8.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published