Github repo with various (getting started) examples

I have been using Codea for a while now. I usually create a github repo with lots of examples that can be pasted into the editor. There was a registration problem a while ago so registered just now.

I have 99 codea examples right now here :

I use it myself by copying the code into a new project.

I am planning on creating a sprite/map editor and a asteroids style space mining/building game. I was really suprised how fast codea is on the ipad(ipad pro here) when I started using it.

Hi @Pakz, haven’t seen your posts here before but followed your link to your GitHub site. You have obviously been into coding sometime.

Out of curiosity I pulled up one of your beginners routines by @dijkstra on maps. Problem is I didn’t know what the objective of the code was, have you a supporting web page describing what the code is about.

Ran the code to see what it was about and still unsure I fiddled around with it to try to get a better output, stripped out bits that didn’t seem to fit and came up with that below. I probably need to dig through the forum to get more info. Anyway - my tidying of it below.

-- Djkstra

-- several viewer modes are available type viewer.
viewer.mode = STANDARD
-- Use this function to perform your initial setup
function setup()
    print("Tap top right this window to close it")
    map ={}
    for x=0,10 do
        for y=0,10 do
    openlist = {}

-- This function gets called once every frame to draw content
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)
    -- sets fill or text colour
    fill(255, 14, 0)
    -- call drawmap routine to build map

function drawmap()
    for y=0,10 do
        for x=0,10 do

function flood()
    dx = {0,1,0,-1}
    dy = {-1,0,1,0}
    local pos = vec2(5,5)
    while #openlist>0 do
        pos = openlist[1]
        for i=1,4 do
            local nx = pos.x+dx[i]
            local ny = pos.y+dy[i]
            if nx>-1 and nx<10 and ny>-1 and ny<10 then
                if map[pos.x+dx[i]][pos.y+dy[i]] == 0 then

p.s. welcome to the forum.

@Pakz Welcome to the forum!

If you have any code that could make good standalone examples it would be great to see it on WebRepo. It’s my attempt to consolidate community projects and examples in one place and using the ‘WebRepo’ project in Codea allows easy access to any of the submitted projects :smile:

@Pakz wow nice collection! I feel like this would be really helpful to use as a reference (esp the Beginners - ones), and the examples are short and informative.

Platform slope collide was quite interesting to me, but why the outer loop (for st=1,50 do…) ?

@simeon the outer loop is to animate the collision. It is the amount of blocks that fall down onto the slope. I should have commented that part.

@steppers I think I have made every example standalone. I wil take a look at the link.

@Bri_G the dijkstra code. As it is named after a algorithm inventor. It is a flood fill that creates a pathfinding map. It starts at the value 1 and ‘floods’ around this number increasing the number every step further it gets. If you would have a enemy sprite at the end of a map he would be able to be coded to path from the high numbers to the lowest number where the player would be at.
I think I could create more examples showing a bit more.

Here a video I made based on this dijkstra algorithm :

@Pakz - thanks for the video and explanation. If you haven’t already visited it - the Codea Wiki has many routines and links to Codea books from users like @Ignatz.

Really helpful for beginners and seasoned coders - maybe some useful routines for you there.

@Pakz I see your proc stuff and I wonder if it’d be well inside your skill set to convert ProcTree:

…as the above thread shows, I was in over my head trying to get it done.

If we could get ProcTree working in lua we could make some pretty awesome Voxel trees, I think.

@UberGoober The voxel system that comes with codea is something I wish to get into. At the moment I have little experience with it. Not even sure how I need to get started inserting procedural generators into it.

@Pakz generators aren’t even relevant at this stage. First ProcTree has to be working, so that there’s a skeleton to build the tree on. There are simpler branching algorithms but ProcTree includes foliage volume, I think.

On the other thread you can see a link to a guy who used ProcTree to make skeletons for Minecraft trees. It would be cool to get that going in Craft.

Anyway there’s tons of cool stuff that could be done, but the first step has nothing to do with Craft or Voxels: someone has to port the dang ProcTree code to lua.

I tried and failed, and since your proc examples even include a 2D tree algorithm, I thought perhaps it might be easy for you.

If you want to look at the original C code, the whole thing is actually in the Codea project I attached in that thread, in between block-comment marks.

Woa, that proctree code looks quite complex. I do not think I could pull it off. There’s things in there that I have no insights in. I have no idea what vertexes are and how to really use vectors and such.