Log In  
Follow
SophieHoulden

Hi, I make games.

[ :: Read More :: ]

Cart #vgfx_demo-1 | 2024-03-23 | Embed ▽ | License: CC4-BY-NC-SA
1


(click for different demos)

I want to make a game using vector animations so I got started on a way for drawing that.

Main tips for speedy drawing:

  • Scaling/rotating is slower
  • More vector sprites is slower
  • Bigger vector sprites is slower
  • More triangles is MUCH slower

code here:

--[[ vgfx.lua
vector graphics drawing

=== todo: ===
-more triangulation functions
-tween/interpolate between two vector sprites/polygons
-animation playback
-compression for vector data
-maybe look into userdata for optimisations
-maybe try writing directly to graphics memory if it's faster

also:
-make a vector sprite editor/animator app

=== docs: ===
"vector sprite": an array of polygons
"polygon": an array with 3 elements: color 1, color 2, vertices
"vertices": array of numbers (x0,y0, y1,y2, ...etc)

vertices list should be triangulated, sprv() will NOT triangulate arbitrary polygons

tri() and triraster() are decent triangle drawing functions, for lightweight
vector drawing, skip the vector sprite stuff and just use these

]]

vgfx_wire=false--enable for debug view of polygon triangles
vgfx_precise=false--enable if you have issues with edge seams

function make_polygon(col1,col2, verts)
    return {col1,col2,verts}
end

--vector sprite expectations:
-- array of polygons
-- each polygon is an array with:
--  color1, color2, vertices
--vertices expectations:
-- array of numbers (x0,y0, y1,y2, ...etc)
-- should be triangulated already - each three vertices will be drawn as a tri

--draw a vector sprite
function sprv(v, x,y, rot,scale, col)
    local s, cs = 0,0
    if rot and rot!=0 then
        s = sin(rot)
        cs = cos(rot)
    end

    if (col) color(col)
    for p=1,#v do--loop through each polygon in the vector sprite

        --prep to draw this polygon's colours
        if not col then
            fillp(0b1010010110100101)
            color((v[p][1]<<8)+v[p][2])
        end

        --third item in each polygon is a list of vertices (triangulated!)
        local t = v[p][3] 

        --draw each tri now
        local b=0
        local l=#t/6
        local v0 = {}
        local v1 = {}
        local v2 = {}
        for i=1, l do
            if rot and rot!=0 then
                v0 = rotvert(t[1+b],t[2+b],s,cs)
                v1 = rotvert(t[3+b],t[4+b],s,cs)
                v2 =rotvert(t[5+b],t[6+b],s,cs)
            else
                v0 = {x=t[1+b],y=t[2+b]}
                v1 = {x=t[3+b],y=t[4+b]}
                v2 = {x=t[5+b],y=t[6+b]}
            end

            if scale and scale!=1 then
                tri(x+v0.x*scale,y+v0.y*scale, x+v1.x*scale,y+v1.y*scale, x+v2.x*scale,y+v2.y*scale)
            else
                tri(x+v0.x,y+v0.y, x+v1.x,y+v1.y, x+v2.x,y+v2.y)
            end
            b+=6
        end
    end
    return tris
end

function rotvert(x,y,s,c)
    local v={}
    v.x=x*c-y*s
    v.y=x*s+y*c
    return v
end

function fan_triangulate(points)
    local v,i={},3
    while i<=#points do
        add(v,points[i].x)
        add(v,points[i].y)
        add(v,points[i-1].x)
        add(v,points[i-1].y)
        add(v,points[1].x)
        add(v,points[1].y)
        i+=1
    end
    return v
end

