public void UpdateTargetPoint() { float yDiffToNextPoint; float yDistanceInFrontToAimAt; if (closerTargetTimer > 0.0f) { closerTargetTimer -= Constants.kFrameRate; yDistanceInFrontToAimAt = 50.0f; } else { yDistanceInFrontToAimAt = 170.0f; } if (targetPoint < (racingLine.numPoints - 1)) { yDiffToNextPoint = Utilities.GetDistanceP1(Utilities.CGPointMake(racingLine.GetPoint(targetPoint + 1).x, racingLine.GetPoint(targetPoint + 1).y), myPig. position); if (yDiffToNextPoint < yDistanceInFrontToAimAt) { targetPoint++; } } this.SetNextTargetPoint(); }
public void AddToSceneP1(HangingButton.HangingButtonInfo info, FrontEndButton inButt) { hangingButtonScale = info.hangingButtonScale; if (hangingButtonScale <= 0.0f) { hangingButtonScale = 1.0f; } wobbleDeclineMultiplier = 1.0f; yOffset = 0.0f; myButton = inButt; showWobbleMultiplier = info.showWobbleMultiplier; longerRope = 0.0f; baseAngleFromCentre = Utilities.GetAngleFromXYP1(info.offset.x, info.offset.y); baseAngleFromCentre2 = Utilities.GetAngleFromXYP1(-info.offset.x, info.offset.y); baseDistance = Utilities.GetDistanceP1(Utilities.CGPointMake(0, 0), info.offset); currentOffset = info.offset; currentOffset2 = info.offset; currentOffset2.x = -currentOffset2.x; type = info.type; currentWobble = 0.0f; if ((int)type == (int)HangingButtonType.kHB_Rope) { } else { } subTextureId = info.subTextureId; }
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); } }
public void PlayHoofSound() { float distanceToPlayer = Utilities.GetDistanceP1(position, ((Globals.g_world.game).player).position); float volume = 0.3f + (0.5f * (1.0f - Utilities.GetRatioP1P2(distanceToPlayer, 0.0f, 300.0f))); volume *= 0.7f; (SoundEngine.Instance()).PlayFinchSoundP1((int)Audio.Enum1.kSoundEffect_RunSoftPig1 + whichHoof, volume); }
public void CreateRacingLineFromGhost(Ghost inGhost) { numPoints = 0; CGPoint lastPoint = Utilities.CGPointMake(-1000, -1000); inGhost.SetStartOfRace(); for (int i = 0; i < inGhost.numFrames; i++) { inGhost.UpdatePlaying(); CGPoint ghostPosition = inGhost.position; float distanceFromLastPoint = Utilities.GetDistanceP1(ghostPosition, lastPoint); if (distanceFromLastPoint >= kDistanceBetweenPoints) { this.AddPoint(ghostPosition); lastPoint = ghostPosition; } } }
public void SetupAtlasWithGridArray(List <int> inGridArray) { int inGridSize = (inGridArray[0]); int numObjects = (inGridArray[1]); int index = 2; for (int i = 0; i < numObjects; i++) { float a = (((float)(inGridArray[index])) * (float)inGridSize); float b = (((float)(inGridArray[index + 1])) * (float)inGridSize); float c = (((float)(inGridArray[index + 2])) * (float)inGridSize); float d = (((float)(inGridArray[index + 3])) * (float)inGridSize); minUV[i, 0] = (short)a; minUV[i, 1] = (short)b; maxUV[i, 0] = (short)c; maxUV[i, 1] = (short)d; index += 4; stWidth[i] = 0.5f * (float)(maxUV[i, 0] - minUV[i, 0]); stHeight[i] = 0.5f * (float)(maxUV[i, 1] - minUV[i, 1]); stWidth[i] *= Constants.kScreenMultiplierForShorts; stHeight[i] *= Constants.kScreenMultiplierForShorts; // if (Globals.deviceIPhone4) { // stWidth[i] *= 0.5f; // stHeight[i] *= 0.5f; // } rotationScale[i] = Utilities.GetDistanceP1(Utilities.CGPointMake(0, 0), Utilities.CGPointMake(stWidth[i], stHeight[i])); float thing = stWidth[i] / stHeight[i]; rotationAngle1[i] = Constants.HALF_PI - (float)Math.Atan(thing); rotationAngle2[i] = Constants.PI_ - (rotationAngle1[i] * 2.0f); } this.SetupVertices(1); this.SetupTextureCoordinates(0); }
public void BumpP1(CGPoint newVelocity, Player whoBy) { #if RACE_AS_PIGGY return; #endif if (bumpTimer > 0.0f) { #if NOT_FINAL_VERSION if (whoBy == (Globals.g_world.game).player) { } #endif return; } #if NOT_FINAL_VERSION if (whoBy == (Globals.g_world.game).player) { } #endif CGPoint bumpVelocity = Utilities.CGPointMake(newVelocity.x, newVelocity.y / 6.0f); if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Elephant) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if ((int)crossingThingType == (int)CrossingThingType.kCrossingThing_Sheep) { bumpMaxDistance = 20.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else { bumpMaxDistance = 5.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } bumpDirection = Utilities.Normalise(bumpVelocity); const float kMaxBumpSameDir = 30.0f; const float kMaxBumpOppDir = 80.0f; float xThing = bumpMaxDistance * bumpDirection.x; if (xSpeed > 0.0f) { if (xThing > kMaxBumpSameDir) { bumpMaxDistance = bumpDirection.x * kMaxBumpSameDir; } else if (xThing < -kMaxBumpOppDir) { bumpMaxDistance = -bumpDirection.x * kMaxBumpOppDir; } } else { if (xThing < -kMaxBumpSameDir) { bumpMaxDistance = -bumpDirection.x * kMaxBumpSameDir; } else if (xThing > kMaxBumpOppDir) { bumpMaxDistance = bumpDirection.x * kMaxBumpOppDir; } } bumpTimer = kCTBumpTime; }
public float BumpP1(CGPoint newVelocity, Player whoBy) { #if RACE_AS_PIGGY return(false); #endif CGPoint bumpVelocity = Utilities.CGPointMake(newVelocity.x, newVelocity.y - myFlock.speed); float powerSqr = Utilities.GetSqrDistanceP1(Utilities.CGPointMake(0.0f, myFlock.speed), newVelocity); if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley) { if (powerSqr > 120.0f) { if (whoBy == (Globals.g_world.game).player) { ((Globals.g_world.frontEnd).profile).QueueAchievement(Profile.Enum2.kAchievement_ShirleyThump); ((Globals.g_world.frontEnd).profile).FlushPendingAchievements(); } } if (powerSqr > 24.0f) { if (bumpTimer <= 0.25f) { (SoundEngine.Instance()).PlayFinchSound((int)Audio.Enum1.kSoundEffect_HitShirley); } } } if (bumpTimer > 0.0f) { return(0.0f); } if (flockAnimalType == FlockAnimalType.kFlockAnimalCow) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalSheep) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalZebra) { bumpMaxDistance = 3.2f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else if (flockAnimalType == FlockAnimalType.kFlockAnimalShirley) { bumpMaxDistance = 2.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } else { bumpMaxDistance = 5.0f * Utilities.GetDistanceP1(Utilities.CGPointMake(0.0f, 0.0f), bumpVelocity); } bumpDirection = Utilities.Normalise(bumpVelocity); bumpTimer = kBumpTime; return(powerSqr); }