-- title: blockbattle -- author: pixelbath -- desc: a falling blocks game totally not inspired by anything previous -- script: lua t=0 local pieces = { { { {0, 0, 0, 0}, {1, 1, 1, 1}, {0, 0, 0, 0}, {0, 0, 0, 0}, }, { {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, {0, 1, 0, 0}, }, }, { { {0, 0, 0, 0}, {0, 4, 4, 0}, {0, 4, 4, 0}, {0, 0, 0, 0}, }, }, { { {0, 0, 0, 0}, {2, 2, 2, 0}, {0, 0, 2, 0}, {0, 0, 0, 0}, }, { {0, 2, 0, 0}, {0, 2, 0, 0}, {2, 2, 0, 0}, {0, 0, 0, 0}, }, { {2, 0, 0, 0}, {2, 2, 2, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, }, { {0, 2, 2, 0}, {0, 2, 0, 0}, {0, 2, 0, 0}, {0, 0, 0, 0}, }, }, { { {0, 0, 0, 0}, {3, 3, 3, 0}, {3, 0, 0, 0}, {0, 0, 0, 0}, }, { {0, 3, 0, 0}, {0, 3, 0, 0}, {0, 3, 3, 0}, {0, 0, 0, 0}, }, { {0, 0, 3, 0}, {3, 3, 3, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, }, { {3, 3, 0, 0}, {0, 3, 0, 0}, {0, 3, 0, 0}, {0, 0, 0, 0}, }, }, { { {0, 0, 0, 0}, {5, 5, 5, 0}, {0, 5, 0, 0}, {0, 0, 0, 0}, }, { {0, 5, 0, 0}, {0, 5, 5, 0}, {0, 5, 0, 0}, {0, 0, 0, 0}, }, { {0, 5, 0, 0}, {5, 5, 5, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}, }, { {0, 5, 0, 0}, {5, 5, 0, 0}, {0, 5, 0, 0}, {0, 0, 0, 0}, }, }, { { {0, 0, 0, 0}, {0, 6, 6, 0}, {6, 6, 0, 0}, {0, 0, 0, 0}, }, { {6, 0, 0, 0}, {6, 6, 0, 0}, {0, 6, 0, 0}, {0, 0, 0, 0}, }, }, { { {0, 0, 0, 0}, {7, 7, 0, 0}, {0, 7, 7, 0}, {0, 0, 0, 0}, }, { {0, 7, 0, 0}, {7, 7, 0, 0}, {7, 0, 0, 0}, {0, 0, 0, 0}, }, }, } local board = {} local pieceType = 1 local pieceRotation = 1 local piece_x = 3 local piece_y = 0 function init_board() for y = 1, 20 do board[y] = {} for x = 1, 10 do board[y][x] = 0 end end end function draw_piece() for y = 1, 4 do for x = 1, 4 do local block = pieces[pieceType][pieceRotation][y][x] if block ~= 0 then local blockSize = 8 local blockDrawSize = blockSize - 1 rect( (x - 1) * blockSize, (y - 1) * blockSize, blockDrawSize, blockDrawSize, 4 ) end end end end function handle_input() if btnp(4) then pieceRotation = pieceRotation + 1 if pieceRotation > #pieces[pieceType] then pieceRotation = 1 end end if btnp(5) then pieceRotation = pieceRotation - 1 if pieceRotation < 1 then pieceRotation = #pieces[pieceType] end end end function TIC() handle_input() cls(0) draw_piece() end -- -- 000:140c1c44243430346d4e4a4e854c30346524d04648757161597dced27d2c8595a16daa2cd2aa996dc2cadad45edeeed6 --