Ejemplo n.º 1
0
        public void UpdateWalkWobble()
        {
            const float kWobbleSpeed = 0.25f;
            const float kWalkSpeed   = 0.15f;

            wobbleSin += kWobbleSpeed;
            if (wobbleSin >= Constants.PI_)
            {
                wobbleSin -= (2 * Constants.PI_);
            }

            const float kAngleBigness = 0.6f;

            noseAngle = (Constants.PI_ / 2) + ((float)Math.Cos(wobbleSin) * kAngleBigness);
            if ((int)movement == (int)CowMovement.kCowWalkingRight)
            {
                noseAngle += Constants.PI_;
            }

            float showAngle = (Constants.PI_ / 2) + ((float)Math.Cos(wobbleSin) * kAngleBigness * 0.05f);

            velocity    = Utilities.GetVectorFromAngle(noseAngle);
            velocity.x *= kWalkSpeed;
            velocity.y *= kWalkSpeed;
            rotation    = (showAngle) - Constants.HALF_PI;
            mapObject.SetRotation(rotation);
        }
Ejemplo n.º 2
0
        public void UpdateWordRotation()
        {
            if (orientationButton != null)
            {
                rotationWholeWord = orientationButton.currentRotation;
            }

            if (rotationWholeWord != 0.0f)
            {
                //Globals.g_main.SetGLMatrixMode(GL_MODELVIEW);
                //glLoadIdentity();
                //glScalef(Constants.kScaleForShorts, Constants.kScaleForShorts, 0.0f);
                //glPushMatrix();
                float roatation = rotationWholeWord;
                float yThing    = Globals.g_world.screenHeight;
                float x         = position.x;
                float y         = position.y;
                if (Globals.deviceIPad)
                {
                    x *= 2.0f;
                    x += 64.0f;
                    y *= 2.0f;
                }

                CGPoint tempWordPos     = Utilities.CGPointMake(x, y);
                CGPoint vectorToBasePos = Utilities.CGPointMake(tempWordPos.x, yThing - tempWordPos.y);
                float   baseAngle       = Constants.PI_ - Utilities.GetAngleFromXYP1(vectorToBasePos.x, vectorToBasePos.y);
                CGPoint positionWas     = tempWordPos;
                float   distance        = Utilities.GetDistanceP1(Utilities.CGPointMake(0, yThing), positionWas);
                CGPoint newPosVec       = Utilities.GetVectorFromAngle(baseAngle + roatation);
                newPosVec.x *= distance;
                newPosVec.y *= distance;
                CGPoint positionNow = newPosVec;
                positionNow.y = -positionNow.y;
                CGPoint diff;
                diff.x = positionNow.x - positionWas.x;
                diff.y = positionNow.y - (yThing - positionWas.y);
                //glRotatef((roatation) * (360.0 / (Constants.TWO_PI)), 0, 0, 1);
                //glTranslatef(diff.x * Constants.kScreenMultiplierForShorts, diff.y * Constants.kScreenMultiplierForShorts, 0.0f);
                CGPoint orientationButtonPos = Utilities.CGPointMake((orientationButton.myButton).position.x, (orientationButton.myButton).position.y);
                if (Globals.deviceIPad)
                {
                    orientationButtonPos.x *= 2.0f;
                    orientationButtonPos.x += 64.0f;
                    orientationButtonPos.y *= 2.0f;
                }

                CGPoint startOffset  = Utilities.CGPointMake(tempWordPos.x - orientationButtonPos.x, tempWordPos.y - orientationButtonPos.y);
                float   startAngle   = Utilities.GetAngleFromXYNewP1(startOffset.x, startOffset.y);
                float   offsetLength = Utilities.GetDistanceP1(Utilities.CGPointMake(0, 0), startOffset);
                CGPoint normalAngle  = Utilities.GetVectorFromAngleNew(startAngle - roatation);
                normalAngle.x *= offsetLength;
                normalAngle.y *= offsetLength;
                CGPoint offset;
                offset.x = startOffset.x - normalAngle.x;
                offset.y = startOffset.y - normalAngle.y;
                //glTranslatef(-offset.x * 20.0f, offset.y * 20.0f, 0.0f);
            }
        }
Ejemplo n.º 3
0
        public void UpdateOffset(float currentAngle)
        {
            CGPoint angleVec  = Utilities.GetVectorFromAngle(baseAngleFromCentre + currentAngle);
            CGPoint angleVec2 = Utilities.GetVectorFromAngle(baseAngleFromCentre2 + currentAngle);

            currentOffset.x  = angleVec.x * baseDistance;
            currentOffset.y  = -angleVec.y * baseDistance;
            currentOffset2.x = angleVec2.x * baseDistance;
            currentOffset2.y = -angleVec2.y * baseDistance;
        }