All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.nighttripperid.engine.Font5x5 Maven / Gradle / Ivy

Go to download

LittleEngine, a Lightweight Java Game Engine to be pulled in as Maven dependency

The newest version!
package com.github.nighttripperid.engine;

/**
 * Character arrays that represent a 5x5 Font for convenience. Used by Screen.
 *
 */
class Font5x5 {

    private Font5x5() {
    }

    private static final char[] A = { 0 ,'#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#','#','#','#', 0 ,
                                     '#', 0 , 0 ,'#', 0

    };

    private static final char[] B = { '#','#','#', 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#','#','#', 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#','#','#', 0 , 0

    };

    private static final char[] C = {  0 ,'#','#', 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                       0 ,'#','#', 0 , 0

    };

    private static final char[] D = {'#','#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#','#','#', 0 , 0
    };

    private static final char[] E = {'#','#','#','#', 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                     '#','#','#', 0 , 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                     '#','#','#','#', 0
    };

    private static final char[] F = {'#','#','#','#', 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                     '#','#','#', 0 , 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                     '#', 0 , 0 , 0 , 0
    };

    private static final char[] G = {  0 ,'#','#', 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                       0 ,'#','#','#', 0

    };

    private static final char[] H = { '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#','#','#','#', 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 ,'#', 0
    };

    private static final char[] I = {'#','#','#','#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                     '#','#','#','#', 0
    };

    private static final char[] J = {'#','#','#','#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                     '#', 0 ,'#', 0 , 0 ,
                                     '#','#','#', 0 , 0
    };

    private static final char[] K = {'#', 0 , 0 ,'#', 0 ,
                                     '#', 0 ,'#', 0 , 0 ,
                                     '#','#', 0 , 0 , 0 ,
                                     '#', 0 ,'#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0
    };

    private static final char[] L = { '#', 0 , 0 , 0 , 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#','#','#','#', 0

    };

    private static final char[] M = { '#', 0 , 0 ,'#', 0 ,
                                      '#','#','#','#', 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 ,'#', 0 ,
                                      '#', 0 , 0 ,'#', 0

    };

    private static final char[] N = { '#', 0 , 0 , '#', 0 ,
                                      '#','#', 0 , '#', 0 ,
                                      '#', 0 ,'#', '#', 0 ,
                                      '#', 0 , 0 , '#', 0 ,
                                      '#', 0 , 0 , '#', 0

    };

    private static final char[] O = { 0 ,'#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                      0 ,'#','#', 0,  0
    };

    private static final char[] P = {'#','#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#','#','#', 0 , 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                     '#', 0 , 0 , 0 , 0
    };

    private static final char[] Q = { 0 ,'#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                      0 ,'#','#','#', 0 ,
    };

    private static final char[] R = {'#','#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#','#','#', 0 , 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
    };

    private static final char[] S = { 0 ,'#','#','#', 0 ,
                                     '#', 0 , 0 , 0 , 0 ,
                                      0 ,'#','#', 0 , 0 ,
                                      0 , 0 , 0 ,'#', 0 ,
                                     '#','#','#', 0 , 0 ,
    };

    private static final char[] T = {'#','#','#','#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0
    };

    private static final char[] U = {'#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     '#', 0 , 0 ,'#', 0 ,
                                     0 , '#','#', 0 , 0
    };

    private static final char[] V = { 0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 , 0 ,'#', 0 , 0

    };

    private static final char[] W = { 0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#','#','#', 0 ,
                                      0 ,'#', 0 ,'#', 0

    };

    private static final char[] X = { 0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,

    };

    private static final char[] Y = { 0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 ,'#', 0 ,'#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 , 0 ,'#', 0 , 0
    };

    private static final char[] Z = {'#','#','#','#', 0 ,
                                      0 , 0 , 0 ,'#', 0 ,
                                      0 , 0 ,'#', 0 , 0 ,
                                      0 ,'#', 0 , 0 , 0 ,
                                     '#','#','#','#', 0

    };

    private static final char[] _0 = { 0 ,'#','#','#',0 ,
                                      '#', 0 , 0 , 0 ,'#',
                                      '#', 0 , 0 , 0 ,'#',
                                      '#', 0 , 0 , 0 ,'#',
                                       0 ,'#','#','#', 0
    };

    private static final char[] _1 = { 0 , 0 ,'#', 0 , 0 ,
                                       0 , 0 ,'#', 0 , 0 ,
                                       0 , 0 ,'#', 0 , 0 ,
                                       0 , 0 ,'#', 0 , 0 ,
                                       0 , 0 ,'#', 0 , 0
    };

    private static final char[] _2 = { 0 ,'#','#','#', 0 ,
                                      '#', 0 , 0 , 0 ,'#',
                                       0 ,'#','#','#', 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#','#','#','#','#',
    };

    private static final char[] _3 = { 0 ,'#','#','#', 0 ,
                                      '#', 0 , 0 , 0 ,'#',
                                       0 , 0 ,'#','#', 0 ,
                                      '#', 0 , 0 , 0 ,'#',
                                       0 ,'#','#','#', 0
    };

    private static final char[] _4 = { '#', 0 , 0 , 0 ,'#',
                                       '#', 0 , 0 , 0 ,'#',
                                       '#','#','#','#','#',
                                        0 , 0 , 0 , 0 ,'#',
                                        0 , 0 , 0 , 0 ,'#',
                                        0 , 0 , 0 , 0 ,'#',
    };

    private static final char[] _5 = { '#','#','#','#','#',
                                       '#', 0 , 0 , 0 , 0 ,
                                       '#','#','#','#', 0 ,
                                        0 , 0 , 0 , 0 ,'#',
                                       '#','#','#','#', 0
    };

    private static final char[] _6 = { 0 ,'#','#','#', 0 ,
                                      '#', 0 , 0 , 0 , 0 ,
                                      '#','#','#','#', 0 ,
                                      '#', 0 , 0 , 0 ,'#',
                                       0 ,'#','#','#', 0

    };

    private static final char[] _7 = { '#','#','#','#','#',
                                        0 , 0 , 0 , 0 ,'#',
                                        0 , 0 , 0 ,'#', 0 ,
                                        0 , 0 ,'#', 0 , 0 ,
                                        0 , 0 ,'#', 0 , 0
    };

    private static final char[] _8 = {  0 ,'#','#','#', 0 ,
                                       '#', 0 , 0 , 0 ,'#',
                                        0 ,'#','#','#', 0 ,
                                       '#', 0 , 0 , 0 ,'#',
                                        0 ,'#','#','#', 0
    };

    private static final char[] _9 = {  0 ,'#','#','#', 0 ,
                                       '#', 0 , 0 , 0 ,'#',
                                       '#','#','#','#','#',
                                        0 , 0 , 0 , 0 ,'#',
                                       '#','#','#','#', 0

    };

    private static final char[] SPACE = { 0 , 0 , 0 , 0 , 0 ,
                                          0 , 0 , 0 , 0 , 0 ,
                                          0 , 0 , 0 , 0 , 0 ,
                                          0 , 0 , 0 , 0 , 0 ,
                                          0 , 0 , 0 , 0 , 0

    };

    static char[] getChar(char c){

        c = Character.toUpperCase(c);

        switch(c){
            case 'A':
                return Font5x5.A;
            case 'B':
                return Font5x5.B;
            case 'C':
                return Font5x5.C;
            case 'D':
                return Font5x5.D;
            case 'E':
                return Font5x5.E;
            case 'F':
                return Font5x5.F;
            case 'G':
                return Font5x5.G;
            case 'H':
                return Font5x5.H;
            case 'I':
                return Font5x5.I;
            case 'J':
                return Font5x5.J;
            case 'K':
                return Font5x5.K;
            case 'L':
                return Font5x5.L;
            case 'M':
                return Font5x5.M;
            case 'N':
                return Font5x5.N;
            case 'O':
                return Font5x5.O;
            case 'P':
                return Font5x5.P;
            case 'Q':
                return Font5x5.Q;
            case 'R':
                return Font5x5.R;
            case 'S':
                return Font5x5.S;
            case 'T':
                return Font5x5.T;
            case 'U':
                return Font5x5.U;
            case 'V':
                return Font5x5.V;
            case 'W':
                return Font5x5.W;
            case 'X':
                return Font5x5.X;
            case 'Y':
                return Font5x5.Y;
            case 'Z':
                return Font5x5.Z;
            case '0':
                return Font5x5._0;
            case '1':
                return Font5x5._1;
            case '2':
                return Font5x5._2;
            case '3':
                return Font5x5._3;
            case '4':
                return Font5x5._4;
            case '5':
                return Font5x5._5;
            case '6':
                return Font5x5._6;
            case '7':
                return Font5x5._7;
            case '8':
                return Font5x5._8;
            case '9':
                return Font5x5._9;
        }
        return Font5x5.SPACE;
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy