Glimmr Canvas Editor

version 1/100805 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Part - New Sprite Creation from Library

    A clicking graphlink rule when the current graphlink window is the paging-window (this is the clicking in pager rule):
        if the click hit a hot link:
            if the current graphlink is:
                -- Page-right_button: increase current-page by 1;
                -- Page-left_button: decrease current-page by 1;
            follow the window-drawing rules for the library-window;
            follow the window-drawing rules for the paging-window;
            rule succeeds.

    A clicking graphlink rule when the current graphlink window is the library-window (this is the clicking in library rule):
        if the click hit a hot link:
            now glulx replacement command is "CREATE NEW SPRITE";
            rule succeeds;
        now glulx replacement command is "";
        
    Spawning sprites is an action applying to nothing. Understand "spawn new sprite" or "create new sprite" or "create new" or "spawn new" as spawning sprites.

    Check spawning sprites:
        if the command is mouse-generated:
            continue the action;
        otherwise:
            say "[bracket]That command is reserved for the editor.[close bracket][paragraph break]You may click on an image in the library window to create a new sprite from the library image.";
            rule fails;

    Carry out spawning sprites:
        create a new sprite from the current graphlink in the working window;
        update the status line;
        rule succeeds;

    To create a new sprite from (S - a sprite) in (win - a g-window):
        increase the instance-counter of S by 1;
        let the new sprite be a new object cloned from S;
        now the new sprite is standard;
        change the associated canvas of the new sprite to the associated canvas of win;
        unlink the element-name of the new sprite;
        replace the text "_\d+$" in the element-name of the new sprite with "_[instance-counter of S]";
        replace the text " " in the element-name of the new sprite with "_";
        now the new sprite is standard;
        unlink the of-kind of the new sprite;
        unlink the tag of the new sprite;
        [now the of-kind of the new sprite is the kind-flag of S;***]
        unlink the replacement-command of the new sprite;
        change the x-scaling factor of the new sprite to the default scaling factor;
        change the y-scaling factor of the new sprite to the default scaling factor;
        change the display-layer of the new sprite to the current display-layer;
        unlink the origin of the new sprite;
        let xx be the canvas-width of the associated canvas of win;
        let yy be the canvas-height of the associated canvas of win;
        let x-img be the image-width of the image-ID of the new sprite real times the x-scaling factor of the new sprite as an integer;
        let y-img be the image-height of the image-ID of the new sprite real times the y-scaling factor of the new sprite as an integer;
        let x be (xx divided by 2) minus (x-img divided by 2);
        let y be (yy divided by 2) minus (y-img divided by 2);
        change entry 1 of the origin of the new sprite to x;
        change entry 2 of the origin of the new sprite to y;
        say "New sprite [element-name of new sprite] created from [image-ID of S].";
        change element-selection set to {};
        add new sprite at entry 1 in the element-selection set;
        follow the window-drawing rules for win;
        [follow the window-drawing rules for the layers-window;]