Log In  
Follow
stefvdw

Cart #bezzy-0 | 2019-07-18 | Code ▽ | Embed ▽ | No License
7


Hi guys,

I was working on a train game when it hit me that i have no idea how to make a smooth curve.
So I came across bezier curves and after reading some math articles I managed to write a function myself.
Even though many other people have shared thier version here is my bezier curve, with only a single control point sadly (I will figure out the rest later).

Here is the code i have tried to make it very eazy to implement into other projects (since I was gonna use it for my train haha).


function lv(v1,v2,t)
    return (1-t)*v1+t*v2
end

--Quadratic Bezier Curve Vector
function qbcvector(v1,v2,v3,t) 
    return  lv(lv(v1,v3,t), lv(v3,v2,t),t)
end

--draw Quadratic Bezier Curve
--x1,y1 = starting point 
--x2,y2 = end point
--x3,y3 = 3rd manipulating point 
--n = "amount of pixels in curve"(just put it higher than you expect)
--c = color
function drawqbc(x1,y1,x2,y2,x3,y3,n,c)
    for i = 1,n do 
        local t = i/n
       pset(qbcvector(x1,x2,x3,t),qbcvector(y1,y2,y3,t),c)
    end
end

[ Continue Reading.. ]

7
2 comments



Cart #boaty-2 | 2019-06-21 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1


Hi, I wanted to make a pirate game and I thought it would be cool if there were actual sailing mechanics.
So I decided that I would start with that.
I'm quite happy with the results so far but would no like to add land, birds and also make a bigger ship with some cannons or something.But i think the basics are here.

--controls
left and right - sailing
Z - sail up or down

If you have any suggestions feel free to give them.

1
1 comment



Cart #space_race-3 | 2019-02-17 | Code ▽ | Embed ▽ | No License
2

its gonna be a race

update:I added more sattelites and a cow (very productive I know).
Still thinking about the gameplay, I think I am going to make them be able to bump into eachother and collide with astroids and maybe sattelites aswell. and when they eventually get to the moon. maybe do a moonlander mini-game or something.

2
4 comments