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

@TokOut I’ve tidied it up a bit and turned into a single project. There are a couple of extra redundant lines which I’ve commented out and you also need to look up the reference for supportedOrientations.

Finally, I’m not really getting the Star Wars theme…

--displayMode(OVERLAY). --replaced by next line - not needed
displayMode(FULLSCREEN)
--this command is being used incorrectly - Landscape, portrait, etc are the correct parameters to use - look up the reference
-- supportedOrientations(WIDTH)

function setup()
    img=image(WIDTH,HEIGHT)
    --this next section replaces the second code and generates the image to be displayed
    setContext(img)
    translate(WIDTH/2,HEIGHT/2)
    z = 20
    zy = 25
    starship_table = {}
    lazer_table = {}
    background(0, 0, 0, 255)
    for x = -25, 25 do
        --    stars[x] = {} --doesn't do anything
        for y = -19, 18 do
            --         stars[x][y] = false - neither does this
            strokeWidth(2)
            stroke(255, 255, 255, 255)
            line(x * z, y * z - 2.5, x * z, y * z + 2.5)
            line(x * z - 2.5, y * z, x * z + 2.5, y * z)
        end
    end
    --starship
    sprite("Tyrian Remastered:Boss B")
    --lazer
    for y = 1, 14 do
        lazer_table[y] = false
        stroke(125, 200, 150, 255)
        strokeWidth(10)
        line(0, y * zy - 385, 0, y * zy - 375)
    end
    setContext()
    --end of image generation code
    rotation = 20
end

function draw()
    translate(WIDTH/2, HEIGHT/2)
    rotate(ElapsedTime * rotation)
    sprite(img, 0, 0)
end

Thx

How are we judging this thing? We could do a surveymonkey vote, like last time?

Actually, I think the winner should be based on Star Wars rules, which are that all the good guys using the Force always win.

Our force is Codea, which makes everybody is a winner, for sharing and having fun with it.

Uh-oh, but what if I’m on the dark side?

My guess is that the force won’t be with you

Teeing it up…how about judging it by size?

Ok, here’s the installer for my effort.

It was fun to make, and is pretty good fun to play too! The framerate does drop on the iPad Air when the action hots up (probably unplayable on older hardware), but not as much as I thought it would, given that the models, especially the tie fighter, are insanely detailed. That’s the problem with just grabbing stuff from Blender, it’s often too detailed for a game. If you spent a bit of time optimising it, and culling verts from the model, you could get it to consistent 60 fps on the Air, I’m sure.

If the force is strong with you, you can unlock retro mode!

(The tie fighters have so many verts that even in wireframe mode they look solid until you get really close!)

The wireframe shader is actually faster than the diffuse lighting shader, which is pretty cool. I might actually explore this more seriously in a project down the road, as it’s a cool aesthetic, and one you don’t really see right now.

Finally, I’m pretty pleased with this GitHub repo installer. It’s designed to be used with repositories created from Codea’s new zipped-project export feature. It grabs the correct file list from the info.plist file. It’s created by the new version of my WorkingCopyCodeaClient.

local url = "https://raw.githubusercontent.com/Utsira/Codea-OBJ-Importer/master/TrenchRun.codea/"
 
