Пример #1
0
void doRender(SDL_Renderer *renderer, GameState *game,SDL_Rect mCam)
{


  //set the drawing color to blue
    SDL_SetRenderDrawColor(renderer, 0, 0, 255, 255);

    //Clear the screen (to blue)
    SDL_RenderClear(renderer);
    for(int i=0;i<COLUMNS;i++)
    {
        for(int j=0;j<ROWS;j++)
        {
            if(playfield[i][j]==0)
            {
                SDL_Rect camera2={j*TILESIZE-mCam.x,i*TILESIZE-mCam.y,TILESIZE,TILESIZE};
                SDL_RenderCopy(renderer,game->gTileTexture.mTexture,&game->TileClip[0],&camera2);
            }
             if(playfield[i][j]==1)
            {
                SDL_Rect camera2={j*TILESIZE-mCam.x,i*TILESIZE-mCam.y,TILESIZE,TILESIZE};
                SDL_RenderCopy(renderer,game->gTileTexture.mTexture,&game->TileClip[1],&camera2);
            }
            if(playfield[i][j]==2)
            {
                SDL_Rect camera3={j*TILESIZE-mCam.x,i*TILESIZE-mCam.y,TILESIZE,TILESIZE};
                SDL_RenderCopy(renderer,game->gTileTexture.mTexture,&game->TileClip[2],&camera3);
            }
            if(playfield[i][j]==3)
            {
                SDL_Rect camera2={j*TILESIZE-mCam.x,i*TILESIZE-mCam.y,TILESIZE,TILESIZE};
                SDL_RenderCopy(renderer,game->gTileTexture.mTexture,&game->TileClip[3],&camera2);
            }
        }

    }

//
//    SDL_Rect camera={0,0,SCREEN_WIDTH,SCREEN_HEIGHT};
//    SDL_RenderCopy(renderer,game->gTileTexture.mTexture,&mCam,&camera);

    SDL_SetRenderDrawColor(renderer, 255,255, 255, 255);
        SDL_Rect tmp;
    //set the drawing color to white
   // SDL_Rect rect = {game->playerEntity.mPosX-mCam.x,game->playerEntity.mPosY-mCam.y, 32, 32 };
    for(int i=0;i<5;i++)
        SDL_RenderCopy(renderer,game->mPlayerTexture,&game->playerEntity[i].spriteFacing,getRenderPosition(game->playerEntity[i].object.rect,mCam,tmp));

//    SDL_Rect AIrect = {game->AiEntity.mPosX-mCam.x,game->AiEntity.mPosY-mCam.y, 32, 32 };
//    SDL_RenderCopy(renderer,game->AiEntity.object.mTexture,&game->AiEntity.SpriteFacing,&AIrect);
   // SDL_RenderFillRect(renderer, &rect);
   for(int i=0;i<game->nrOfAi;i++)
   {
        whatSprite(&game->AiEntity[i]);
        SDL_RenderCopy(renderer,game->mAiTexture,&game->AiEntity[i].spriteFacing,getRenderPosition(game->AiEntity[i].object.rect,mCam,tmp));
   }
        SDL_RenderPresent(renderer);

}
// return bottom 32-bits of the render position
status_t AudioStreamOut::getRenderPosition(uint32_t *frames)
{
    uint64_t position64 = 0;
    status_t status = getRenderPosition(&position64);
    if (status == NO_ERROR) {
        *frames = (uint32_t)position64;
    }
    return status;
}
    void PlayerComponent::onSimulationUpdate(float elapsedTime)
    {
        float const minVerticalScaleToInitiateClimb = 0.35f;
        float const minDistToLadderCentre = _node->getScaleX() * 0.15f;
        gameplay::Vector3 const ladderVeritcallyAlignedPosition(_ladderPosition.x, getRenderPosition().y, 0.0f);
        bool const isClimbRequested = fabs(_verticalMovementScale) > minVerticalScaleToInitiateClimb;
        bool const isPlayerWithinLadderClimbingDistance = getRenderPosition().distance(ladderVeritcallyAlignedPosition) <= minDistToLadderCentre;

        // Initiate climbing if possible
        if(_climbingEnabled && isClimbRequested && isPlayerWithinLadderClimbingDistance)
        {
            if (_state != State::Climbing)
            {
                // Attach the player to the ladder at the render position rather than the physics position
                _node->setTranslation(gameplay::Vector3(ladderVeritcallyAlignedPosition.x, ladderVeritcallyAlignedPosition.y, 0));
            }

            _state = State::Climbing;

            // Physics will be disabled so that we can translate the player vertically along the ladder
            _node->setTranslationX(_ladderPosition.x);
            _character->resetVelocityState();
            _character->setPhysicsEnabled(false);
        }

        if(_state == State::Climbing)
        {
            // Move the player along the ladder using the input vertical movement scale
            float const elapsedTimeMs = elapsedTime / 1000.0f;
            float const verticalMovementSpeed = _movementSpeed / 2.0f;
            float const previousDistToLadder = _ladderPosition.distanceSquared(_node->getTranslation());
            gameplay::Vector3 const previousPosition = _node->getTranslation();
            _node->translateY((_verticalMovementScale * verticalMovementSpeed) * elapsedTimeMs);

            // If the player has moved away from the ladder but they are no longer intersecting it then restore their last position
            // and zero their movement, this will prevent them from climing beyond the top/bottom
            if(!_climbingEnabled && previousDistToLadder < _node->getTranslation().distanceSquared(_ladderPosition))
            {
                _node->setTranslation(previousPosition);
                _verticalMovementScale = 0.0f;
            }
        }
    }
