@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.
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?
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.
So, one step forward which is great and now a new challange 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
@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.
(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()
@ignatz well thats’s what I’ve been doing for a while removed all print lines before submitting the code. everything i print looks correct, but obviously it’s not I have rewritten the code from scratch a few times but end up with the same result.
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.
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