123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- -- 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
- -- <PALETTE>
- -- 000:140c1c44243430346d4e4a4e854c30346524d04648757161597dced27d2c8595a16daa2cd2aa996dc2cadad45edeeed6
- -- </PALETTE>
|