Another competition, a long time ago, in a galaxy far away...

@West = winner.

Deadline is the end of the year…

That’s true! But this idea can’t be stolen anymore. If someone will make the graphics better and more 3d and another picture, but this is nearly impossible in 10 days…

Here’s a very simple physics bb8.

Use the background from above plus here’s the head and body sprites

http://imgur.com/2Yvp7BV
http://imgur.com/w2j7Bu3

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

-- Bb8
--By West
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    size=100
    bbody=physics.body(CIRCLE,size)
    bbody.x=WIDTH/2
    bbody.y=HEIGHT
    physics.body(EDGE,vec2(0,30),vec2(WIDTH,30))
    physics.body(EDGE,vec2(0,30),vec2(0,HEIGHT))
    physics.body(EDGE,vec2(WIDTH,30),vec2(WIDTH,HEIGHT))
    bbody.restitution=0.2
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color
    background(40, 40, 50)
    sprite("Project:background",WIDTH/2,HEIGHT/2)
    noStroke()
    fill(163, 82, 30, 255)
    rect(0,0,WIDTH,30)
    physics.gravity(Gravity)
    -- This sets the line thickness
    strokeWidth(5)
    pushMatrix()
    translate(bbody.x,bbody.y)
    rotate(bbody.angle)
    sprite("Project:bb8body",0,0,2*size)
    popMatrix()
    sprite("Project:bb8head",bbody.x,bbody.y+size,2*size)
end

setting the standard there, @West! <3

Hey everyone, have an X-wing with R2 unit for Christmas!

Looks pretty sweet in wireframe mode too:

Code here: https://github.com/Utsira/Codea-OBJ-Importer

Model is a CC-BY licence, so you’re free to use it in your projects as long as you credit the creator, PixelOz

http://www.blendswap.com/blends/view/50244

Not sure I’ll have time to do much more with this before the end of year deadline. I was thinking of maybe doing an animated storm trooper

@yojimbo2000 wow, that’s pretty awesome. Detailed model. How are you rendering the wire version?

:o :o :o

With a wireframe shader I ported. It uses the standard derivatives GLES 2.0 add-on (which I guess is included as part of the standard library in 3.0):

wireframe.vert = [[
uniform mat4 modelViewProjection;
attribute vec4 position;
attribute vec4 color;
attribute vec3 normal;
varying highp vec4 vColor;
varying highp vec3 vNormal;
void main(void) {
    vColor = color;
    vNormal = normal;
    gl_Position = modelViewProjection * position;
}]]

wireframe.frag = [[
#extension GL_OES_standard_derivatives : enable
uniform highp float strokeWidth;
varying highp vec4 vColor;
varying highp vec3 vNormal;
void main(void) {
    highp vec4 col = vColor;
    if (!gl_FrontFacing) col.rgb *= 0.5; //darken rear-facing struts
    highp vec3 d = fwidth(vNormal);    
    highp vec3 tdist = smoothstep(vec3(0.0), d * strokeWidth, vNormal); 
    //2 methods: 1. discard method: best way of ensuring back facing struts show through
    if (min(min(tdist.x, tdist.y), tdist.z) > 0.5) discard; 
    else gl_FragColor = mix(col, vec4(col.rgb, 0.), -0.5 + 2. * min(min(tdist.x, tdist.y), tdist.z)); // anti-aliasing
    
    //2. alpha method means some rear faces wont show. Would be good for a "solid" mode though
    //gl_FragColor = mix(col, vec4(0.), min(min(tdist.x, tdist.y), tdist.z)); 
}]]

Fab @yojimbo2000 - the force is strong with this one!

:slight_smile:
And the winner is…
[edit] just got the code: perfect install, perfect smoothness, perfect rendering…
And the winner is…

Turning bb8 into a game - tap to jump. Something up with the physics though - sometimes falls through the platforms, sometimes passes through the screen edge. What am I missing?

-- Bb8
--By West
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
    size=25
    bbody=physics.body(CIRCLE,size)
    bbody.x=WIDTH*0.05
    bbody.y=HEIGHT
    bbody.bullet=true

    physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
    physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
    bbody.restitution=0.2
    platform={}
    platform[1]={x1=0,y1=HEIGHT*0.8,x2=WIDTH*0.5,y2=HEIGHT*0.8}
    platform[2]={x1=WIDTH*0.6,y1=HEIGHT*0.8,x2=WIDTH,y2=HEIGHT*0.8}
    platform[3]={x1=WIDTH*0.2,y1=HEIGHT*0.6,x2=WIDTH,y2=HEIGHT*0.6}
    platform[4]={x1=0,y1=HEIGHT*0.4,x2=WIDTH*0.3,y2=HEIGHT*0.4}
    platform[5]={x1=WIDTH*0.4,y1=HEIGHT*0.4,x2=WIDTH*0.6,y2=HEIGHT*0.4}
    platform[6]={x1=WIDTH*0.7,y1=HEIGHT*0.4,x2=WIDTH,y2=HEIGHT*0.4}
    platform[7]={x1=WIDTH*0.2,y1=HEIGHT*0.2,x2=WIDTH,y2=HEIGHT*0.2}
    platform[8]={x1=0,y1=HEIGHT*0.05,x2=WIDTH,y2=HEIGHT*0.05}
    for i,p in pairs(platform) do
        plat=physics.body(POLYGON,vec2(p.x1,p.y1),vec2(p.x2,p.y1),vec2(p.x2,p.y2-10),vec2(p.x1,p.y2-10))
        plat.type=STATIC
    end
    obj={}
    obj[1]={x=WIDTH*0.9,y=HEIGHT*0.85}
    obj[2]={x=WIDTH*0.35,y=HEIGHT*0.65}
    obj[3]={x=WIDTH*0.85,y=HEIGHT*0.45}
    obj[4]={x=WIDTH*0.55,y=HEIGHT*0.25}
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color
    background(40, 40, 50)
    sprite("Project:background",WIDTH/2,HEIGHT/2)
    physics.gravity(Gravity)
    for i,b in pairs(obj) do
        sprite("Tyrian Remastered:Evil Head",b.x,b.y,3*size)
        if vec2(b.x,b.y):dist(vec2(bbody.x,bbody.y))<20 then
            bbody.x=WIDTH*0.05
            bbody.y=HEIGHT
        end
    end
    
    -- This sets the line thickness
    strokeWidth(5)
    pushMatrix()
    translate(bbody.x,bbody.y)
    rotate(bbody.angle)
    sprite("Project:bb8body",0,0,2*size)
    popMatrix()
    sprite("Project:bb8head",bbody.x,bbody.y+size,2*size)
    stroke(60, 78, 31, 255)
        for i,p in pairs(platform) do
        line(p.x1,p.y1,p.x2,p.y2)
    end
    
end

function touched(t)
    if t.state==ENDED then
        print(bbody.linearVelocity.y)
        if math.abs(bbody.linearVelocity.y)<1 then
        bbody:applyForce(vec2(0,600))
            end
    end
end

@West - You might need physics.continuous=true to make bullet work properly

You’re assigning all the platform polygons to the same variable plat. Only one assigned will be valid.

EDIT: Add the lines I show

    pl={}   -- add this
    for i,p in pairs(platform) do
        plat=physics.body(POLYGON,vec2(p.x1,p.y1),vec2(p.x2,p.y1),
            vec2(p.x2,p.y2-10),vec2(p.x1,p.y2-10))
        plat.type=STATIC
        table.insert(pl,plat)   -- add this
    end

These additions and changes can be made to setup(). The first 2 changes, e1 and e2 will fix the sides. EDGE can be used instead of POLYGON for the platforms.

function setup()
    size=25
    bbody=physics.body(CIRCLE,size)
    bbody.x=WIDTH*0.05
    bbody.y=HEIGHT
    bbody.bullet=true

    e1=physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))  -- changed
    e2=physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))  -- changed
    
    bbody.restitution=0.2
    platform={}
    platform[1]={x1=0,y1=HEIGHT*0.8,x2=WIDTH*0.5,y2=HEIGHT*0.8}
    platform[2]={x1=WIDTH*0.6,y1=HEIGHT*0.8,x2=WIDTH,y2=HEIGHT*0.8}
    platform[3]={x1=WIDTH*0.2,y1=HEIGHT*0.6,x2=WIDTH,y2=HEIGHT*0.6}
    platform[4]={x1=0,y1=HEIGHT*0.4,x2=WIDTH*0.3,y2=HEIGHT*0.4}
    platform[5]={x1=WIDTH*0.4,y1=HEIGHT*0.4,x2=WIDTH*0.6,y2=HEIGHT*0.4}
    platform[6]={x1=WIDTH*0.7,y1=HEIGHT*0.4,x2=WIDTH,y2=HEIGHT*0.4}
    platform[7]={x1=WIDTH*0.2,y1=HEIGHT*0.2,x2=WIDTH,y2=HEIGHT*0.2}
    platform[8]={x1=0,y1=HEIGHT*0.05,x2=WIDTH,y2=HEIGHT*0.05}
    
    pl={}   -- add this
    for i,p in pairs(platform) do
        plat=physics.body(EDGE,vec2(p.x1,p.y1),vec2(p.x2,p.y2)) -- changed
        table.insert(pl,plat)   -- add this
    end
    
    obj={}
    obj[1]={x=WIDTH*0.9,y=HEIGHT*0.85}
    obj[2]={x=WIDTH*0.35,y=HEIGHT*0.65}
    obj[3]={x=WIDTH*0.85,y=HEIGHT*0.45}
    obj[4]={x=WIDTH*0.55,y=HEIGHT*0.25}
end

@dave1707 - doh of course! Many thanks!

I added a stormtrooper helmet:

model by matpiet, mofx: http://www.blendswap.com/blends/view/77957 Licence: CC-BY

It has a texture, but weirdly it appears to be inside out (when viewed in Blender too): all the details seem to be on the inside of the helmet.

aaaaaaaargh! Awsome!

Perhaps the details are on the inside because the storm trooper can’t see out of the eyeholes.

Here’s a fairly simple arcade game
https://www.youtube.com/watch?v=jJQ6UkFQvWE

And here is the code, if you want to play with it.

You need this image, saved in Dropbox as “starwars”
https://drive.google.com/open?id=0By-wnjsdtus1OC1DZlFicUd6V1E