Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

J2xC

smooth scrolling using tiles

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

OK... I say I want to implement smooth scrolling for a SIMPLE platform game I''m going to develop(still in design phase): the easiest method is going to be one big buffer from which I just move the viewpoint along... of course this is too slow. I was thinking to do it with tiles in such a way that I have 2 tiles more than fit on the screen vertically and horizontally, so the buffer is formed from a grid of tiles and then the viewpoint is blitted to the primary surface from the correct part of the buffer. Will this be OK to implement? Is there a better way? Is this just too slow? All suggestions welcome... J2xC ------------------------------ About time I put something funny here? I think so too...

Share this post


Link to post
Share on other sites
Advertisement
Right, thats good.

What other good alternatives exist... ?

I suffer from extreme slowness at making decisions... it takes me a week or two to decide on anything slightly significant as you''ve all probably noticed... =)

J2xC

------------------------------
About time I put something funny here? I think so too...

Share this post


Link to post
Share on other sites
Well, tiling is your best bet, and if you don''t want to attach a clipper like "aig" said to do, you can just modify your RECTS (for the tile bitmap source surface) every time you scroll. BTW, I''m writing an article on tiling in DirectX, so you can check it out when it''s done.

Martin

Share this post


Link to post
Share on other sites
Hold On!!!

I have tried using that method you suggested, J2xC, (the one with a slightly larger "canvas", and you blit sections of that canvas to the main window). There are problems, however:

If you have animating tiles, you will have to redraw the canvas, or try to draw them "on top" of the canvas each frame (which gets complicated). The same goes for things like doors, switches, etc.

Also, if you are using DirectX, then you will need to store your "canvas" in system memory (because you can''t have surfaces larger than the primary buffer stored in video memory i think...?). This means that every frame you will be blitting from System->Video which is MUCH slower than Video->Video.

So, how do we get this ideal video->video combination?

Here is my method, which, after trying both ways, i must say I prefer:

-Have all your tiles stored in vid mem.
-When you draw, just have two nested loops (for x... for y) and draw all your tiles to the backbuffer.
-The tiles on the edge must be clipped manually (or else if you are using DX they won''t get drawn)

Repeat this each frame.

The advantage is that you don''t waste memory on a large canvas, and that if a tile changes, it will get redrawn anyway, you don''t have to loop through your tiles and say "are you different from last frame..? ah okay i will draw you then".

AND it is much faster (believe me!) than blitting from system->video.


That''s just my opinion. Please don''t flame me now.

If you need any more information don''t hesitate to ask!


wiseGuy

Share this post


Link to post
Share on other sites
Thanks for the help...
the above method seems interesting and I''m definitiely going to consider it seriously, but one thing... you CAN store buffers greater than the primary surface in system memory... I''m about 99% sure of this...

Just a little note tho... correct me if I''m wrong...

J2xC



------------------------------
About time I put something funny here? I think so too...

Share this post


Link to post
Share on other sites
If your tile scrolling engine is going to scroll horizontally or vertically (not both) create a buffer that is double the size of the way you want to scroll. (horizontal scroller buffer would be [screen width*2,screen height])
If the engine is to scroll both horizontally and vertically, double buffer in both directions (buffer is [screen width*2,screen height*2])
As the viewport offset of the buffer changes, you draw only the borders of the viewport. The area in the center of the screen would only be changed if there are blits to be performed.

If you only created it 2 tiles more as you thought, you''d still have to draw the whole screen each time.

And as far as copying system mem to vid mem goes...
- The time spent copying system mem would be faster than redrawing the entire frame each time.
- Copy by DWORDs, not BYTEs.

(Of course this tile engine method is a generalization; if EVERY tile animates, redrawing the screen each time would be faster.)

Share this post


Link to post
Share on other sites
quote:
Original post by wise_Guy

[quote]
That''s just my opinion. Please don''t flame me now.

If you need any more information don''t hesitate to ask!

wiseGuy



Hey wise_guy. There is no reason why you would get flamed from that idea, as I think it is definetly one of the best ways to go about it. For the simple reason, that you won''t have to store huge images in memory..


Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!