cCuboid cPiece::RotateMoveHitBox(int a_NumCCWRotations, int a_MoveX, int a_MoveY, int a_MoveZ) const { ASSERT(a_NumCCWRotations == (a_NumCCWRotations % 4)); cCuboid res = GetHitBox(); res.p1 = RotatePos(res.p1, a_NumCCWRotations); res.p2 = RotatePos(res.p2, a_NumCCWRotations); res.p1.Move(a_MoveX, a_MoveY, a_MoveZ); res.p2.Move(a_MoveX, a_MoveY, a_MoveZ); return res; }
void CComStation::ConstructWithoutObjectCreationL() { //initilize TextureObject iTextureObject = CTextureObject::New(GetCurrentPositionNormilized(), &CGame::Game->iImageStore->GetImage(EImageIdBuildingComStation), COMSTATION_WIDTH, COMSTATION_HEIGHT, iZCor, 0, 1, 0, 0.625); //create hitBox iHitBox = CHitBox::New(&iCoordinates, &iObjectReflected, TSize(COMSTATION_HITBOX_WIDTH, COMSTATION_HITBOX_HEIGHT)); //however, will not be used,since clouds will //sound object iSoundObject = CSoundObject::New(ESoundFileId_Radio_Signals, GetHitBox()); iSoundObject->PlayRepeatHitBox(); }
void Barrier::Animate() { currentFrame++; if (currentFrame > maxFrame) { currentFrame = 1; } if (tiled) // Barrier type 4 { // Manually repeat the texture; sf::Texture.setRepeated() will not work because it interferes with animation for (int i = 0; i < tiledSize.x; ++i) { for (int j = 0; j < tiledSize.y; ++j) { // get a pointer to the current tile's quad sf::Vertex* quad = &VerticeList[(j + i * tiledSize.y) * 4]; // define its 4 corners // We subtract GetHitBox().width and height in order for GetPosition() to return the top-left corner quad[0].position = sf::Vector2f(GetPosition().x - GetHitBox().width / 2 + i * 16, GetPosition().y - GetHitBox().height / 2 + j * 16); quad[1].position = sf::Vector2f(GetPosition().x - GetHitBox().width / 2 + (i + 1) * 16, GetPosition().y - GetHitBox().height / 2 + j * 16); quad[2].position = sf::Vector2f(GetPosition().x - GetHitBox().width / 2 + (i + 1) * 16, GetPosition().y - GetHitBox().height / 2 + (j + 1) * 16); quad[3].position = sf::Vector2f(GetPosition().x - GetHitBox().width / 2 + i * 16, GetPosition().y - GetHitBox().height / 2 + (j + 1) * 16); // define its 4 texture coordinates // With animated barriers the textures should be in a straight, horizontal line, so y values do not change // Frames are 1-indexed, but the textures are 0-indexed, hence the (currentFrame - 1) quad[0].texCoords = sf::Vector2f((currentFrame - 1) * 16, 0); quad[1].texCoords = sf::Vector2f((currentFrame) * 16, 0); quad[2].texCoords = sf::Vector2f((currentFrame) * 16, 16); quad[3].texCoords = sf::Vector2f((currentFrame - 1) * 16, 16); } } } else // Barrier type 2 { // Size of one frame sf::Vector2i frameSize(GetSprite().getTexture()->getSize().x / maxFrame, GetSprite().getTexture()->getSize().y); SetTextureRect(frameSize.x * (currentFrame - 1), 0, GetTextureRect().width, GetTextureRect().height); } collided = false; }
FieldCharacter * FieldCharacter::Clone() { FieldCharacter *pCloneCharacter = new FieldCharacter(GetId(), GetName(), characterStandingAnimationIds, characterWalkingAnimationIds, characterRunningAnimationIds); pCloneCharacter->SetHitBox(GetHitBox()->Clone()); pCloneCharacter->SetAnchorPosition(GetAnchorPosition()); pCloneCharacter->SetClickRect(GetClickRect()); pCloneCharacter->interactionLocation = interactionLocation; pCloneCharacter->SetCondition(pCondition != NULL ? pCondition->Clone() : NULL); return pCloneCharacter; }
bool FiniteStateCharacter::StandingOnAir() { //Checks if the FiniteStateCharacter is standing on a non-solid tile bool onAir = true; //Calculate the indices of the tiles at the left and right sides of the bottom of the sprite int tileSize = map->GetTileSize(); int leftTileX = location.X/tileSize; int tileY = ((location.Y + GetHitBox().Height) + velocity.Y)/tileSize; int rightTileX = (location.X + GetHitBox().Width)/tileSize; //check if the tiles or objects in these locations are solid if ((map->GetIsSolid(leftTileX, tileY) || map->GetIsSolid(rightTileX, tileY)) || (objects->GetIsSolid(leftTileX, tileY) || objects->GetIsSolid(rightTileX, tileY))) { //A tile was solid onAir = false; } return onAir; }//End StandingOnAir()
void CComStation::ConstructL() { //initilize TextureObject iTextureObject = CTextureObject::New(GetCurrentPositionNormilized(), &CGame::Game->iImageStore->GetImage(EImageIdBuildingComStation), COMSTATION_WIDTH, COMSTATION_HEIGHT, iZCor, 0, 1, 0, 0.625); //create hitBox iHitBox = CHitBox::New(&iCoordinates, &iObjectReflected, TSize(COMSTATION_HITBOX_WIDTH, COMSTATION_HITBOX_HEIGHT)); //however, will not be used,since clouds will //create the Flagpole that shows what side the HQ is on TPoint lFlagPolePosition = GetCurrentPositionNormilized(); lFlagPolePosition.iX += COMSTATION_FLAG_POLE_OFFSET_X; iFlagPole = CFlagPole::New(lFlagPolePosition, iConflictSide); CFighterPilotThePacificWar::FighterGame->iGameData->GetMap()->AddGameObject(iFlagPole); //sound object iSoundObject = CSoundObject::New(ESoundFileId_Radio_Signals, GetHitBox()); iSoundObject->PlayRepeatHitBox(); }
RectangleWH FieldCharacter::GetBoundsForInteraction() { if (IsInteractionPointExact()) { return RectangleWH(interactionLocation.GetX(), interactionLocation.GetY(), 1, 1); } RectangleWH hitboxBoundingBox = GetHitBox()->GetBoundingBox(); return RectangleWH( GetVectorAnchorPosition().GetX() + hitboxBoundingBox.GetX(), GetVectorAnchorPosition().GetY() + hitboxBoundingBox.GetY(), hitboxBoundingBox.GetWidth(), hitboxBoundingBox.GetHeight()); }
void cPlayer::DrawRect(int tex_id,float xo,float yo,float xf,float yf) { int screen_x,screen_y; cRect hitbox = GetHitBox(); int hitbox_w,hitbox_h; screen_x = GetX() + SCENE_Xo; screen_y = GetY() + SCENE_Yo; hitbox_w = hitbox.right - hitbox.left; hitbox_h = hitbox.top - hitbox.bottom; glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,tex_id); glBegin(GL_QUADS); glTexCoord2f(xo,yo); glVertex3i(screen_x - (TILE_SIZE*frame_texture_tiles - hitbox_w)/2,screen_y - (TILE_SIZE*frame_texture_tiles - hitbox_h)/2,screen_y); glTexCoord2f(xf,yo); glVertex3i(screen_x + (TILE_SIZE*frame_texture_tiles + hitbox_w)/2,screen_y - (TILE_SIZE*frame_texture_tiles - hitbox_h)/2,screen_y); glTexCoord2f(xf,yf); glVertex3i(screen_x + (TILE_SIZE*frame_texture_tiles + hitbox_w)/2,screen_y + (TILE_SIZE*frame_texture_tiles + hitbox_h)/2,screen_y); glTexCoord2f(xo,yf); glVertex3i(screen_x - (TILE_SIZE*frame_texture_tiles - hitbox_w)/2,screen_y + (TILE_SIZE*frame_texture_tiles + hitbox_h)/2,screen_y); glEnd(); glDisable(GL_TEXTURE_2D); }
void CWaterSplash::ConstructL() { //create HitBox and AnimationPlayer iHitBox = CHitBox::New(&iCoordinates, &iObjectReflected, TSize(WATER_SPLASH_WIDTH, WATER_SPLASH_HEIGHT)); iTextureObject = CTextureObject::New(GetCurrentPositionNormilized(), &CGame::Game->iImageStore->GetImage(EImageIdExplosionWaterSplash), WATER_SPLASH_WIDTH, WATER_SPLASH_HEIGHT, iZCor, 0, 1, 0, 1); iTextureObject->SetNewTValue(0, 1); //Animation Player SAnimationRequest lDefaultRequest; lDefaultRequest.FramesUntilSwitch = WATER_SPLASH_TOTAL_TIME_FOR_EXPLOSION / 5; lDefaultRequest.TextureId = &CGame::Game->iImageStore->GetImage(EImageIdExplosionWaterSplash); lDefaultRequest.TotalImages = 5; lDefaultRequest.TotalLength = 64; lDefaultRequest.Width = WATER_SPLASH_WIDTH; lDefaultRequest.LowerT = 0; lDefaultRequest.UpperT = 1; iAnimationPlayer = CAnimationPlayer::New(iTextureObject, lDefaultRequest); iAnimationPlayer->PlayAnimation(new SAnimationRequest(lDefaultRequest)); iSoundObject = CSoundObject::New(ESoundFileId_Water_Splash, GetHitBox()); iSoundObject->PlayHitBox(); }
void CJapaneseRocketman::ConstructL() { iTextureObject = CTextureObject::New(GetCurrentPositionNormilized(), &CGame::Game->iImageStore->GetImage(EImageIdGroundUnitJapaneseRocketmanStanding), JAPANESE_ROCKETMAN_WIDTH, JAPANESE_ROCKETMAN_HEIGHT, iZCor, 0, 1, 0, 1); //need to create bounding Hitbox iHitBox = CHitBox::New(&iCoordinates, BASIC_GROUND_UNIT_NUMBER_OF_ORIGINIAL_HITBOX_POINTS, BASIC_GROUND_UNIT_NUMBER_OF_PROJECTED_HITBOX_POINTS, &iPixelsPerMoveX, &iPixelsPerMoveY, &iObjectReflected, &iAngle, CJapaneseRocketman::CollisionPoints); //create GunWeapon iGrendaeLauncher = CGrenadeLauncher::New(false, &iCoordinates, &iAngle, JAPANESE_ROCKETMAN_GRENADE_LAUNCHER_X_LOCATION, JAPANESE_ROCKETMAN_GRENADE_LAUNCHER_Y_LOCATION, &iObjectReflected, &iConflictSide); //Animation Player SAnimationRequest lDefaultRequest;//not really used iAnimationPlayer = CAnimationPlayer::New(iTextureObject, lDefaultRequest); UpdateCurrentState(EGroundUnitStateStanding);//resets the animation player if(iObjectReflected) { iAngle = 0; iPixelsPerMoveX = iSpeed * CMath::GraphicsCosTable(iAngle); iTextureObject->ReflectOverYAxis(); iCoordinates = iTextureObject->ReturnCurrentFixPoint(); } iSoundObject = CSoundObject::New(ESoundFileId_Male_Painful, GetHitBox()); }
bool FieldCharacter::TestCollisionAtPosition(Vector2 position, ForegroundElement *pElement, CollisionParameter *pParam) { return GetHitBox()->IsCollision(position, pElement->GetHitBox(), Vector2(0, 0), pParam); }
bool FieldCharacter::TestCollisionAtPosition(Vector2 position, HitBox *pHitBox, CollisionParameter *pParam) { return GetHitBox()->IsCollision(position, pHitBox, Vector2(0, 0), pParam); }
bool FieldCharacter::TestCollisionAtPosition(Vector2 position, Crowd *pCrowd, CollisionParameter *pParam) { return GetHitBox()->IsCollision(position, pCrowd->GetHitBox(), Vector2(0, 0), pParam); }
bool FieldCharacter::TestCollisionAtPosition(Vector2 position, FieldCharacter *pCharacter, CollisionParameter *pParam) { return GetHitBox()->IsCollision(position, pCharacter->GetHitBox(), pCharacter->GetPosition(), pParam); }
bool FieldCharacter::IsCollision(HitBox *pHitBox, CollisionParameter *pParam) { return GetHitBox()->IsCollision(GetPosition(), pHitBox, Vector2(0, 0), pParam); }
bool FieldCharacter::IsCollision(Crowd *pCrowd, CollisionParameter *pParam) { return GetHitBox()->IsCollision(GetPosition(), pCrowd->GetHitBox(), Vector2(0, 0), pParam); }
bool FieldCharacter::IsCollision(FieldCharacter *pCharacter, CollisionParameter *pParam) { return GetHitBox()->IsCollision(GetPosition(), pCharacter->GetHitBox(), pCharacter->GetPosition(), pParam); }