Overhauling the demo apps

I’ve finished my attempt at meshes, and also a basic physics demo, which are on the wiki page I made earlier, here

https://bitbucket.org/TwoLivesLeft/core/wiki/Codea%20Demo%20Apps

I think we should keep the previous physics demo as an “advanced” version, because it does joints etc, whereas mine is much more simple.

It is really hard making these demos, and I think rather than try for perfection, we should just focus on improving the existing apps as much as we realistically can, especially the apps that are of little help to new users at the moment.

Comments and suggestions (and assistance!?) welcome.

nice demos, quite useful processes.
I miss the ‘swipe for next slide’ though, :wink:

Nice as your swipes are, some of the demos need swipes, you know :smiley:

Cool, the meshes demo seems very nice. Are you planning a separate 3D demo?

Also, is it possible to suggest additions to the built-in assets? ie it might be nice to have some simple tileable textures for demonstrating 3D (tho obviously this depends on licensing, and not adding too much to the install size).

It also might be nice to include some 3D assets, like some simple .obj models. Currently the asset pickers and readText only see files with extension .txt, but you can open text based files in Dropbox/, Documents/ etc with any extension using os.path io.open and file.read. Or, we could ask @Simeon whether the asset picker and readText commands can be tweaked to see files with different extensions (.obj .mtl etc)

@yojimbo2000 - I’m definitely planning a 3D demo, it is badly needed, also other advanced topics like lighting, terrain etc. Anyone who wants to help is welcome, there is plenty of work to do still.

However, while I’m keen to add some demos at the advanced end, I’m torn by the realization that there’s also a lot to do at the basic level. We really need a “your first app” project which introduces the basics, there is no demo on sockets, there are no Lua demos (eg to explain tables and classes), etc.

I like the idea of extending assets. There are some free to use tile sheets that would help people do simple animations, too. If we include obj files, then we need to put an obj reader up to Simeon. I’m not sure if mine is robust enough, but I think you have improved on it.

So (if you have time), why not have a look at this area and put up some ideas?

No problem, I’ll see if I can get my version of the obj reader into a presentable state.

I’ve added a demo app for 3D lighting to the list

https://bitbucket.org/TwoLivesLeft/core/wiki/Codea%20Demo%20Apps

Speaking of tilesets, the lostgarden guy who did the space cute sprites that currently ship with Codea also has some very nice, slightly retro tilesets on his website (forced perspective not-quite-topdown backgrounds, eg for an RPG), also free to use:

http://www.lostgarden.com/2006/07/more-free-game-graphics.html

They’re in .bmp format, and are oddly spaced out with lots of blank spaces between tiles (not sure why), and there’s lots of superfluous stuff like mask images. So if these were to be included they’d need a bit of wrangling into something more appropriate for Codea (perhaps a .png would be best, for the tiles with transparency? Although pngs seem to take up more space than jpegs).

It would also be nice to have a tileset with some animation.

I found some animation tile sets a while back, I’ll see if I can find them again

what about this for currentTouch demo:


--# Main
-- CurrentTouch demo00

function setup()
    info = [[ 
    CurrentTouch gives information on the most recent touch that occurred
    CurrentTouch.state can have the following values:
        BEGAN, MOVING, ENDED, CANCELLED
    The finger position is
        CurrentTouch.x
        CurrentTouch.y
    The last position of this finger is
        CurrentTouch.prevX
        CurrentTouch.prevY
    The difference current position minus last one is
        CurrentTouch.deltaX
        CurrentTouch.deltaY    
    If you tap on the screen without moving the finger too much, you get this count:
        CurrentTouch.tapCount
    CurrentTouch is always available, but is updated only when you start or move or end a touch
    Before any touch has occured, it is in CANCELLED state
    It has a defined id field, but its value is always 0
    It is ok with 1 touch only, but it gets messy if you put 2 or more fingers on the screen
    ]]
end

-- a table to convert touch state (0,1,...)  into a readable string
local states = {}
states[BEGAN] = "BEGAN"
states[MOVING] = "MOVING"
states[ENDED] = "ENDED"
states[CANCELLED] = "CANCELLED"
-- returns a string with all touch fields
function touchToString(name,t)
    local str = {
        name,
        "id = ",
        "state = ",
        "x = ",
        "y = ",
        "deltaX = ",
        "deltaY = ",
        "prevX = ",
        "prevY = ",
        "tapCount = ", 
    }
    if t then
    str = {
        "",
        tostring(CurrentTouch.id),
        states[CurrentTouch.state],
        tostring(CurrentTouch.x),
        tostring(CurrentTouch.y),
        tostring(CurrentTouch.deltaX),
        tostring(CurrentTouch.deltaY),
        tostring(CurrentTouch.prevX),
        tostring(CurrentTouch.prevY),
        tostring(CurrentTouch.tapCount), 
    }
    end
    str = table.concat(str,"\
")
    return str
end
function drawTouchInfo(name,touch,x,y)
    -- draw the touch info
    fill(57, 57, 57, 255)       -- set color for text
    fontSize(20)                -- set font size
    font("ArialMT")
    textMode(CORNER)
    textAlign(RIGHT)            -- align text to the left
    titles = touchToString(name)
    text(titles,x-10-(textSize(titles)),y)       -- draw text on screen
    textAlign(LEFT)            -- align text to the right
    values = touchToString(name,touch)
    text(values,x,y)       -- draw text on screen
    
end
function draw()
    noStroke()
    background(178, 178, 178, 255)     
    -- draw the touch
    local t = CurrentTouch -- a copy 
    fill(255, 190, 0, 255) -- button color
    ellipseMode(RADIUS)
    ellipse(t.x,t.y,50)
    -- draw the CurrentTouch info
    drawTouchInfo("CurrentTouch : ", CurrentTouch, WIDTH/2, HEIGHT-250)
    textMode(CENTER)
    fontSize(17)
    font("Arial-ItalicMT")
    text(info, WIDTH/2, 250)
end

looks good. =D>

Can you put it in a gist and give me a link?

Dont you want additionnal tabs for touched() first?

good idea!