Tiny Wingsalike mechanic using Codea physics

Trying to reproduce the feel of tiny wings… touch to become more gravityish. Ipad 2 landscape. The ground is a little hard to see in the video, it’s a SIN curve…


function setup()
    displayMode(FULLSCREEN)
    --myFPSReporter = FPSReporter(4)
    noSmooth()
    
    points = {}
    for i=1,2000 do
        points[i] = vec2(i*20, math.sin(math.rad(i*20))*50+200)
    end
    slopes = physics.body(CHAIN, false, unpack(points))
    
    player = physics.body(CIRCLE, 15)
    player.restitution = .1
    player.x = 100
    player.y = HEIGHT - 200
    player.gravityScale = .5
    watch("CurrentTouch")
    watch("player.gravityScale")
end

function draw()
    background(0, 0, 0, 255)
    --myFPSReporter:draw(3)
    
    strokeWidth(1)
    scaleY = 1
    if player.y > HEIGHT-50 then
        scaleY = (HEIGHT - 50) / player.y
    end
    pushMatrix()
    scale(scaleY)
    pushMatrix()
    translate(200/scaleY, player.y)
    rotate(player.angle)

    ellipse(0, 0, player.radius*2)
    line(0,0,player.radius-2,0)   
    popMatrix()
    pushMatrix()
    translate((200/scaleY)-player.x,0)
    for k,v in pairs(slopes.points) do
        if v.x < (WIDTH-200)/scaleY+player.x and v.x > -200/scaleY+player.x then
            ellipse(v.x, v.y, 3)
        end    
    end
    popMatrix()
    popMatrix()
    if player.linearVelocity.x < 100 then
        player:applyForce(vec2(100,0))
    end
    if CurrentTouch.state < 2 then
        if CurrentTouch.y < HEIGHT/2 then
            player.gravityScale = 3
        elseif CurrentTouch.y > HEIGHT/2 then
            player.gravityScale = 0.2
        end
    else
        player.gravityScale = 0.4
    end    
end

Spiff. So are you going to add some objects that change the “frequency” ?

.@spacemonkey that’s great. And a surprisingly small amount of code for the result.

@spacemonkey looks really great.
Did something like this some months ago as well:
http://www.youtube.com/watch?v=QUPhlvq5Wz0

Nice! Especially for the small amount of code. Another tiny wings-like library:
http://twolivesleft.com/Codea/Talk/discussion/1267

This is my version

http://www.youtube.com/watch?v=cKYPzIs1rFA

The intro looks awesome!! @juaxix

Thanks, and yes, this is all Codea, I’m creating a new world that looks like Contre Jours too

Is all of that made in Codea?

Very nice intro