0 Members and 1 Guest are viewing this topic.

#### Kirl

• Senior Member
• Pentium
• Posts: 1200
• Karma: 230
##### Re: Programming Codea on IPAD
« Reply #20 on: September 16, 2012 »

www.kirl.nl
Challenge Trophies Won:

#### Hotshot

• Posts: 2114
• Karma: 91
##### Re: Programming Codea on IPAD
« Reply #21 on: September 22, 2012 »
I am not sure on which one is the best for making Brick on the screen

Should I used

Arrays ?

or

For Loop?

Or

Data?

#### Kirl

• Senior Member
• Pentium
• Posts: 1200
• Karma: 230
##### Re: Programming Codea on IPAD
« Reply #22 on: September 23, 2012 »
You can try storing the bricks using a 2 dimensional array (like a grid) and then check only the cells around the ball position. This way you don't have to check all the bricks, but only those around the ball position.

Code: [Select]
`-- get cells around the ball positionxx = Math.floor( ball.x/cellSize ) -- get x indexyy = Math.floor( ball.y/cellSize ) -- get y indexcurrentCell = bricks[ xx ][ yy ]   -- cell the ball is currently overleftCell =    bricks[ xx-1 ][ yy ] -- left neighbour cellrightCell =   bricks[ xx+1 ][ yy ] -- right neighbour celllowerCell =   bricks[ xx ][ yy-1 ] -- lower neighbour cellupperCell =   bricks[ xx ][ yy+1 ] -- upper neighbour cell `
I believe there is a breakout clone among the example games, you can try to figure out their solution too.
« Last Edit: September 23, 2012 by Kirl »
www.kirl.nl
Challenge Trophies Won:

#### jace_stknights

• Amiga 1200
• Posts: 399
• Karma: 32
• PEEK & POKE are not MOVEM!
##### Re: Programming Codea on IPAD
« Reply #23 on: September 24, 2012 »
Looks great!

By the way, can we share our projects and builds?
Challenge Trophies Won:

#### Hotshot

• Posts: 2114
• Karma: 91
##### Re: Programming Codea on IPAD
« Reply #24 on: September 27, 2012 »
Quote
By the way, can we share our projects and builds?

Yes, that is fine and it is good to learn from others

#### Kirl

• Senior Member
• Pentium
• Posts: 1200
• Karma: 230
##### Re: Programming Codea on IPAD
« Reply #25 on: September 27, 2012 »
You on codea too Jace? Would love to see some of your projects!
www.kirl.nl
Challenge Trophies Won:

#### Kirl

• Senior Member
• Pentium
• Posts: 1200
• Karma: 230
##### Re: Programming Codea on IPAD
« Reply #26 on: September 28, 2012 »
I made a pretty cool procedural drawing tool of sorts, based on flowfields (which I've been playing with the last couple of days). Unfortunatly I can't attach pictures from the ipad (figures, Apple only works inside of it's own little universe), but because the code is pretty short I can share that (thanks for the blessing Hotshot, would be cool to have a sort of DBF Codea code repository).

Here's the code.

Code: [Select]
` -- flowfieldfunction setup()    backingMode(RETAINED)        -- retain screen pixels    background(0, 0, 0, 255)     -- draw black background    col = color(math.random(255), math.random(255), math.random(255))  -- set random color    parameter("swirls", 1/2000, 1/50, 1/100)    -- declare interactive swirlyness parameter    parameter("fade", 0, 1, 0)                  -- declare interactive screen fade parameter    parameter("transparency", 1, 10, 2.5)       -- declare interactive line alpha parameter    watch("particles")           -- watch particle count    touches = {}                 -- make container to track screen touches    parts = {}                   -- make container for particlesendfunction touched(touch)          -- track all screen touches   if touch.state == ENDED  then        touches[touch.id] = nil        col = color(math.random(255), math.random(255), math.random(255), transparency*12.5)    else touches[touch.id] = touch    endendfunction draw()    fill(0, 0, 0, fade*100)           -- set fill alpha acording to fade parameter    rect(0,0, WIDTH, HEIGHT)          -- draw transparent rectangle to slowly fade screen    particles = #parts                -- track nr of particles    col.alpha = transparency*12.5     -- set line alpha to transparancy parameter    fill(col)    for i, p in pairs(parts) do                    -- loop through particles        pixel = noise(p.x*swirls, p.y*swirls)      -- define location of noisemap pixel        brightness = (pixel+1) / 2 * p.mult        -- define brightness between 0-1        speed = brightness * p.mult                -- get particle speed value        size = 2 + speed/2 * p.mult                -- get particle size value        angle = brightness * 360 * math.pi / 180   -- get angle based on pixel brightness        p.x = p.x + math.cos(angle) * speed        -- move particle over X        p.y = p.y + math.sin(angle) * speed        -- move particle over Y        ellipse(p.x, p.y, size)                    -- draw particle                if p.x < 0 or p.x > WIDTH or p.y < 0 or p.y > HEIGHT then            table.remove(parts, i)                 -- remove particle if outside of screen        end    end        for i, t in pairs(touches) do        -- add particles at touch position        if t.state == MOVING or t.state == BEGAN then            table.insert( parts, {x=t.x, y=t.y, mult=(1.5 + math.random() * 1.5)} )        end    endend `
Would love to hear what you think about it, you can create a bunch of really interesting effects by adjusting the sliders.
www.kirl.nl
Challenge Trophies Won:

#### jace_stknights

• Amiga 1200
• Posts: 399
• Karma: 32
• PEEK & POKE are not MOVEM!
##### Re: Programming Codea on IPAD
« Reply #27 on: September 29, 2012 »
You on codea too Jace? Would love to see some of your projects!
Nope, but I think I must make try if you CAN share your projects, I think it is worth buying it
Challenge Trophies Won:

#### Clyde

• A Little Fuzzy Wuzzy
• Posts: 7271
• Karma: 71
##### Re: Programming Codea on IPAD
« Reply #28 on: October 27, 2012 »
This might be of use / news to you dudes out there.

Blitz Research have a new toy out which you can create for all sorts of platforms and browser, it's called Monkey. It looks to be similar in style to Blitz Max with a few more bells and whistles.  There's  also a demo version in their store.

http://www.monkeycoder.co.nz/
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won: