dekar avatar dekar committed 2cda010

Work on side animation

Comments (0)

Files changed (2)

include/ct-level.hpp

         Color           mColor;
         bool            mIsActive;
         Timer::Ptr      mAnimationTimer;
+        /**
+         * Значение в пикселях, управляет анимацией движения блока вправо/влево.
+         * mSideMovementDelta > 0.0f - движение вправо
+         * mSideMovementDelta < 0.0f - движение влево
+         * mSideMovementDelta == 0.0f - без анимации
+         */
+        float           mSideMovementValue;
 };
 
 
         mPosition(blockPos), 
         mFieldCorner(fieldCorner),
         mColor(color),
-        mIsActive(true)
+        mIsActive(true),
+        mSideMovementValue(0.0f)
 {
         int blocksCount = sizeof(gStandardBlocks) / sizeof(gStandardBlocks[0]);
         int index = rand() % (blocksCount + 0); //XXX 
 {
         FloatRect rect = computeBoundBox();
         float h = rect.y + rect.h;
+        //bool canDisableTimer = false;
 
         if (mPosition.y + h + FALLING_ANIMATION_DELTA <= mFieldCorner.y + FIELD_HEIGHT_P) {
                 mPosition.y += FALLING_ANIMATION_DELTA;
         } else {
-                timer->disable();
+                //timer->disable();
         }
 }
 
                 for (int j = 0; j < BLOCK_SIZE; j++) {
                         if (mCells[i + BLOCK_SIZE * j] != 0) {
                                 FloatRect rect(mPosition.x + i * CELL_WIDTH_P + borderSize, 
-                                        mPosition.y + j * CELL_HEIGHT_P + borderSize,
-                                        CELL_WIDTH_P - borderSize,
-                                        CELL_HEIGHT_P - borderSize);
+                                               mPosition.y + j * CELL_HEIGHT_P + borderSize,
+                                               CELL_WIDTH_P - borderSize,
+                                               CELL_HEIGHT_P - borderSize);
 
-                                //renderRect(rect, color::red, NULL);
                                 Primitive prim;
 
-                                //prim.setColor(color::red + Color(0, 0, rand() % 30));
                                 prim.setColor(mColor);
                                 prim.setRect(rect);
 
         renderCircle(mFieldCorner, 20.0f, color::white, NULL);
         renderCircle(mPosition, 20.0f, color::green - Color(100, 50, 100), NULL);
         renderRect(FloatRect(mPosition.x, mPosition.y, 
-                                CELL_WIDTH_P * BLOCK_SIZE, 
-                                CELL_HEIGHT_P * BLOCK_SIZE), color::blue);
+                CELL_WIDTH_P * BLOCK_SIZE, 
+                CELL_HEIGHT_P * BLOCK_SIZE), color::blue);
 
         FloatRect rect(computeBoundBox());
         rect.addVector(mPosition);
 
 void SimpleBlock::moveLeft()
 {
+        if (mSideMovementValue != 0.0f) {
+                mSideMovementValue = -3.0f;
+        }
 }
 
 void SimpleBlock::moveRight()
 {
+        if (mSideMovementValue != 0.0f) {
+                mSideMovementValue = 3.0f;
+        }
 }
 
 void SimpleBlock::onCollide()
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.