dekar avatar dekar committed a38e95e

Work on blocks

Comments (0)

Files changed (4)

 ./out/test_*
 ./out/*.log
 ./out/*.a
-./html/*
+./out/*.dll
+./html/*

include/ct-level.hpp

 #include "r2-math.hpp"
 #include "r2-state.hpp"
 #include "r2-texture.hpp"
+#include "r2-timer.hpp"
 
 namespace r2 {
 
-const int	BLOCK_SIZE     = 5;	/**< размер блока, в который вписана фигура */
-const int	FIELD_WIDTH    = 15;	/**< ширина поля тетриса(в клетках) */
-const int	FIELD_HEIGHT   = 25;	/**< высота поля тетриса(в клетках) */
-const int	FIELD_WIDTH_P  = 480;	/**< ширина поля тетриса(в пикселях) */
-const int	FIELD_HEIGHT_P = 800;	/**< ширина поля тетриса(в пикселях) */
+const int BLOCK_SIZE     = 5;	/**< размер блока, в который вписана фигура */
+const int FIELD_WIDTH    = 15;	/**< ширина поля тетриса(в клетках) */
+const int FIELD_HEIGHT   = 25;	/**< высота поля тетриса(в клетках) */
+const int FIELD_WIDTH_P  = 480;	/**< ширина поля тетриса(в пикселях) */
+const int FIELD_HEIGHT_P = 800;	/**< ширина поля тетриса(в пикселях) */
+const int FALLING_ANIMATION_SPEED = 20;         /**< интервал обловления анимации в мс*/
+const float FALLING_ANIMATION_DELTA = 1.0f;     /**< смещение блока при падении в пикс.*/
 
 /**
- * Ш ирина ячейки поля в пикселях
+ * Ширина ячейки поля в пикселях
  */
 const float     CELL_WIDTH_P = FIELD_WIDTH_P / FIELD_WIDTH; 
 /**
 
         CellsArr&       getCells() { return mCells; }
 private:
+
+        void    onAnimationUpdate(Timer* timer);
+
         CellsArr        mCells;	/**< фигура, -1 - пустое место */
         Vec2f           mPosition;
         Color           mColor;
         bool            mIsActive;
+        Timer::Ptr      mAnimationTimer;
 };
 
 
 	        "update_interval": 10
 	}, 
 	"render": {   
-	       "scr_w": 1024,
-	       "scr_h": 768,
+	       "scr_w": 800,
+	       "scr_h": 600,
 	       "bpp": 32,
 	       "windowed": 1,
 	       "msample": 0,
                "type": "gl"
 	}, 
 	"log": {
-	       "stack_trace": 1,
+	       "stack_trace": 0,
 	       "print": 1
 	},
 	"font_manager": {
 void Level::onUpdate(StateMachine* machine)
 {
         for (auto it = mBlocks.begin(); it != mBlocks.end(); ++it) {
-                if (*it)->isActive() {
+                if ((*it)->isActive()) {
                         (*it)->moveDown();
                         (*it)->update();
                 }
                 gStandardBlocks[index] + sizeof(gStandardBlocks[0]) / sizeof(gStandardBlocks[0][0]), 
                 mCells.begin());
 
+        mAnimationTimer = gApplication->createTimer(FALLING_ANIMATION_SPEED, true);
+        mAnimationTimer->getSignal().connect(sigc::mem_fun(*this, &SimpleBlock::onAnimationUpdate));
 }
 
 SimpleBlock::~SimpleBlock()
 {
 }
 
+void SimpleBlock::onAnimationUpdate(Timer* timer)
+{
+        mPosition.y += FALLING_ANIMATION_DELTA;
+        LOG("G onAnimationUpdate");
+}
+
 void SimpleBlock::render(const Vec2f& fieldCorner)
 {
         const float borderSize = 1.0f;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.