Jump to content
  • Advertisement
Sign in to follow this  
Jaye05

Scrolling/Wraping issues....

This topic is 5096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been working on this for about 2 days now. My iso engine is rendering tiles that are 2:1 (46x23) from Left to Right and Top to Bottom. The render looks fine until I start moving about. The map doesn't wrap around correctly. I'm trying to wrap it along both axis so the map seems like the world is round. The Y Axis wrap is beautiful. However the X axis is.... another story... if I cross it from (0,0) to (99, 0) (the otherside) it puts me on tile number 9999 (which I should be on tile 99) (y*MaxX)+x (0*100)+99 = 99. I've got a screenshot of the render and each tile has it's number in the map array on top of it. maybe someone can help me... http://www.jo-solutions.com/shot.gif It's basically if you take notebook paper and wrap it around so the lines touch and run endlessly around... then shift the lines either up or down a row and it's like a candy cane's stripe... that I think is the issue. My render code.... (using SDL) I can't really paste the code here... it formats weird... but I'll try int BaseWidth = mTiles.GetWidth(); int BaseHeight = mTiles.GetHeight(); int MapX = mMap.GetXDim(); int MapY = mMap.GetYDim(); int thing = sizeof(mMap.mMap); for(int layer=0;layer < mMap.GetZDim();layer++) { //Let's get to our start location... //The camera is in the center... we've got to find the Top Left cell. int StartY = mCam.GetCamPos().y-CamOffsetY; int StartX = mCam.GetCamPos().x-CamOffsetX; CellCounter = (((StartY)*MapX)+(StartX))*(layer+1); tmpY=0; tmpY -= BaseHeight/2; //Screen coords tmpX= 0; IsOdd = mCam.IsOdd(); for(int y=0;y < MapY;y++) { if(IsOdd) { tmpX-=BaseWidth/2; IsOdd=false; } else IsOdd=true; for(int x=0; x < MapX; x++) { //Scroll the map around... if(CellCounter>=(MapX*MapY)*(layer+1)) { CellCounter-=(MapX*MapY)*(layer+1); } if(CellCounter<0) { CellCounter+=(MapX*MapY)*(layer+1); } if(x<mCam.GetXView() && y<mCam.GetYView() && mMap.mMap[CellCounter].mTile > 0) { int YOffset=mTiles.GetHeight(mMap.mMap[CellCounter].mTile) - BaseWidth/2; int LayerOffset=mMap.mMap[CellCounter].mHeight*BaseHeight; TileDest.x = tmpX; TileDest.y = tmpY-YOffset-LayerOffset; TileSource.x=0; TileSource.y=0; TileSource.w=BaseWidth; TileSource.h=mTiles.GetHeight(mMap.mMap[CellCounter].mTile); //So there aren't poky corners... if(x==mCam.GetXView()-1) { if(IsOdd) TileSource.w -= BaseWidth/2; } if(y==mCam.GetYView()-1) { TileSource.h -= BaseHeight/2; } SDL_BlitSurface(mTiles.GetTile(mMap.mMap[CellCounter].mTile), &TileSource, mScreen, &TileDest); drawString(mScreen, mSplashFont, tmpX, tmpY, "%d", CellCounter); } CellCounter++; tmpX+=BaseWidth; } tmpX=0; tmpY+=BaseHeight/2; } } Thanks Jaye

Share this post


Link to post
Share on other sites
Advertisement
Fixed it! instead of wrappnig CellCounter I wrap StartX and StartY before sending them to CellCounter. I increment StartX and Y in their appropriate loops and set CellCounter once every X loop to the new X Y... it wokrs perfectly!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!