This way is just flipping it horizontally:
It would be more like this for rotating it:
The goofy 'z' shape (man, i hate those pieces. They always seem to screw up my tetrises(tetrisi?)) is somewhat different because it only has 2 actual rotational positions.
An 'L' shape rotating clock-wise would be:
100 11 111 01
111 10 100 01
10 11
But I would maybe store the data as:
100 011 111 010
111 010 001 010
000 010 000 110
In 3x3 data blocks so as to keep the data sizes the same.
I would approach the idea like this:
`SETTING UP A USER DEFINED TYPE TO STORE THE SHAPE'S LENGTH AND HEIGHT
TYPE ShapeData
DataLength as INTEGER
DataHeight as INTEGER
ENDTYPE
`CREATING THE VARIABLE 'LBlock' AS THE NEW UDT THAT WAS MADE
LBlock as ShapeData
`READING THE LENGTH AND HEIGHT AND PLACING IT IN 'LBlock'
READ LBlock.DataLength
READ LBlock.DataHeight
`CREATE THE ARRAY FROM THE ABOVE INFORMATION
`THE '4' IS HOW MANY FRAMES/ROTATIONS THE SHAPE WILL HAVE
DIM lBlockData(4, LBlock.DataLength,LBlock.DataHeight)
`GETTING THE SHAPE'S DATA
FOR RotationState = 1 to 4
FOR y = 1 to LBlock.DataHeight
FOR x = 1 to LBlock.DataLength
READ lBlockData(RotationState, x,y)
NEXT x
NEXT y
NEXT RotationState
`SETTING A COUPLE VARIABLES BEFORE THE LOOP
ShapeRotation = 1
KeyToggle = 0
`THE LOOP!
DO
CLS
FOR y = 1 to LBlock.DataHeight
FOR x = 1 to LBlock.DataLength
`SETTING SCREEN POSITIONS ACCORDING TO WHAT DATA WE ARE RECIEVEING
left = x * 20
top = y * 20
right = left + 20
bottom = top + 20
`DECIDING ON WHETHER TO MAKE A BLOCK OR NOT (2 BLOCKS. 1 FOR THE WHITE BORDER AND ONE FOR THE COLOR)
IF lBlockData(ShapeRotation, x,y) > 0
BOX left, top, right, bottom
BOX left+1, top+1, right-1, bottom-1, rgb(255,0,0)
ENDIF
NEXT x
NEXT y
`OUR KEYBOARD INPUT AND TOGGLE TO REPRESENT IF IT IS STILL BEING PRESSED
IF KEYSTATE(57) = 1 && KeyToggle = 0
INC ShapeRotation
IF ShapeRotation > 4 THEN ShapeRotation = 1
KeyToggle = 1
ENDIF
IF KeyToggle = 1 && KEYSTATE(57) = 0 THEN KeyToggle = 0
SET CURSOR 0,0: PRINT "Press Space key to rotate shape. Its rotation state is: " + STR$(ShapeRotation)
SYNC
LOOP
END
`L SHAPE
DATA 3,3
DATA 1,0,0,1,1,1,0,0,0
DATA 0,1,1,0,1,0,0,1,0
DATA 0,0,0,1,1,1,0,0,1
DATA 0,1,0,0,1,0,1,1,0
If you run the code, you'll see it rotate the shape in place. It should get an idea on how to get the data and place it on the screen from the array.
As seƱor Paxton said, it would be easier to hard code the rotations than to do all the math involved.
Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.