Jump to content
  • Advertisement

Archived

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

Alpha_ProgDes

scrolling. it's a mystery to me!

This topic is 5409 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 looked at some sites (though not many). from what i've read, you don't "draw" the background every time you move your character. (mind you the screen IS scrolling not static) but the most i can understand (for right now of course) is that you do redraw the background when it moves then draw the character(s). i don't quite understand the mechanics of how blitting and moving the background is done. seeing there are, seemingly, so many to do it. does anyone have a good explanation or know a good site that explains it well? edit: it seems someone posted and then deleted. cuz there's no way that a post with no replies can just up 10-15 spots for no reason. also i wanted to make myself clearer. [edited by - Alpha_ProgDes on February 27, 2004 11:38:36 AM]

Share this post


Link to post
Share on other sites
Advertisement
As you said, there are so many ways to do it.

I would imagine that most games these days would use an API like DirectX or OpenGL to draw sprites (characters, enemies etc.) and backgrounds on the screen. In that case, they are probably drawing the whole image (background, sprites, effects, everything) every frame. That does use more processor time than only drawing things that change, but these days your average Commander Keen-style game, done this way, uses about the same percentage of the processor time as a ''guess the number'' game.

If you want to get moderately oldskool, you can manage your own screen buffer and do all your blitting yourself. Probably the easiest way to do it is to have your entire world as one big bitmap, and then just blit the currently visible portion onto the screen. The basic idea is that the screen has an offset into the world (topleftX, topleftY) and you just copy the section of the world bitmap, from (topleftX, topleftY) to (topleftX+screenWidth, topleftY+screenHeight), onto the screen.

Share this post


Link to post
Share on other sites
If you want to do scrolling old school, you have to break your rendering function into three parts.

1) Draw background ONLY IF scrollX and/or scrollY have changed

2) Draw character - this one needs a bit of explaining. Look at steps A - B

A) Draw the background that is under the character. This will effectivly erase the character.

B) Draw the character in the new position.

Share this post


Link to post
Share on other sites
In the "Articles & Resources" section are some articles about diferent kinds of scrolling, did you see those already?

Share this post


Link to post
Share on other sites
The best way to look at it is that you''re not actually moving anything except a camera which views the world. To decide what is shown in each frame, you look at the camera''s position and calculate it from there. In terms of drawing it, the simplest method is just to redraw everything each time; the background, then the characters, whether they move or not.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
quote:
Original post by Alpha_ProgDes
i take it you''ll have to have a high FPS rate.
i mean if you didn''t then they''d be alot of flickering.
To avoid flickering, you use double(or tripple) buffering, which means you don''t draw directly to the screen. Instead, you draw to a buffer, and when you''re done drawing you tell the computer to display the entire image.

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!