function strip_triangulate(points)
    if (#points<=3) return points

    local v,i={},4
    add(v,points[1].x)
    add(v,points[1].y)
    add(v,points[2].x)
    add(v,points[2].y)
    add(v,points[3].x)
    add(v,points[3].y)
    while i<=#points do
        add(v,points[i].x)
        add(v,points[i].y)
        add(v,points[i-1].x)
        add(v,points[i-1].y)
        add(v,points[i-2].x)
        add(v,points[i-2].y)
        i+=1
    end
    return v
end

vgfx_trisdrawn=0
function tri(x0,y0, x1,y1, x2,y2)
    vgfx_trisdrawn += 1

    if (vgfx_precise)   x0,y0,x1,y1,x2,y2 = flr(x0),flr(y0),flr(x1),flr(y1),flr(x2),flr(y2)

    --wireframe
    if vgfx_wire then
        fillp()
        line(x0,y0, x1,y1, 7)
        line(x1,y1, x2,y2, 7)
        line(x2,y2, x0,y0, 7)
        return
    end

    --order the vertices so they are descending from top to bottom
    --we need this since we are drawing it as two triangles:
    --one with a flat base, one with a flat top
    if (y1<y0) x0,x1=x1,x0; y0,y1=y1,y0
    if (y2<y0) x0,x2=x2,x0; y0,y2=y2,y0
    if (y2<y1) x1,x2=x2,x1; y1,y2=y2,y1

    --draw the top half
    local hh=y1-y0--height of the half
    local x3=x0+hh*(x2-x0)/(y2-y0)--slicing the tri in two makes another vertex
    if (y0!=y1) triraster(y0,y1, (x3-x0)/hh,(x1-x0)/hh, x0,x0)

    --draw the bottom half
    hh=y2-y1
    if (y1!=y2) triraster(y1,y2, (x2-x1)/hh,(x2-x3)/hh, x1,x3)
end

--draws a filled triangle line-by-line, top-to-bottom
--args: top, bottom, step left, step right, left pixel, right pixel
function triraster(t,b, sl,sr, pl,pr)
    for y=t,b do
        rectfill(pl,y,pr,y)
        pl+=sl
        pr+=sr
    end
end

P#144124 2024-03-22 11:49 ( Edited 2024-03-26 19:59)

[ :: Read More :: ]


load #enview-2
// to load from inside Picotron

The largest part of this work is based on pancelor's api explorer

It has some improvements like sub-tables being sorted, and not printing text above/below the screen.
Also I made some style changes to try and get it to gel with the OS as a windowed app.

I'd like to have it so clicking on a function shows you what parameters it expects, but honestly I have no idea if that's a thing you can even query in lua.

I may hard-code stuff so it gives an authored explanation of each item and how to use it, but right now it just lists the stuff and nothing else.

anyway I'm still very much learning picotron (which is why I wanted a nice API list I can quickly check in the GUI) so things might not be ideal.

P#143554 2024-03-17 18:58 ( Edited 2024-03-18 18:44)

[ :: Read More :: ]


load #duskchild_wp-0
// to load from inside Picotron

An animated wallpaper using graphics from Dusk Child.

Made just to learn picotron a little bit, and it was fun!

P#143345 2024-03-16 17:47 ( Edited 2024-03-16 17:48)

[ :: Read More :: ]

Cart #rotslimepires_1_1-0 | 2022-04-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
178

Hi! It's been a while since I have finished a pico-8 game to be able to share it here, but this is one!

The controls are Z/C to Jump, and X/V = Shoot (or respawn if you become a slimepire)


~ Story: ~
Years after the horde have claimed Earth's surface, they find their way into Bunker 4103 - the last bastion of humanity. You awake in a remote part of the underground shelter, and if you want to remain human you must reach the bunker's deepest point: the safe room.


~ Extras ~
You can tip $3 or more on itch.io for access to extra goodies: illustrated & pixel maps, a comprehensive manual, and also a 2 hour video of me talking through the game project and its code.


~ Links: ~
Return of the SLIMEPIRES! on itch.io
My Patreon - supports things like this <3
Development thread on twitter

P#110276 2022-04-15 10:46

[ :: Read More :: ]

Cart #47742 | 2017-12-29 | Code ▽ | Embed ▽ | No License
106

Originally made for Ludum Dare 40, then upgraded a bunch for my patrons, now available for everyone! <3

The vector drawing/animation on the title screen is based on Gabriel Crowe's systems found >here<.


~ Links: ~
Curse of Greed on itch.io
My Patreon - supports things like this ;)


~ Changelog: ~
Curse of Greed - Ludum Dare Release
Ultimate 1.0 - New levels, difficulties, fixes & improvements, title effects

P#47743 2017-12-29 06:16 ( Edited 2018-01-12 07:04)

[ :: Read More :: ]

Cart #45961 | 2017-11-07 | Code ▽ | Embed ▽ | No License
70

It's a platformer, a difficult one!

I made this in 3 days for my patrons as a Halloween gift, then took an extra day to polish it up and include some spooOOooky music by Tim Monks. Now it's available for everyone, hooray!

Good luck, little pumpkin!


~ Links: ~
Pumpking on itch.io
My Patreon - supports things like this ;)


~ Changelog: ~
1.0 Patreon release
1.1 first public release (Game improvements, added music by Tim Monks, extra boss stages)
1.1a Commented all code for learners, made small background improvements, better cartridge label.

P#45827 2017-11-03 10:18 ( Edited 2018-10-25 19:37)

[ :: Read More :: ]

Cart #41286 | 2017-06-04 | Code ▽ | Embed ▽ | No License
79

~ Story: ~
Oh no! Zaks the evil wizard has once again captured Dizzy's girlfriend, Daisy! And the other yolkfolk need help too, looks like another adventure for Dizzy!

~

~ Controls: ~
[ Left ]/[ Right ] - Move
[ Z ] - Jump
[ Down ] - Drop from ledge
[ Up ] - Cycle through inventory
[ X ] - Interact/pick up item/drop item

~

~ Music: ~
Huge thanks to @gruber_music for making a brilliant pico-8 version of the Amiga Magicland Dizzy theme :D

~

~ About: ~
I wanted there to be a Dizzy game for Pico-8, so now there is! Heads up though; I've tried to be faithful to the classic Dizzy games - that means limited lives, rubbish platforming, cheesy dialogue and a kidnapped damsel.

Obviously this is a fan project and not an official dizzy game, they don't make those anymore :(

~

~ Changelog: ~
beta1: First Release
beta2: Added music & minor fixes
1.0: Animated water

P#41037 2017-05-27 04:58 ( Edited 2017-05-27 08:58)

[ :: Read More :: ]

Cart #39705 | 2017-04-15 | Code ▽ | Embed ▽ | No License
360

Controls:
Z - Examine/Pick-up/Drop
X - (not used until later in the game)
Up - Jump
Down - Duck/Crawl
Left/Right - Move

Story:
You have been drawn to a mysterious place, what secrets does it hold, and what will they mean for you?

Help:
When not carrying an item, you can examine things. If you're stuck, try examining signs and other objects.
When you have explored far enough into the western temple, you can use the 'X' button.


I'm calling this "done" though there are a few things I might touch up in the future. Right now though, I've spent too long working on this already and need to get back to work on things that stand a chance of making some money :P


1.4: fixed map initialisation corrupting some sprites
1.3: fixed a bug & added some minor text
1.2: fixed special effects rendering wrong in newer pico-8 builds
1.1: fixed a couple of bugs
1.0: first version

P#12682 2015-08-15 11:11 ( Edited 2018-04-17 23:45)

Follow Lexaloffle:          
Generated 2024-03-28 10:15:52 | 0.105s | Q:35