Archived

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

Pzh

Scrolling background

Recommended Posts

Pzh    122
Hi to all ! I want to do intro in game as a scrolling background with text. On first view it''s simple. But i have problems with speed, because i need copy all screen, to scroll it up. Also i have text which move up with other speed than background, so simple copy Primary.BltFast(0,0,Primary,Rect(0,1,SCR_W,SCR_H),0); not work. I need scroll it in back buffer, than put textlayer on it , than flip to primary, also need refresh buffer with fone without text, so 3 fullscreen blittings... I saw this samples in many game, i thing it have beautifull solve. May you help me ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Don''t use BltFast, use Blt. Then you can use a clipper, copy your huge background into a surface and scroll it.

Share this post


Link to post
Share on other sites
megajocke    123
It doesn''t makle much difference Blt / BltFast, but don''t use a
clipper (they are slower), clip it manually instead. The clippers
main purpose is for using in windowed mode.

Share this post


Link to post
Share on other sites
Mr Bakbugawk    122
How is clipping done manually if you use the hardware blitter? Do you mean you just see what parts of the surface are going to be on the screen, create a new surface for that part and then blt? This has confused me before.

Share this post


Link to post
Share on other sites
Pzh    122
Let i tell promblem in other words: Need to scroll two layers
with different speeds.One Layer(background) - fullscreen,non-transparen,other (top layer) also fullscreen - transparent(no alpha , only Color Key ).


Ok, now let''s i show how i do it, i sure that is not correct solve. Its work very slow on P233 with 1Mb Video, it look not good,because Quake ,for example, make more difficult work and not have problems with speed.I think that because i need do two fullscreen blittings + one flip (BackBuffer also must be in System Memory when Video = 1Mb,so flip makes as blitting ) , but how i can do without this ...

May be you have other point of view on this problem,and can give
other solution.



SCREEN_WIDTH = 640;
SCREEN_HEIGHT = 480
16Bit mode
/////////////////////////////////////////////////////////////
Initialization [Calling once on start]
////////////////////////////////////////////////////////////
0 Step - InitDirectDraw; // BackBuffer attached to PrimaryBuffer

{Now creating big surface with height >> ScreenHeight, it
will be filled with background image }
1 Step - Fone = CreateSurfaceInSystemMemory(SCREEN_W,SCREEN_H*10);

{Create One else buffer for text, text will be draw on it }
2 Step - TextLayer = CreateSurfaceInSystemMemory(SCREEN_W,SCREEN_H*10);

3 Step - Fill Fone with image data and out text on TextLayer
End Initialization


/// Variables - Current Positions on Fone and TextLayer.
var
FonePosition:integer;
TextLayerPosition:integer;



//////////////////////////////////////////////////////////////
Begin Game Cycle [Calling by OnIdle Event]
////////////////////////////////////////////////////////////
1 Step - Copy on BackBuffer Fone in X=0 Y=0 from FoneRect:0,FonePosition,SCREEN_WIDTH,FonePosition+SCREEN_HEIGHT

2 Step - Put transparently Textlayer on Backbuffer to X=0,Y=0
from TextLayerRect:0,TextLayerPosition,SCREEN_WIDTH,TextLayerPosition+SCREEN_HEIGHT

3 Step - Copy BackBuffer to Primary buffer ( FlipMethod )

4 Step - Increment of FonePosition (+1) and TextLayerPosition (+2).
//////////////////////////////////////////////////////////////
End Game Cycle
/////////////////////////////////////////////////////////////


Share this post


Link to post
Share on other sites