SVector2 EvadeBehavior::Update(float deltaTime) { SVector2 returnForce = SVector2(0.0f, 0.0f); if (mPreviousDestination != SVector2(-1.0f, -1.0f)) { SVector2 targetVelocity = (mpAgent->GetDestination() - mPreviousDestination)/deltaTime; float maxSpeed = mpAgent->GetMaxSpeed(); float distFromTarget = Length(mpAgent->GetDestination() - mpAgent->GetPosition()); float expectedTime = distFromTarget/maxSpeed; mTargetDestination = mpAgent->GetDestination() + targetVelocity * expectedTime; // FLEE const float panicDistanceSq = maxSpeed * maxSpeed; if (DistanceSquared(mpAgent->GetPosition(), mpAgent->GetDestination()) > panicDistanceSq) { return SVector2( 0, 0); } SVector2 positionToDestination = mpAgent->GetPosition() - mTargetDestination; SVector2 desiredVelocity = Normalize(positionToDestination) * mpAgent->GetMaxSpeed(); returnForce = desiredVelocity - mpAgent->GetVelocity(); } mPreviousDestination = mpAgent->GetDestination(); return returnForce; }
SVector2 ArriveBehavior::Update(float deltaTime) { if (mActive) { SVector2 positionToDestination = mpAgent->GetDestination() - mpAgent->GetPosition(); SVector2 posToDestNorm = Normalize(positionToDestination); float maxSpeed = mpAgent->GetMaxSpeed(); SVector2 desiredVelocity = posToDestNorm * maxSpeed; float distSq = LengthSquared(positionToDestination); float velocitySq = LengthSquared(mpAgent->GetVelocity()); float slowingRadiusSq = 160000.0f; float stopRadiusSq = 25.0f; if (distSq < velocitySq) { if (distSq < slowingRadiusSq && distSq > stopRadiusSq ) { //desiredVelocity = -velocitySq/(2*sqrt(distSq)); desiredVelocity = posToDestNorm * maxSpeed * distSq/(slowingRadiusSq*slowingRadiusSq*slowingRadiusSq*slowingRadiusSq);// * maxSpeed/(distSq*distSq); } else if (distSq <= stopRadiusSq) { mpAgent->SetPosition(mpAgent->GetDestination()); desiredVelocity = SVector2(0.0f, 0.0f); } } return desiredVelocity - mpAgent->GetVelocity(); } return SVector2(0.0f, 0.0f); }
SVector2 PursuitBehavior::Update(float deltaTime) { SVector2 returnForce = SVector2(0.0f, 0.0f); if (mPreviousDestination != SVector2(-1.0f, -1.0f)) { SVector2 targetVelocity = (mpAgent->GetDestination() - mPreviousDestination)/deltaTime; //targetVelocity = Normalize(targetVelocity); float maxSpeed = mpAgent->GetMaxSpeed(); float distFromTarget = Length(mpAgent->GetDestination() - mpAgent->GetPosition()); float expectedTime = distFromTarget/maxSpeed; mTargetDestination = mpAgent->GetDestination() + targetVelocity * expectedTime; // SEEK SVector2 positionToDestination = mTargetDestination - mpAgent->GetPosition(); SVector2 desiredVelocity = Normalize(positionToDestination) * mpAgent->GetMaxSpeed(); returnForce = desiredVelocity - mpAgent->GetVelocity(); } mPreviousDestination = mpAgent->GetDestination(); return returnForce; }
void NPC::CheckCollision(float fSeconds, Map& map, Character& character) { // Check collision SRect bb = GetBoundingBox(); SRect newbb = bb + SVector2(mVelocity.x, 0.0f); SRect rightbb = map.GetBoundingBoxFromSegment(newbb.GetRightSegment(), *this, character); SRect leftbb = map.GetBoundingBoxFromSegment(newbb.GetLeftSegment(), *this, character); // Right collision if (mVelocity.x > 0.0f && rightbb.IsValid()) { mNPCData.mPosition.x += static_cast<int>(rightbb.min.x - bb.max.x) - 1.0f; } // Left collision else if (mVelocity.x < 0.0f && leftbb.IsValid()) { mNPCData.mPosition.x += static_cast<int>(leftbb.max.x - bb.min.x) + 1.0f; } else { mNPCData.mPosition.x += static_cast<int>(mVelocity.x); } // Check collision newbb = bb + SVector2(0.0f, mVelocity.y); SRect bottombb = map.GetBoundingBoxFromSegment(newbb.GetBottomSegment(), *this, character); SRect topbb = map.GetBoundingBoxFromSegment(newbb.GetTopSegment(), *this, character); // Bottom collision if (mVelocity.y > 0.0f && bottombb.IsValid()) { mNPCData.mPosition.y += static_cast<int>(bottombb.min.y - bb.max.y) - 1.0f; mVelocity.y = 0.0f; Graphics_DebugRect(newbb + sOffset, 0xff00ff); Graphics_DebugRect(bottombb + sOffset, 0xff0000); } // Top collision else if (mVelocity.y < 0.0f && topbb.IsValid()) { mNPCData.mPosition.y += static_cast<int>(topbb.max.y - bb.min.y) + 1.0f; mVelocity.y = 0.0f; Graphics_DebugRect(newbb + sOffset, 0xff00ff); Graphics_DebugRect(topbb + sOffset, 0xff0000); } else { mNPCData.mPosition.y += static_cast<int>(mVelocity.y); } }
bool Map::LoadLevel(const char* pLevelFile) { FILE* pFile = NULL; fopen_s(&pFile, pLevelFile, "r"); // Read map dimensions fscanf_s(pFile, "%*s %d", &mColumns); fscanf_s(pFile, "%*s %d", &mRows); fscanf_s(pFile, "%*s %d", &mTileSize); // Create tile buffer mTiles = new Tile[mColumns * mRows]; // Parse tile data fgetc(pFile); for(int y = 0; y < mRows; ++y) { for(int x = 0; x < mColumns; ++x) { const int index = x + (y * mColumns); mTiles[index].SetPosition(SVector2(static_cast<float>(x * mTileSize), static_cast<float>(y * mTileSize))); mTiles[index].SetSize(mTileSize); mTiles[index].SetType(fgetc(pFile) - '0'); //mTiles[index].SetWalkable(); TODO } fgetc(pFile); } //Close file fclose(pFile); return true; }
void DragSprite::Update(float deltaTime) { if(mVisible) { float x = Input_GetMouseScreenX(); float y = Input_GetMouseScreenY(); if(Input_IsMouseDown(Mouse::LBUTTON) && x - mPosition.x > 176 && y - mPosition.y < 16) { mVisible = false; } // Draggable Inventory else if(Input_IsMouseDown(Mouse::LBUTTON) && (x > mPosition.x && x < mPosition.x + mSprite.GetWidth() - 20) && (y > mPosition.y && y < mPosition.y + 30)) { mDragDown = true; } if(!Input_IsMouseDown(Mouse::LBUTTON) && mDragDown) { mDragDown = false; } if(mDragDown) { mPosition = SVector2(x - 75, y - 20); mSprite.Update(deltaTime); } } }
Inventory::Inventory(int inventorySlots, Raknet& raknet, Map& map, PlayerInfo& playerInfo, Character& character) : mInventorySlots(inventorySlots), mRaknet(raknet), mMap(map), mDragSprite( SVector2((float) SGE::Graphics_WindowWidth() - 300.0, 290.0f), false), mPlayerInfo(playerInfo), mCharacter(character) { }
SVector2 SeparationBehavior::Update(float deltaTime) { SVector2 steeringForce = SVector2(0.0f, 0.0f); const std::vector<Agent*>& agents = mpAgent->GetWorld().GetNearbyAgents(mpAgent->GetPosition()); unsigned int numNeighbors = agents.size(); for (unsigned int i = 0; i < numNeighbors; ++i) { SVector2 position = mpAgent->GetPosition(); SVector2 neighborPos = agents[i]->GetPosition(); SVector2 vectorAway = position - neighborPos; // STEP 2 - Normalize vector away vectorAway = Normalize(vectorAway); // STEP 3 - Divide by distance from neighbor //vectorAway /= dist; // STEP 4 - Accumulate in steering force steeringForce += vectorAway; } // SEEK //SVector2 positionToDestination = mpAgent->GetDestination() - mpAgent->GetPosition(); //positionToDestination = Normalize(positionToDestination); //SVector2 desiredVelocity = Normalize(positionToDestination + steeringForce) * mpAgent->GetMaxSpeed(); //SVector2 force = desiredVelocity - mpAgent->GetVelocity(); return steeringForce * mpAgent->GetMaxSpeed() - mpAgent->GetVelocity(); }
Equip::Equip(Raknet& raknet, PlayerInfo& playerInfo, Inventory& inventory) : mDragSprite( SVector2((float) SGE::Graphics_WindowWidth() - 800.0, 130.0f), false), mRaknet(raknet), mPlayerInfo(playerInfo), mInventory( inventory), mStats() { }
void MapData::SetTileInfo(float x, float y, int tile, int layer, int id) { Tile* temp; switch (layer) { case 1: { temp = &mLayer1[tile]; break; } case 2: { temp = &mLayer2[tile]; break; } case 3: { temp = &mLayer3[tile]; break; } case 4: { temp = &mLayer4[tile]; break; } default: { break; } } temp->SetPosition(SVector2(x, y)); temp->SetType(id); }
void Equip::Update(float deltaTime) { mDragSprite.Update(deltaTime); mStats.Update(deltaTime); mStats.SetPosition(mDragSprite.GetPosition() + SVector2(13.5f, 228.0f)); SVector2 position = mDragSprite.GetPosition(); float x = Input_GetMouseScreenX() - position.x; float y = Input_GetMouseScreenY() - position.y - 32; bool mouseDown = Input_IsMousePressed(Mouse::LBUTTON); // Exit Button if (mouseDown && x > 260 && x < 290 && y < 2) { mDragSprite.ToggleVisible(); } // Stat Button if ((mouseDown && x > 77 && x < 220 && y > 168 && y < 187)) { mStats.ToggleVisible(); } }
void Character::Update(float deltaTime, const Map& map) { const float kSpeed = 500.0f; //Check horizontal movement if (Input_IsKeyDown(Keys::RIGHT)) { mVelocity.x = kSpeed * deltaTime; } else if (Input_IsKeyDown(Keys::LEFT)) { mVelocity.x = -kSpeed * deltaTime; } else { mVelocity.x = 0.0f; } // Check collision SRect bb = GetBoundingBox(); SRect newbb = bb + SVector2(mVelocity.x, 0.0f); SRect rightbb = map.GetBoundingBoxFromSegment(newbb.GetRightSegment()); SRect leftbb = map.GetBoundingBoxFromSegment(newbb.GetLeftSegment()); // Right collision if (mVelocity.x > 0.0f && rightbb.IsValid()) { mPosition.x += (int)(rightbb.min.x - bb.max.x) - 1.0f; } // Left collision else if (mVelocity.x < 0.0f && leftbb.IsValid()) { mPosition.x += (int)(leftbb.max.x - bb.min.x) + 1.0f; } else { mPosition.x += (int)mVelocity.x; } //Check vertical movement //if (Input_IsKeyDown(Keys::DOWN)) //{ // mVelocity.y = kSpeed * deltaTime; //} //else if (Input_IsKeyDown(Keys::UP)) //{ // mVelocity.y = -kSpeed * deltaTime; //} //else //{ // mVelocity.y = 0.0f; //} if(!mJumping && Input_IsKeyPressed(Keys::UP)) { mVelocity.y = -30.0f; mJumping = true; } else { mVelocity.y += 100.0f * deltaTime; } mVelocity.y = Min(mVelocity.y, 30.0f); // Check collision newbb = bb + SVector2(0.0f, mVelocity.y); SRect bottombb = map.GetBoundingBoxFromSegment(newbb.GetBottomSegment()); SRect topbb = map.GetBoundingBoxFromSegment(newbb.GetTopSegment()); // Bottom collision if(mVelocity.y > 0.0f && bottombb.IsValid()) { mPosition.y += (int)(bottombb.min.y - bb.max.y) - 1.0f; mVelocity.y = 0.0f; mJumping = false; } // Top collision else if(mVelocity.y < 0.0f && topbb.IsValid()) { mPosition.y += (int)(topbb.max.y - bb.min.y) + 1.0f; mVelocity.y = 0.0f; } else { mPosition.y += (int)mVelocity.y; } }
void NPC::Update(float deltaTime, Map* map, Character& character) { int x = (RoundUp((int) mNPCData.mPosition.x + (mSprite.GetWidth() * 0.5), 32) / 32) - 1; int y = (RoundUp((int) mNPCData.mPosition.y + (mSprite.GetHeight() * 0.5), 32) / 32) - 1; int index = x + (y * mMapWidth); if (!mInit || !mNPCData.mCanMove) return; int tiles = mMapWidth * mMapHeight; // If we have reached our destination and are not fighting find a new place to walk if (mReachedDestination && !mBattling) { if (mNPCData.mHost) { mNPCData.mPathEnd = rand() % tiles; while (!map->GetWalkable(mNPCData.mPathEnd)) { mNPCData.mPathEnd = rand() % tiles; } RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID) ID_NPC_NEW_PATH); // Npc Array Slot bsOut.Write(mIndex); // End Position index bsOut.Write(mNPCData.mPathEnd); bsOut.Write(mNPCData.mPosition); mRaknet.mPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, mRaknet.mServerAddress, false); } } else if (!mNPCData.mStop) { SVector2 oldPosition = mNPCData.mPosition; mVelocity = SVector2(0.0f, 0.0f); // Smooths out Animation jitters for (int a = 0; a < 3; ++a) { // Move us towards are location if (mNPCData.mPathIndex < mPath.size()) { bool xDone = false; SVector2 position = mPath[mNPCData.mPathIndex]; CheckCollision(deltaTime, *map, character); if (mNPCData.mPosition.x < position.x - mNPCData.mMoveSpeed) { mVelocity.x += mNPCData.mMoveSpeed; } else if (mNPCData.mPosition.x > position.x + mNPCData.mMoveSpeed) { mVelocity.x -= mNPCData.mMoveSpeed; } else { // We are at the right x location xDone = true; } // Move the npc to the next position if (mNPCData.mPosition.y < position.y - mNPCData.mMoveSpeed) { mVelocity.y += mNPCData.mMoveSpeed; } else if (mNPCData.mPosition.y > position.y + mNPCData.mMoveSpeed) { mVelocity.y -= mNPCData.mMoveSpeed; } else { // We are at the next tile if (xDone) { if (mNPCData.mHost) { RakNet::BitStream bsOut; bsOut.Write((RakNet::MessageID) ID_NPC_POSITION); bsOut.Write(mIndex); // Array location bsOut.Write(mNPCData.mPathIndex); bsOut.Write(mNPCData.mPosition); mRaknet.mPeer->Send(&bsOut, HIGH_PRIORITY, RELIABLE_ORDERED, 0, mRaknet.mServerAddress, false); } ++mNPCData.mPathIndex; } } } else { mReachedDestination = true; } } Direction oldDirection = mDirection; SVector2 positionDifferance = mNPCData.mPosition - oldPosition; // Right if (positionDifferance.x > 0 && positionDifferance.y == 0) { if (oldDirection != right) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(true); mDirection = right; } } // Left else if (positionDifferance.x < 0 && positionDifferance.y == 0) { if (oldDirection != left) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(false); mDirection = left; } } // Up else if (positionDifferance.y > 0 && positionDifferance.x == 0) { if (oldDirection != up) { mAnimation.SetStartFrame(mFrames.WalkDownStart); mAnimation.SetEndFrame(mFrames.WalkDownEnd); mSprite.SetFlipH(false); mDirection = up; } } // Down else if (positionDifferance.y < 0 && positionDifferance.x == 0) { if (oldDirection != down) { mAnimation.SetStartFrame(mFrames.WalkUpStart); mAnimation.SetEndFrame(mFrames.WalkUpEnd); mSprite.SetFlipH(false); mDirection = down; } } // Up Right else if (positionDifferance.x > 0 && positionDifferance.y < 0) { if (oldDirection != rightDown) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(true); mDirection = rightDown; } } // Down Right else if (positionDifferance.x > 0 && positionDifferance.y > 0) { if (oldDirection != rightUp) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(true); mDirection = rightUp; } } // Up Left else if (positionDifferance.x < 0 && positionDifferance.y > 0) { if (oldDirection != leftUp) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(false); mDirection = leftUp; } } // Down Left else if (positionDifferance.x < 0 && positionDifferance.y < 0) { if (oldDirection != leftDown) { mAnimation.SetStartFrame(mFrames.WalkLeftStart); mAnimation.SetEndFrame(mFrames.WalkLeftEnd); mSprite.SetFlipH(false); mDirection = leftDown; } } if (positionDifferance.x != 0 || positionDifferance.y != 0) { mSprite.Update(deltaTime); mAnimation.AnimateSprite(deltaTime, mSprite); mAnimation.SetIsAnimating(true); } } if (GetStop()) { CheckCollision(deltaTime, *map, character); } }
void Character::Update(float deltaTime, const Map& map, const SVector2& renderOffset) { const float kSpeed = 256.0f; // Check horizontal movement if(Input_IsKeyDown(Keys::RIGHT)) { mVelocity.x = kSpeed * deltaTime; mSprite.SetRotation(1.575f); } else if(Input_IsKeyDown(Keys::LEFT)) { mVelocity.x = -kSpeed * deltaTime; mSprite.SetRotation(-1.575f); } else { mVelocity.x = 0.0f; } // Check collision SRect bb = GetBoundingBox(renderOffset); SRect newbb = bb + SVector2(mVelocity.x, 0.0f); SLineSegment tempRightLS(newbb.GetRightSegment().from.x - renderOffset.x, newbb.GetRightSegment().from.y - renderOffset.y, newbb.GetRightSegment().to.x - renderOffset.x, newbb.GetRightSegment().to.y - renderOffset.y); SLineSegment tempLeftLS(newbb.GetLeftSegment().from.x - renderOffset.x, newbb.GetLeftSegment().from.y - renderOffset.y, newbb.GetLeftSegment().to.x - renderOffset.x, newbb.GetLeftSegment().to.y - renderOffset.y); SRect rightbb = map.GetBoudingBoxFromSegment(tempRightLS); SRect leftbb = map.GetBoudingBoxFromSegment(tempLeftLS); Graphics_DebugRect(bb, 0xF04BC3); Graphics_DebugRect(newbb, 0x004BC3); Graphics_DebugRect(rightbb, 0xF04B00); Graphics_DebugRect(leftbb, 0xF000C3); // Right Collision if(mVelocity.x > 0.0f && rightbb.IsValid()) { mPosition.x += static_cast<int>(rightbb.min.x - bb.max.x) - 1.0f; } // Left Collision else if(mVelocity.x < 0.0f && leftbb.IsValid()) { mPosition.x += static_cast<int>(leftbb.max.x - bb.min.x) + 1.0f; } else { mPosition.x += static_cast<int>(mVelocity.x); } // Check vertical movement if(Input_IsKeyDown(Keys::DOWN)) { mVelocity.y = kSpeed * deltaTime; mSprite.SetRotation(3.15f); } else if(Input_IsKeyDown(Keys::UP)) { mVelocity.y = -kSpeed * deltaTime; mSprite.SetRotation(0.0f); } else { mVelocity.y = 0.0f; } // Check collision newbb = bb + SVector2(0.0f, mVelocity.y); SRect topbb = map.GetBoudingBoxFromSegment(newbb.GetTopSegment()); SRect bottombb = map.GetBoudingBoxFromSegment(newbb.GetBottomSegment()); // Top Collision if(mVelocity.y < 0.0f && topbb.IsValid()) { mPosition.y += static_cast<int>(topbb.max.y - bb.min.y) + 1.0f; } // Bottom Collision else if(mVelocity.y > 0.0f && bottombb.IsValid()) { mPosition.y += static_cast<int>(bottombb.min.y - bb.max.y) - 1.0f; } else { mPosition.y += static_cast<int>(mVelocity.y); } mPosition += mVelocity; }
void CWall3D::initPieces() { //cputimer::debug_interval tt0( "w3d init" ); assert( !mPiecesInited ); assert( !mFracturedPieces ); assert( !mPieces3D ); assert( mPiecesCombined.empty() ); const int QUADTREE_DEPTH = 2; //const int QUADTREE_DEPTH = 3; mQuadtree = TWallQuadNode::create( SVector2(0,0), mWall2D.getSize(), QUADTREE_DEPTH, &mQuadtreeNodeCount ); int i; int n = mWall2D.getPieceCount(); mPieces3D = new CWallPiece3D[n]; mFracturedPieces = new bool[n]; mPieceRestoreTimes = new float[n]; // init the leaf pieces for( i = 0; i < n; ++i ) { mPieces3D[i].init( *this, i ); mFracturedPieces[i] = false; mPieceRestoreTimes[i] = -1.0f; CWallPieceCombined* wpc = new CWallPieceCombined(); wpc->initBegin( *this, NULL, false ); wpc->initAddPiece( i ); wpc->initEnd( mQuadtree ); mPiecesCombined.push_back( wpc ); } // go through quadtree nodes and merge the pieces n = mQuadtreeNodeCount; for( i = 0; i < n; ++i ) { TWallQuadNode& node = mQuadtree[i]; assert( !node.getData().combined ); int npc = node.getData().leafs.size(); if( npc > 0 ) { CWallPieceCombined* wpc = new CWallPieceCombined(); wpc->initBegin( *this, &node, i==0 ); for( int j = 0; j < npc; ++j ) wpc->initAddPiece( node.getData().leafs[j]->getLeafIndex() ); wpc->initEnd( mQuadtree ); mPiecesCombined.push_back( wpc ); } } // init fade-in mesh if( mFadeInMesh ) { SMatrix4x4 m = mMatrix; m.getOrigin() += m.getAxisX() * (mWall2D.getSize().x*0.5f); m.getOrigin() += m.getAxisY() * (mWall2D.getSize().y*0.5f); m.getOrigin() += m.getAxisZ() * (-HALF_THICK); m.getAxisX() *= mWall2D.getSize().x * -1.01f; m.getAxisY() *= mWall2D.getSize().y * 1.01f; mFadeInMesh->mWorldMat = m; mFadeInMesh->addLightToParams( LIGHT_POS_1 + LIGHT_WOFF ); for( i = 0; i < RMCOUNT; ++i ) { CRenderableMesh* r = mFadeInMesh->getRenderMesh(eRenderMode(i)); if( !r ) continue; r->getParams().addVector3( "vNormal", m.getAxisZ() ); r->getParams().addTexture( "tAlpha", *mRestoreTexture ); } } // init AABB mWorldAABB.extend( SVector3(0,0,-HALF_THICK*2), 0.1f ); mWorldAABB.extend( SVector3(mWall2D.getSize().x,mWall2D.getSize().y,HALF_THICK*2), 0.1f ); mWorldAABB.transform( mMatrix ); mPiecesInited = true; mNeedsRenderingIntoVB = true; mNeedsRenderFadeMesh = true; }
void Map::Render(const SVector2& offset, OtherPlayers& otherPlayers) { // Used in bounding box checks later sOffset = offset; int tiles = mMapData.GetTileAmount(); SGE::Graphics_DebugUsageBegin("Ground"); // Render Ground for (int a = 0; a < tiles; ++a) { GroundTile* pTile = &mMapData.mLayer1[a]; int type = pTile->GetType(); if (type) { const SVector2& pos = pTile->GetPosition(); mSprites[type].SetPosition(pos + offset); mSprites[type].Render(); } } SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("MaskItems"); // Render Mask for (int a = 0; a < tiles; ++a) { Tile* pTile = &mMapData.mLayer2[a]; int type = pTile->GetType(); if (type) { const SVector2& pos = pTile->GetPosition(); mSprites[type].SetPosition(pos + offset); mSprites[type].Render(); } // Render Items if (mMapData.mLayer1[a].GetItemImageNumber() > 0 && GetItemActive(a)) { SVector2 pos = SVector2(mMapData.mLayer1[a].GetPosition().y, mMapData.mLayer1[a].GetPosition().x); // Bug int type = mMapData.mLayer1[a].GetItemImageNumber(); if (type > 0 && type < mNumberOfItems) { mItemSprites[type].mSprite.SetPosition(pos + offset); mItemSprites[type].mSprite.Render(); } } } SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("NPCs"); // Render NPCS for (int a = 0; a < mNumberOfNPCS; ++a) { mNPCS[a]->Render(offset); } SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("Players"); // Render Character mCharacter.Render(offset); // Render other players otherPlayers.Render(offset); SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("Extras"); // Render Extra for (int a = 0; a < tiles; ++a) { SVector2 pos = mMapData.mLayer3[a].GetPosition(); int type = mMapData.mLayer3[a].GetType(); mSprites[type].SetPosition(pos + offset); mSprites[type].Render(); } SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("Fringe"); // Render Fringe for (int a = 0; a < tiles; ++a) { SVector2 pos = mMapData.mLayer4[a].GetPosition(); int type = mMapData.mLayer4[a].GetType(); mSprites[type].SetPosition(pos + offset); mSprites[type].Render(); } SGE::Graphics_DebugUsageEnd(); SGE::Graphics_DebugUsageBegin("WeatherPaths"); mWeather.Render(offset); mPathFinding.Render(offset); SGE::Graphics_DebugUsageEnd(); }