Log In  

Cart #outline_diverse-1 | 2022-03-16 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

TO LOAD THIS CART IN PICO-8, type in immediate mode, load #outline_diverse

Years ago when I first got the IBM-pc, I was quite interested in 8x8 pixel artwork and even though I was limited to black and white, I managed to write up a little paint program that self-modified GWBASIC to create strings of 8x8 pixeled images using multiple stringed plot() for each of the letters A-Z.

If instead I pressed the CTRL key followed by a letter I could enter in a new 1-bit 8x8 pixel definition or replace an old one. To save my 26-images I just saved the .BAS program.

Years later when color was introduced I modified my program and built from it a massive system called, "Tilemaster." The version for BlitzMAX I wrote I still use to today, and in it, I have a function I call Outline Diverse or (outdiv()).

In it take a single string of up to 9-characters and draws an outline for a sprite based upon a 3x3 field.

You of course are welcome to develop your own outlines, using the format for a single number:

256 128 064 ▄ ▄ ▄
032 016 008 ▄ ▄ ▄
004 002 001 ▄ ▄ ▄

[32x16]

For instance, this pattern creates what I called a BRICK shadow. It not only creates a shadow that is X+1 and Y+1 of the image but also X+1,Y+0 and X+0,Y+1. Doing so gives a more full outline. It's numerical equivalent is 8+2+1 or 11.

You can include the center square as well (16) to have the outline replace the actual image with a single color as well. This is useful to make enemy targets flash white or red or what have you. This choice is included in the demo above. GLOW lights up all 9-outline points and gives you not just your sprite turned to one-color but a perfect outline around it as well.

In execution:

Use the ⬅️ and ➡️ arrow keys to move the sprite left and right.
Use the ⬆️ and ⬇️ arrow keys to change the sprite image. You can make more if you like.
Use the 🅾️ key to change the outline type, be aware you can add your own.
Use the ❎ key to change the color of the outline, 16-color choices.

The CPU shows how much map() is taking with a / key showing actual CPU usage which is quite small at maximum 1%.

And there you have it !

The function included is called, outline() at 75 tokens or 176-chars and uses the following arguments:

function outline(s,x,y,t,c,h,v)
-- draw sprite outline using
-- the following variables:
-- s=sprite #
-- x=sprite's x-position
-- y=sprite's y-position

-- t=type of outline (binary)
--   this is a single number
--   from 0-511 thus:
--   256 128 064 █ █ █
--   032 016 008 █ █ █
--   004 002 001 █ █ █

-- c=color of outline
-- h=sprite size across, def 1
-- v=sprite size down  , def 1
-- (both variables of h + v
--  are optional)

H + V are optional and yes you can give a shadow or outline to a bigger sprite, just use a number greater than one for either H or V. H=2 and V=2 or instance will use a sprite that is 16x16 pixels.

If you have any questions, feel free to ask.

P#108762 2022-03-16 21:32 ( Edited 2022-03-17 03:37)


[Please log in to post a comment]