Пример #4
0
void LLVOTree::updateSpatialExtents(LLVector3& newMin, LLVector3& newMax)
{
	F32 radius = getScale().length()*0.05f;
	LLVector3 center = getRenderPosition();

	F32 sz = mBillboardScale*mBillboardRatio*radius*0.5f; 
	LLVector3 size(sz,sz,sz);

	center += LLVector3(0, 0, size.mV[2]) * getRotation();
	
	newMin.set(center-size);
	newMax.set(center+size);
	mDrawable->setPositionGroup(center);
}
Пример #5
0
void WaterPlane::setShaderParams( SceneRenderState *state, BaseMatInstance* mat, const WaterMatParams& paramHandles)
{
   // Set variables that will be assigned to shader consts within WaterCommon
   // before calling Parent::setShaderParams

   mUndulateMaxDist = mGridElementSize * mGridSizeMinusOne * 0.5f;

   Parent::setShaderParams( state, mat, paramHandles );   

   // Now set the rest of the shader consts that are either unique to this
   // class or that WaterObject leaves to us to handle...    

   MaterialParameters* matParams = mat->getMaterialParameters();

   // set vertex shader constants
   //-----------------------------------   
   matParams->setSafe(paramHandles.mGridElementSizeSC, (F32)mGridElementSize);
   //matParams->setSafe( paramHandles.mReflectTexSizeSC, mReflectTexSize );
   if ( paramHandles.mModelMatSC->isValid() )
      matParams->set(paramHandles.mModelMatSC, getRenderTransform(), GFXSCT_Float4x4);

   // set pixel shader constants
   //-----------------------------------

   ColorF c( mWaterFogData.color );
   matParams->setSafe( paramHandles.mBaseColorSC, c );   
   
   // By default we need to show a true reflection is fullReflect is enabled and
   // we are above water.
   F32 reflect = mPlaneReflector.isEnabled() && !isUnderwater( state->getCameraPosition() );
   
   // If we were occluded the last frame a query was fetched ( not necessarily last frame )
   // and we weren't updated last frame... we don't have a valid texture to show
   // so use the cubemap / fake reflection color this frame.
   if ( mPlaneReflector.lastUpdateMs != REFLECTMGR->getLastUpdateMs() && mPlaneReflector.isOccluded() )
      reflect = false;

   //Point4F reflectParams( getRenderPosition().z, mReflectMinDist, mReflectMaxDist, reflect );
   Point4F reflectParams( getRenderPosition().z, 0.0f, 1000.0f, !reflect );
   
   // TODO: This is a hack... why is this broken... check after
   // we merge advanced lighting with trunk!
   //
   reflectParams.z = 0.0f;
   matParams->setSafe( paramHandles.mReflectParamsSC, reflectParams );

   VectorF reflectNorm( 0, 0, 1 );
   matParams->setSafe(paramHandles.mReflectNormalSC, reflectNorm ); 
}
void LLVOPartGroup::setPixelAreaAndAngle(LLAgent &agent)
{
	// mPixelArea is calculated during render
	F32 mid_scale = getMidScale();
	F32 range = (getRenderPosition()-LLViewerCamera::getInstance()->getOrigin()).length();

	if (range < 0.001f || isHUDAttachment())		// range == zero
	{
		mAppAngle = 180.f;
	}
	else
	{
		mAppAngle = (F32) atan2( mid_scale, range) * RAD_TO_DEG;
	}
}
Пример #7
0
void afxMooring::advanceTime(F32 dt)
{
  Parent::advanceTime(dt);

  if (hookup_with_chor)
  {
    afxChoreographer* chor = arcaneFX::findClientChoreographer(chor_id);
    if (chor)
    {
      chor->setGhostConstraintObject(this, ghost_cons_name);
      hookup_with_chor = false;
    }
  }

  Point3F pos = getRenderPosition();
}