Hello,
I am a novice at coding. I have read up quite a bit on corona and played around with all the sample codes. Now I am now trying to take a shot at making my own Tetris semi-clone (right now my code resembles nothing of Tetris, I am just trying to get a feel for the general concepts).
I have started by creating a function that executes every 1.5 seconds to create a new block. I add the block to a group. Then I execute another function every 1.5 seconds that moves every item in the group up (in my Tetris the block go up the screen, not down). The problem is new blocks are placed on the same Y coordinate as the blocks that have already moved up. I don’t understand?!?
My code is below. Can someone help me understand how to add a block, put it in a group, then move each item in the group up the Y coordinate by a set amount without putting each block on the same Y coordinate?
–create group for blocks
local blockGroup = display.newGroup()
–function to move blocks
local blockMove = function ()
blockGroupStart = blockGroup.y
blockGroup.y = blockGroupStart - 26
end
–function to drop blocks
local randomBlock = function()
choice = math.random( 100 )
local block
if ( choice > 50 ) then
block = display.newImage( “red.png” )
block.x = -29 + (54 * math.random( 6 ) ); block.y = 1000
blockGroup:insert( block )
else
block = display.newImage( “red.png” )
block.x = -29 + (54 * math.random( 6 ) ); block.y = 1000
blockGroup:insert( block )
end
end
–run function to drop blocks
timer.performWithDelay( 1500, randomBlock, 0)
–run function to move blocks
timer.performWithDelay( 1500, blockMove, 0)
thank you for your help
Chase