local function install(data)
    --parse plist into list of tab files
    local array = data:match("<key>Buffer Order</key>%s-<array>(.-)</array>")
    local files = {}
    
    for tabName in array:gmatch("<string>(.-)</string>%s") do
        table.insert(files, {name = tabName})
    end   
    
    --success function
    local function success(i, name, data)
        if not data then alert("No data", name) return end
        print("Loaded "..i.."/"..#files..":"..name)
        files[i].data = data
        for i,v in ipairs(files) do
            if not v.data then 
                return --quit this function if any files have mssing data
            end
        end
        --if all data is present then save...
        for i,v in ipairs(files) do
            saveProjectTab(v.name, v.data)
            print("Saved "..i.."/"..#files..":"..v.name)
        end
        for i,v in ipairs(files) do --load...
            load(v.data)()
        end
        setup() --and run
    end
    --request all the tab files
    for i,v in ipairs(files) do
        http.request(url..v.name..".lua", function(data) success(i, v.name, data) end, function(error) alert(error, v.name.." not found") end)
    end
     
end

http.request(url.."Info.plist", install, function (error) alert(error) end)

@yojimbo2000 excellent - loads and runs on ipad3 but something amiss with the depth of the trench - seems to only render the trench walls very close to the xwing (as if the clipping depth is set very shallow). Might be a hardware limitation

Here’s a final card match game - uses the spritesheet image from an earlier post

-- Match The Cards
displayMode(FULLSCREEN_NO_BUTTONS)
-- Use this function to perform your initial setup
function setup()

p1={name="Luke",score=0}
p2={name="Vader",score=0}    
    activeplayer=1
    row=9
    col=4
    total=row*col
    ss=image(384,384)
    setContext(ss)
    sprite("Project:spritesheet",384/2,384/2,384,384)
    setContext()
    numPics=9    
    pic={}
    pic[1]=ss:copy(0,0,192,384)
    pic[2]=ss:copy(192,320,64,64)
    pic[3]=ss:copy(256,320,64,64)
    pic[4]=ss:copy(320,320,64,64)
    pic[5]=ss:copy(192,0,32,32)
    pic[6]=ss:copy(192,32,32,32)
    pic[7]=ss:copy(192,64,32,32)
    pic[8]=ss:copy(192,96,32,32)
    pic[9]=ss:copy(192,128,32,32)

    tabh=0.8*HEIGHT --height of playing area

cards={}
    ct=1
    local cnt=0
    for i=0,WIDTH-1,WIDTH/row do
        for j=0,tabh-1,tabh/col do
        table.insert(cards,{x=i+WIDTH/(2*row),y=j+tabh/(2*col),active=1,t=ct})
            cnt = cnt + 1
            if cnt>=total/numPics then
                cnt=0
                ct = ct + 1
            end
            
        end
    end
    for i=1,100 do
        exchange()
    end
    selectIndex1=0
    selectIndex2=0
    vistime=60
    checkpair=0
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    font("ArialRoundedMTBold")
    fontSize(40)
    if activeplayer==1 then
        fill(255, 243, 0, 255)
    else
        fill(149, 148, 135, 255)        
    end
text(p1.name..": "..p1.score,WIDTH*0.1,HEIGHT*0.9)
    if activeplayer==2 then
        fill(255, 243, 0, 255)
    else
        fill(149, 148, 135, 255)        
    end
text(p2.name..": "..p2.score,WIDTH*0.9,HEIGHT*0.9)
    -- This sets the line thickness
    strokeWidth(5)

for i,c in pairs(cards) do
        if c.active==1 then
        sprite("Platformer Art:Block Special Brick",c.x,c.y,0.8*WIDTH/row,0.8*tabh/col)
        elseif c.active>1 then            
        sprite(pic[c.t],c.x,c.y,0.8*WIDTH/row,0.8*tabh/col)
            end
        if c.active>2 then
            c.active = c.active + 1
            if c.active>vistime then
                checkpair=1
            end
        end
    end
    if checkpair==1 then
        checkpair=0
        if cards[selectIndex1].t==cards[selectIndex2].t then
            cards[selectIndex1].active=0
            cards[selectIndex2].active=0
            sound("Game Sounds One:Bell 2")
            if activeplayer==1 then
                p1.score = p1.score + 1
                else
                p2.score = p2.score + 1
            end
            else
            cards[selectIndex1].active=1
            cards[selectIndex2].active=1
            sound("Game Sounds One:Wrong")
            activeplayer = activeplayer + 1
            if activeplayer>2 then activeplayer=1 end
        end
         selectIndex1=0
         selectIndex2=0        
    end
for i,c in pairs(cards) do
        if c.active==0 then
            table.remove(cards,i)
        end
    end
    if #cards==0 then
        if p1.score>p2.score then
            text(p1.name.." Wins!",WIDTH/2,HEIGHT/2)
        elseif p1.score<p2.score then
            text(p2.name.." Wins!",WIDTH/2,HEIGHT/2)
        else
            text("Draw,",WIDTH/2,HEIGHT/2)
        end
    end
end

function touched(t)
    if t.state==ENDED then
        for i,c in pairs(cards) do
         if c.active==1 and (selectIndex1==0 or selectIndex2==0) and t.x>c.x-WIDTH/(2*row) and t.x<c.x+WIDTH/(2*row) and t.y>c.y-tabh/(2*col) and t.y<c.y+tabh/(2*col) then
               c.active = c.active + 1
                if selectIndex1==0 then
                selectIndex1=i
                else
                    selectIndex2=i
                end
             if c.active>2 then 
           c.active=1 
                if selectIndex1==i then
                        selectIndex1=0
                    end
                if selectIndex2==i then
                        selectIndex2=0
                    end
             end
            end
        end
        
        if selectIndex1~=0 and selectIndex2~=0 then
            cards[selectIndex1].active=3
            cards[selectIndex2].active=3

        end
        
    end
end

function exchange()
  local   c1=math.random(#cards)
   local  c2=math.random(#cards)
    while(c1==c2) do
        c2=math.random(#cards)
    end
    local sub=cards[c1].t
    cards[c1].t=cards[c2].t
    cards[c2].t=sub
end

@West or @yojimbo2000 could be winner! the others aren’t bad but… They are better.
We can make voting everyone, who was here so everyone is judge, West and yojimbo2000 can vote, too. Isn’t it a good idea? So then it’s not like yojimbo2000 is mod and my friend, so then the votes could be more vair; if we use this system, then I vote for @yojimbo2000!

@yojimbo2000, this error appears by using your xwing:

Instanced meshes not supported on this device

your iPad may be too old for this code

@yojimbo2000 very nice. In my 1rst attempt there was an error ‘main’ not found. Then i ran again and loading was ok.

Oh yeah, forgot to say that the trench is drawn with instancing, which I guess requires an A7 chip or newer? If I have time, I’ll see if I can add a non-instanced version. It’s good that the error message is so specific.

Ok, I removed instancing. Doesn’t seem to make any difference to the performance (I think we worked out that instancing is only beneficial when there’re hundreds of instances anyway)

Rerun the installer code above to get the new version.

@Jmv38 thanks for the report, I guess the http.request timed out for Main.lua. I’ll see whether I can make the installer a little more robust.

@yojimbo2000 why did you deleted my messages when they were 3 times in a row?

@TokOut users aren’t supposed to have multiple accounts or open multiple threads on the same subject. If users repeatedly ignore our requests to keep discussions of the same code-base in one thread, then we might close the threads we consider to be duplicate or off-topic.

Super late entry, but thought I’d enter this little demo I made. It’s an isometric(well, truly diametric) game where you’re R2D2 exploring the death star. I was hoping to add more content(minigames, etc) but I ran out of time.
https://m.youtube.com/watch?v=I-M9f5DeGc8