Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "svgCreate.c"
- #include <fstream>
- using namespace std;
- int tetriminoPattern[20][10] =
- {
- {7,0,0,0,0,0,0,0,0,0}, //20
- {7,7,0,0,0,0,0,0,0,0}, //19
- {7,0,0,0,0,0,0,0,0,0}, //18
- {0,0,1,1,0,0,0,0,0,0}, //17
- {0,0,0,1,1,0,0,0,0,0}, //16
- {6,6,0,7,5,5,5,5,2,2}, //15
- {6,0,0,7,7,5,5,5,5,2}, //14
- {6,1,0,7,4,4,7,6,6,2}, //13
- {1,1,0,4,4,7,7,6,2,2}, //12
- {1,0,0,4,1,1,7,6,5,2}, //11
- {3,3,0,4,4,1,1,2,5,2}, //10
- {3,3,0,6,4,2,2,2,5,6}, //09
- {4,0,0,6,6,6,3,3,5,6}, //08
- {4,4,0,7,1,1,3,3,6,6}, //07
- {2,4,0,7,7,1,1,7,7,7}, //06
- {2,0,0,7,1,5,3,3,7,5}, //05
- {2,2,0,1,1,5,3,3,5,5}, //04
- {6,6,0,1,1,5,3,3,5,5}, //03
- {6,0,0,1,1,5,3,3,5,5}, //02
- {6,7,0,1,4,4,4,4,5,2} //01
- };
- class TetraBlock {
- public:
- int blockColor;
- TetraBlock(){
- blockColor = 0;
- }
- TetraBlock(int _blockColor){
- blockColor = _blockColor;
- }
- void writeSVG(FILE* fp, std::string fileName, int x, int y){
- switch(blockColor){
- case 0:
- createBlock(fp, x, y, 0, 0, 0);
- break;
- case 1:
- createBlock(fp, x, y, 255, 0, 0);
- break;
- case 2:
- createBlock(fp, x, y, 255, 127, 0);
- break;
- case 3:
- createBlock(fp, x, y, 255,255,0);
- break;
- case 4:
- createBlock(fp, x, y, 0, 255, 0);
- break;
- case 5:
- createBlock(fp, x, y, 0, 255, 255);
- break;
- case 6:
- createBlock(fp, x, y, 0, 0, 255);
- break;
- case 7:
- createBlock(fp, x, y, 255, 0, 255);
- break;
- }
- }
- };
- int main()
- {
- FILE* fp = fopen("htmlfile.html","w+");
- fputs( "<!DOCTYPE html>\n<html>\n<body>\n<svg height = \"1000\" width = \"2000\">\n", fp);
- TetraBlock block[10][20];
- for (int i = 0; i < 10; i++){
- for (int j = 0; j < 20; j++){
- block[i][j] = TetraBlock(tetriminoPattern[j][i]);
- block[i][j].writeSVG(fp,"htmlfile.html",i*50,j*50);
- }
- }
- fputs("</svg></body>\n</html>\n",fp);
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement