Jump to content
  • Advertisement
Sign in to follow this  
soundsystem

smooth tile scrolling?

This topic is 5066 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

The way I have my scrolling now, it moves in steps of tile size, 16 pixels each step, for example.. and it looks choppy. How would I make it so it moves smooth?

Share this post


Link to post
Share on other sites
Advertisement
By rendering slightly more than the camera can see and moving the camera [or the tile surface] by smaller increments, loading tiles as needed.

There are a few better explinations than that online, as it's a common question. I've put off implimenting the scrolling for my game, so don't have much more insight, sorry :[

My game will likely move each tile's rect since it doesn't have a camera, and since the map bounds are unknown to the client.

Share this post


Link to post
Share on other sites
You can reduce the choppiness by reducing the amount of pixels per time/step that the camera and character travel. Instead of having the character move from tile to tile with every step, you can have him move less pixels per time and 'walk' to the next tile through several steps.

Share this post


Link to post
Share on other sites
Thanks for the replies.
I have a problem with scrolling in general (not smooth scrolling)..I can get a camera to work fine, but I can't get the camera to follow the hero.. when the hero moves, the camera does also but the hero goes past it.. below is the function that draws the map, the heros x/y (in tile coords, not pixels) are passed to this function.


void DrawMap(int off_x, int off_y) {
off_x -= SW/2;
off_y -= SH/2;
if (off_x < 0) off_x = 0;
if (off_y < 0) off_y = 0;

for (int x=0; x<SW; ++x)
for (int y=0; y<SH; ++y)
DrawTile(x, y, map[x+off_x][y+off_y]);
}



Share this post


Link to post
Share on other sites
instead of moving your character keep him stationary and move the map around him. so basically when the user pushes a key it scrolls the map and doesnt move the character.

Share this post


Link to post
Share on other sites
Is that how the other side scrollers are done? in mind I have Streets of Rage / Megaman / Sonic.. etc. I want to eventually make the game 2 (or more) players.

Share this post


Link to post
Share on other sites
I've seen it done like described above. Like this, you can scroll the map, and just rotate between two or more pictures of the character to make it look like they're walking in you want to.

Share this post


Link to post
Share on other sites
Yes that is WAY too inefficient..

Bitblit the entire screen on your backbuffer by OFFSET amount, eg.. 1,2,3,4,.. in your case 16..

only replace a ROW or COLUMN of tiles (one FOR loop now instead of a double loop) that you lose when the screen shifts.. you will have to create four steps for it.. such as to determine which direction you are going and which tiles to replace. It means you will bitblt the tile offset size of width and height, so if you lose 4 pixels on a shift, what I did on mine was blit the main tile width and height difference to replace it, such as:

tempWidth = tileXPosition - 4;
tempHeight = tileYPosition - 4;

invoke BitBlt(or bltFast for Directx)...,x,y,tempWidth,tempHeight

etc..

You may have to decrease the 16 down to a lower number because you will fly all around, the speed increase will be tremendous.

Please rate me too :) <lower left>

Above method c2004 BrainDead Software, All Rights Reserved.

Share this post


Link to post
Share on other sites
hmm.. right now I am blitting the character to the middle of the screen and just movin the camera around.. and it looks normal unless you hit the edge.. he doesn't keep going as he should. Does anyone have any basic scrolling example? the ones I've found are too complex, they add a lot of other things to the examples, like sound, collision detection, projectiles, animation..

drarem: alright, I want to get this working properly first before optimizing it though. I just want a character that is able to move through a map that is larger than the screen..

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!