You cheeky!Robin wrote:The rules don't require any type of visual feedback.
Any ideas for next 1K challenge?
You cheeky!Robin wrote:The rules don't require any type of visual feedback.
I tried for Tetris once, it is really hard.ivan wrote:Any ideas for next 1K challenge?
Tetris might be too hard, but I'll see if Space Invaders or Asteroids are possible (personally leaning more towards Asteroids).hatninja wrote:i think a clone of Asteroids or Space Invaders could be a good choice.
I don't think it's possible.zorg wrote:tetris could be fine, though i'm not sure a <1K implementation is possible
Code: Select all
-------------------------------------------------------------------------------
--[[
0000011001100000 -- O 16 1 4
0000111100000000 0010001000100010 -- I 16 2 4
000111001 010010110 100111000 011010010 -- J 9 4 3
000111100 110010010 001111000 010010011 -- L 9 4 3
000011110 010011001 000011110 010011001 -- S 9 4 3
000110011 001011010 000110011 001011010 -- Z 9 4 3
000111010 010110010 010111000 010011010 -- T 9 4 3
0x0660
0x0f002222
0x1ca5a70d2
0x1e648f093
0x0f2643c99
0x19968665a
0x1d2c9709a
"`""¥§
!æHð&CÉhfZ, "
--]]
--[[
-- 4bit version
T,t,_={},"06600f0022221ca5a70d21e648f0930f2643c9919968665a1d2c9709a",{9,4,3}
for c in t:gmatch"." do for i=0,3 do T[#T+1]=(tonumber(c,16)/2^i)%1 end end
--]]
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--[[ 109 Bytes - Tetromino data flat tableize ]]--
-- T is the temporary flat table of cells to be processed into a hierarchical one
-- t is temporary hexstring holding all the tetromino types and rotations (in order, makes it easier)
-- Goes through all bytes in the string, and stores all bits in those bytes into T
--[[
T,t={},[=[`""¥§
!æHð&CÉhfZ, ]=];for c in t:gmatch"." do for i=0,7 do T[#T+1]=(string.byte(c)/2^i)%1 end end
--]]
T,t={},[=[`""¥§
!æHð&CÉhfZ, ]=];for c=1,#t do for i=7,0,-1 do T[#T+1]=(string.byte(c)/2^i)%1 end end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--[[ 267 Bytes - Tetromino data hierarchical tableize ]]--
-- The below barf doesn't work right, so yeah...
-- _ is temporary for 3x3 ones, since we can save 6 chars per inclusion
-- A is tetronimo hierarchical table
-- Create the hierarchy: type, rotation, row index, cell content (0/1)
_={9,4,3};
t,A,a,b,c,d={{16,1,4},{16,2,4},_,_,_,_,_},{},1,0,0,0;
for i=1,#T do
if b==0 then A[#A+1]={} end
if b<t[a][2] then
B=A[#A];
B[#B+1]={};
b=b+1;
if c<t[a][3] then
C=B[#B];
C[#C+1]={};
c=c+1;
if d<t[a][1] then
D=C[#C];
D[#D+1]=T[i];
print(A,B,C,D,a,b,c,d)
d=d+1;
else
d=0
end
else
c=0
end
else
b=0;
a=a+1
end
end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- T is holder array for block "parts" (the grid), inited to 10x20 0-s.
-- t is the active block
-- I is whether t exists or not (may not save enough chars; alternative would be to do "if type(t)~='table' then" for Spawn)
-- t has these fields: 1 type1based 2 rota0based 3 rotacount0based 4 moveaction 5 y0based 6 x0based 7 rotaaction
-- t's fields for the coords denote the topleft of the 3x3 or 4x4 square of the chosen piece.
-- D is Delta accum
-- G is whether gravity is 1 cell/second (0) or 20 (1).
T,t,I,D,G,m={},{},0,1,0,math;for i=1,10 do T[i]={};for j=1,20 do T[i][j]=0 end end
love.update=function(d)
-- Spawn
if I<1 then -- ==0
a=love.math.random(1,7);I,t=1,{a,0,#A[a],0,0,0,0}; -- No active blocks -> create a new one.
end
-- Move
t[5]=t[4]<0 and m.max(t[5]-1,0)
t[5]=t[4]>0 and m.min(t[5]+1,10-#A[t[1]][1])
-- Rotate & test
if t[7]>0 then
end
-- Drop / Settle
D=D-d;
if D<0 then -- <=0
D=G>0 and .05 or 1 -- 1/20
end
end
love.draw=function()
love.graphics.points(t[5],t[6])
end
--(T[t][2]+K[k])%T[t][3]
--[[
Spawn block if no active is present
Block may be rotated if a key was pressed,
Block descends one cell per second
If it hits another during descent, it will cease to be active: table -> number (0)
--]]
-------------------------------------------------------------------------------
--[[ 202 Bytes ]]--
-- K is supported rota keys
-- First if is move, second rota, third is drop
K={['a']=-1,['d']=1};love.keypressed=function(k)if K[k] then t[4]=K[k] end if k=='w' then t[7]=1 end if k=='d' then G=1 end end love.keyreleased=function(k) if k=='w' then G=0 else t[4],t[7]=0,0 end end
-------------------------------------------------------------------------------
Go ahead, we might get a few more entries that way.zorg wrote:Edit: Also i should probably open a new thread for this...
Users browsing this forum: No registered users and 3 guests