My ELEC2645 joystick project Tetris Game NAME: JIANWEI CHEN SID: 200879849

Dependencies:   N5110 SDFileSystem mbed

Patterns.cpp

Committer:
cjw851102
Date:
2016-04-25
Revision:
1:2a758565f691
Parent:
0:12a1972fa0d0

File content as of revision 1:2a758565f691:

#include "Patterns.h"

    // type rotation y x
int pattern[7][4][6][6] = { 
 //type 0: L
 //type 1: L mirrored
 //type 2: I
 //type 3: T
 //type 4: square
 //type 5: N
 //type 6: N mirrored
    {
        //L
        {
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0}
        }, {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {1,1,1,1,1,1},
            {1,1,1,1,1,1}
        }, {
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1}
        }, {
            {1,1,1,1,1,1},
            {1,1,1,1,1,1},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }
    },

    {
        //L mirrored
        {
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1}
        }, {
            {1,1,1,1,1,1},
            {1,1,1,1,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0}
        }, {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,1,1,1,1},
            {1,1,1,1,1,1}
        }
    },
    
     {
        //I
        {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {1,1,1,1,1,1},
            {1,1,1,1,1,1},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0}
        }, {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {1,1,1,1,1,1},
            {1,1,1,1,1,1},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0}
        }
    },
    
    {
        //T
        {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {1,1,1,1,1,1},
            {1,1,1,1,1,1}
        }, {
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1}
        }, {
            {1,1,1,1,1,1},
            {1,1,1,1,1,1},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0}
        }
    },
    
    {
        //square
        {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }, {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }
    },
    
    {
        //N
        {
            {1,1,0,0,0,0},
            {1,1,0,0,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0}
        }, {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0}
        }, {
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {0,0,0,0,1,1},
            {0,0,0,0,1,1}
        }, {
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }
    },
    
    {
        //N mirrored
        {
            {0,0,1,1,0,0},
            {0,0,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {1,1,0,0,0,0},
            {1,1,0,0,0,0}
        }, {
            {0,0,0,0,0,0},
            {0,0,0,0,0,0},
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1}
        }, {
            {0,0,0,0,1,1},
            {0,0,0,0,1,1},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {0,0,1,1,0,0},
            {0,0,1,1,0,0}
        }, {
            {1,1,1,1,0,0},
            {1,1,1,1,0,0},
            {0,0,1,1,1,1},
            {0,0,1,1,1,1},
            {0,0,0,0,0,0},
            {0,0,0,0,0,0}
        }
    }

};

int Patterns::getPatterns(int type, int rotation, int y, int x)
{
    return pattern[type][rotation][y][x];
}