Puzzle game touch

@fikabord - create a gist account first. Then in the main Codea menu, where you see a list of your projects, press on your project name and hold until a little menu pops up. Select Copy, and this will copy all your code tabs.

Then go to the gist webpage and paste it in there, and save, and post the URL here.

@jvm38 @Ignatz the code should be available here.

I currently have one questions which would be great to get some guidance on where to start. Once you align +3 brushes they should be removed and create a whole where the brushes above can fall into. How should I go about animating the brushes which should be moved down?

@fikabord - you forgot to include a link to your code

@ignatz Im such a noob :stuck_out_tongue:

https://gist.github.com/fikabord/f6c36d6c2781a0898369

Gist is nice, but if you split your gist in tabs (and dont make a single file), it doesnt change much from what you did before in the forum! Still have to copy then tab by tab.

@fikabord - you could use tweens to animate the brushes. See the Animation demo project inside Codea, and here

http://coolcodea.wordpress.com/2013/07/18/995-tweens-what-are-they

@jmv38 im such a noob again :wink:
@ignatz thx that really helped alot. really easy to understand example.

new link to code:
https://gist.github.com/fikabord/fd4898215453fef57104

So, one step forward which is great and now a new challange :slight_smile: The brushes animate just great. Trying to figure out a solution to not create holes in the palette and I think I just got an idea. If it doesn’t work out I might come back with another question :slight_smile:

Thanks for all the help guys!!

@fikabord - it’s naturally going to be better if you can solve this yourself.

Assuming that inspecting the code doesn’t help, what I might do in a situation like this is to put in some print statements around where the problem occurs, to print out the value of variables and what is happening. You may find a “for” loop is incorrect, or a function is running too many times, or something is running when it shouldn’t.

(Off topic) seriously? Emoji in code?

(On topic) I kind of tried to make a program that works for 3Ds. Here:


-- check for matched color combos
function checkMixedColors()
    for i=1, 6 do      
        local rowCount = 0
        local rowMaxCount = 1
        local rowCombo = {}
        local rowC = nil
        local columCount = 0
        local columMaxCount = 1
        local columCombo = {}
        local columColor = nil
        for j=1, 6 do
            -- check for +3 in a row in rows first
            if palette[i][j].col == rowColor then
                rowCount = rowCount + 1             
                if rowCount > rowMaxCount then
                    rowMaxCount = rowMaxCount + 1
                    rowCombo[#rowCombo+1] = palette[i][j].ind
                end
            else
                rowColor = palette[i][j].col
                rowCount = 1
                if rowMaxCount == 1 then
                    rowCombo[1] = palette[i][j].ind
                end
            end
            -- then check for +3 in a row in colums     
            if palette[j][i].col == columColor then
                columCount = columCount + 1             
                if columCount > columMaxCount then
                    columMaxCount = columMaxCount + 1
                    columCombo[#columCombo+1] = palette[j][i].ind
                end
            else
                columColor = palette[j][i].col
                columCount = 1
                if columMaxCount == 1 then
                    columCombo[1] = palette[j][i].ind
                end
            end          
        end
        -- if we find +3 in a row then mark witch brushes to score
        if rowMaxCount >= 3 then
            for i=1, #rowCombo do
                resolveCombo(rowCombo)
            end
        end
        if columMaxCount >= 3 then
            for i=1, #columCombo do
                resolveCombo(columCombo)
            end
        end
    end
    score()
end
for x in 1,6 do --there are 6 faces in a cube
    checkMixedColors()

Basically a copy off @fikabord. Such a noob… XD

@ignatz well thats’s what I’ve been doing for a while :slight_smile: removed all print lines before submitting the code. everything i print looks correct, but obviously it’s not :wink: I have rewritten the code from scratch a few times but end up with the same result.

Oh. I guess we are in the same boat…

@ignatz @aurumcoder2624 finally some progress :slight_smile:

instead of copying the palette I just created another matrix storing static values of brush positions. I also revisited the moveBrushDown() function. now brushes are falling into the right positions. obviously there are new bugs to fix and some design issues.

@ignatz thanks for believing in me :wink:



function moveBrushDown()
    local numberOfHoles = {}
    local staticBrushPositions = {}
    local pw = math.min(WIDTH,HEIGHT)
    local ph = pw
    local bw = pw/6
    local bh = pw/6
    local sx = bw/2
    local sy = bh/2
    for i=1, 12 do      
        staticBrushPositions[i] = {}
        for j=1, 6 do
            staticBrushPositions[i][j] = vec2(sx, sy)
            sx = sx + bw
        end
        sx = bw/2
        sy = sy + bh
    end
        
    for i=1, 6 do
        local count = 0
        numberOfHoles[i] = {}
        for j=1, 6 do
            if palette[j][i].score == true then
                count = count + 1
            end
            numberOfHoles[i][j] = count
        end
        for j=1, 6 do
            local nextFreeNoScoringBrush = numberOfHoles[i][j]
            local endPos = palette[j][i].pos
            palette[j][i].pos = staticBrushPositions[j+nextFreeNoScoringBrush][i]
            palette[j][i].col = palette[j+nextFreeNoScoringBrush][i].col
            tween(3, palette[j][i].pos, {x=endPos.x, y=endPos.y})
        end
    end
end

@fikabord - of course we believe in you . We all have these impossible problems from time to time, but somehow we find a way through! =D>

Except for me… I’m so much of a noob I can’t do anything right. Anyone would say I’m darn hopeless :expressionless:

And I’m not just saying that for sympathy…

The user and all related content has been deleted.

Oh I’m an exception all right. But I’ll guess I’ll try…

@aurumcoder2624 If you’re so terrible at Lua and Codea, why are you improving every library in Codea and making your own app-making company?

@skythecoder, he’s a troll…you haven’t figured that out by now? Shame Shame

I have help. Didn’t you notice? And I have decided not to use Codea main Ly.

@Invad3rZIM I have, I’m just checking if there’s any method to his madness.