Library to control the Tetris game area

Dependents:   Tetris_Game

Revision:
2:56dc50270349
Parent:
1:32aa5cd552cd
Child:
3:af0a7a4464e5
--- a/Tetris.cpp	Sun Mar 27 13:26:57 2016 +0000
+++ b/Tetris.cpp	Thu Apr 07 10:38:15 2016 +0000
@@ -1,1 +1,77 @@
- #include "Tetris.h"
\ No newline at end of file
+/** My Tetris class
+
+@file Tetris.cpp
+
+@brief Library containing all the functions for the game tetris
+
+*/
+
+#include "Tetris.h"
+
+N5110 screen (PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3);
+
+Tetris::Tetris(){
+    pieceposition[0] = 4;
+    pieceposition[1] = 0;
+    orientation = 0;
+}
+
+void Tetris::gamePixel(int x,int y){
+    screen.drawRect(42+(3*x),2+(3*y),2,2,1);
+    screen.refresh();
+    }
+    
+void Tetris::clearGamePixel(int x, int y){
+    for(int i =0; i<3; i++) {
+        for(int j =0; j<3; j++) {
+            screen.clearPixel(42+(x*3)+i,2+(3*y)+j);
+
+        }
+    }
+    screen.refresh();
+    }
+    
+void Tetris::clearGame(){
+    for(int i = 0; i<30; i++) {
+
+        for(int j = 0; j<45; j++) {
+
+            screen.clearPixel(42+i,2+j);
+        }
+    }
+    screen.refresh();
+    }
+    
+void Tetris::piecePlace(int x,int y,int shape)
+{
+
+
+    int count = 0;
+    for(int i = 0; i<4; i++) {
+        for(int j = 0; j<4; j++) {
+
+            int bit = shape & (1<<count);
+
+            if (bit) {
+                gamePixel(j+x,i+y);
+            }
+            count++;
+        }
+    }
+}
+
+void Tetris::pieceClear(int x,int y,int shape)
+{
+    int count = 0;
+    for(int i = 0; i<4; i++) {
+        for(int j = 0; j<4; j++) {
+
+            int bit = shape & (1<<count);
+
+            if (bit) {
+                clearGamePixel(j+x,i+y);
+            }
+            count++;
+        }
+    }
+}