PreviousUpNext

15.4.1363  src/lib/x-kit/tut/badbricks-game/brick-junk.pkg

## brick-junk.pkg

# Compiled by:
#     src/lib/x-kit/tut/badbricks-game/badbricks-game-app.lib


stipulate
    include package   threadkit;                                # threadkit             is from   src/lib/src/lib/thread-kit/src/core-thread-kit/threadkit.pkg
    #
    package g2d=  geometry2d;                                   # geometry2d            is from   src/lib/std/2d/geometry2d.pkg

    package xc =  xclient;                                      # xclient               is from   src/lib/x-kit/xclient/xclient.pkg
herein

    package  brick_junk
    :        Brick_Junk                                         # Brick_Junk            is from   src/lib/x-kit/tut/badbricks-game/brick-junk.api
    {
        brick_size_high = 16;
        brick_size_wide = 48;

        brick_font = "-adobe-helvetica-medium-r-normal--10-100-*-*-p-56-iso8859-1";

        Difficulty = EASY
                   | NORMAL
                   | HARD
                   | DESPERATE
                   | RIDICULOUS
                   | ABSURD
                   ;

        difficulty_list
            =
            [ EASY, NORMAL, HARD, DESPERATE, RIDICULOUS, ABSURD ];

        Range = SHORT | LONG;

        Palette
            =
            { brick:            xc::Rgb,
              mark:             xc::Rgb,
              concrete:         xc::Rgb,
              dark_lines:       xc::Rgb,
              light_lines:      xc::Rgb,
              highlight_lines:  xc::Rgb
            };

        fun difficulty_probability d
            = 
            case d
                #
                EASY       => 15;
                NORMAL     => 20;
                HARD       => 25;
                #
                DESPERATE  => 30;
                RIDICULOUS => 40;
                ABSURD     => 50;
            esac;

        fun difficulty_name d
            = 
            case d
                #
                EASY       => "Easy";
                NORMAL     => "Normal";
                HARD       => "Hard";
                DESPERATE  => "Desperate";
                RIDICULOUS => "Ridiculous";
                ABSURD     => "Absurd";
            esac;

        fun cmp_difficulty (d1, d2)
            = 
            difficulty_probability d1
            -
            difficulty_probability d2;

        State = NO_BRICK_STATE
              | UNKNOWN_STATE
              | OK_STATE
              | BAD_STATE Int           # Number of good brick neighbors.
              ; 

        fun state_val NO_BRICK_STATE    => -3;
            state_val UNKNOWN_STATE     => -2;
            state_val OK_STATE          => -1;
            state_val (BAD_STATE count) =>  count;
        end;

        Position = g2d::Point;


        fun west_of      ({ col, row } ) =  { col=>col - 1,           row=>row     };
        fun northwest_of ({ col, row } ) =  { col=>col - 1+(row % 2), row=>row - 1 };
        fun northeast_of ({ col, row } ) =  { col=>col +   (row % 2), row=>row - 1 };
        fun east_of      ({ col, row } ) =  { col=>col+1,             row=>row     };
        fun southeast_of ({ col, row } ) =  { col=>col +   (row % 2), row=>row + 1 };
        fun southwest_of ({ col, row } ) =  { col=>col - 1+(row % 2), row=>row + 1 };


        Mse_Evt = DOWN (xc::Mousebutton, Position)
                | UP   (xc::Mousebutton, Position)
                | CANCEL Position
                ;

    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext