@DB User 2006+ :
Yes, I use my PurePLUGIN system because it initialize all thing for my new plugin
Here is a small demo attached to this post for thoses that wanna try it and give me the frame rate (perfs) depending on their specs...
Here is the demo source commented:
`SETUP Display mode and bitmap format handling alpha transparency.
Flush Video Memory
Set Display Mode 640, 480, 32
Sync On : Sync Rate 0
Set Bitmap Format 21
` Define default tiles sizes and options to use with layers.
Set Default Tile Width 32
Set Default Tile Height 32
Set Default Tile Transparency 1
` Call the function to prepare images to use with tiles.
PrepareGRAPHICS()
` Assign images to tiles.
PrepareTILES()
` Call the functions to create the layers with their properties.
PrepareLAYER( 1 ) ` Layer 1 : Background moon and stars.
Set Layer Properties 1, 1, 0
PrepareLAYER( 2 ) ` Layer 2 : Clouds.
Set Layer Properties 2, 1, 0
PrepareLAYER( 3 ) ` Layer 3 : Mountains.
Set Layer Properties 3, 1, 0
PrepareLAYER( 4 ) ` Layer 4 : Trees.
Set Layer Properties 4, 1, 0
PrepareLAYER( 5 ) ` Layer 5 : Decorations.
Set Layer Properties 5, 1, 0
` Main demonstration loop
Repeat
Update DBal ` Update Tiles/Sprites animations frames.
` Scroll the clouds each 8 times.
Inc Count, 1 : If Count = 8 : Scroll Layer 2, 1, 0 : Count = 0 : Endif
` Calculate user scrolling for 3 layers depending on keyboard.
XMove = RightKey() - LeftKey()
If XMove <> 0
XSHIFT = XSHIFT + XMove
XScroll = XMove / Abs( XMove )
` Scroll layer 3, 1 times / 6
If XShift = 3 : Scroll Layer 3, XScroll, 0 : Endif
` Scolle layer 4, 2 times / 6
If XShift = 2 Or XShift = 4 : Scroll Layer 4, XScroll, 0 : Endif
If XShift < 0 : XShift = XShift + 6 : Endif
If Xshift > 7 : XShift = XShift - 6 : Endif
` Scroll layer 5 each time user want.
Scroll Layer 5, XMove, 0
Endif
` Display all layers on screen on order of distance.
Paste Layer 1, 0, 0, Bitmap Width() + 32, 320
Paste Layer 2, 0, 64, Bitmap Width() + 32, 192
Paste Layer 3, 0, 288, Bitmap Width() + 32, 416
Paste Layer 4, 0, 352, Bitmap Width() + 32, 448
Paste Layer 5, 0, 288 , Bitmap Width() + 32, 480
Set Cursor 0, 0 : Print Screen FPS()
Sync
Until SpaceKey() = 1
End
` Prepare all layers using DATA defined below.
Function PrepareLAYER( LayerID )
Select LayerID
Case 1 : Restore BACKGROUNDPART : EndCase
Case 2 : Restore CLOUDYPART : EndCase
Case 3 : Restore MOUNTAINSPART : EndCase
Case 4 : Restore TREESPART : EndCase
Case 5 : Restore DECORATIONPART : EndCase
EndSelect
READ LayerXSize : READ LayerYSize
Create Layer LayerID, LayerXSize, LayerYSize
For YLoop = 0 To LayerYSize - 1
For XLoop = 0 To LayerXSize - 1
READ LayerDATA
Set Layer Tile LayerID, XLoop, YLoop, LayerDATA
Next XLoop
Next YLoop
EndFunction
` Load the main image and cut it into 32x32 small images.
Function PrepareGRAPHICS()
File$ = "Media/Demo01GFX.png"
If File Exist( File$ ) = 1
Load Image "Media/Demo01GFX.png", 1, 1
IWidth = Image Width( 1 ) : IHeight = Image Height( 1 )
Create Bitmap 1, IWidth, IHeight
Paste Image 1, 0, 0
Delete Image 1 : CurrentTILE = 0
For Yloop = 0 to IHeight - 32 Step 32
For XLoop = 0 To IWidth - 32 Step 32
Inc CurrentTILE, 1
Get Image CurrentTILE, XLoop, YLoop, XLoop + 32, YLoop + 32, 1
Next XLoop
Next YLoop
Delete Bitmap 1
Endif
EndFunction
` Prepare tiles and tiles animations.
Function PrepareTILES()
` Create tile 1 using image 1
Create Tile 1, 1
` Create animation list 1
Create DBal 1, "ANIM;01;02;03;04;05;06;07;08;41;42;43;44;45;46;47;48;"
` Assign Animation list 1 to tile 1
Set DBal To Tile 1, 1
` Define animation 1 frames per second ( 50=50 frames/second)
Set DBal Speed 1, 50
` Start Animation
Play DBal 1
` Same than for tile 1, Create tile 2 with image 9
Create Tile 2, 9
Create DBal 2, "ANIM;09;10;11;12;13;14;15;16;49;50;51;52;53;54;55;56;"
Set DBal To Tile 2, 2
Set DBal Speed 2, 50
Play DBal 2
Create Tile 3, 57
Create DBal 3, "ANIM;17;18;19;20;21;22;23;24;57;58;59;60;61;62;63;64;"
Set DBal To Tile 3, 3
Set DBal Speed 3, 50
Play DBal 3
` Create all non animated tiles.
Restore TILELISTS
Repeat
Read TileID : Read TileIMAGEID
If TileID > MAXTILE Then MAXTILE = TileID
If TileID > 0 And TileIMAGEID > 0
Create Tile TileID, TileIMAGEID
Endif
Until TileID = 0 And TileIMAGEID = 0
EndFunction
` Only here to force compiler to include some DarkBASIC Professional DLL.
Function COMPILER_Includes()
Null = Memblock Exist(1)
Null = Bitmap Exist(1)
Null = Image Exist(1)
Null = Sprite Exist(1)
Null = PP Initialized()
Null = EXT Initialized()
Null = MBC Initialized()
Null = IMG Initialized()
Null = SPR Initialized()
Null = Rgb(1,1,1)
EndFunction
` Tile definition. structure : TileID, ImageID
TILELISTS:
Data 4, 25, 5, 33
Data 6, 26, 7, 34
Data 8, 27, 9, 28, 10, 35, 11, 36, 12, 29, 13, 30
Data 14, 37, 15, 38
Data 16, 31, 17, 32, 18, 39, 19, 40
Data 20, 65, 21, 66, 22, 67, 23, 68, 24, 73, 25, 74, 26, 75, 27, 76
Data 28, 69, 29, 70, 30, 71, 31, 72, 32, 77, 33, 78, 34, 79, 35, 80
Data 36, 81, 37, 82, 38, 83, 39, 84, 40, 85, 41, 86, 42, 87, 43, 88
Data 44, 89, 45, 90, 46, 91, 47, 92, 48, 93, 49, 94, 50, 95, 51, 96
Data 52, 97, 53, 98, 54, 99, 55,100, 56,101, 57,102, 58,103, 59,104
Data 60,105, 61,106, 62,107, 63,108, 64,109, 65,110, 66,111, 67,112
Data 0, 0
` Mountains layer tile definition.
MOUNTAINSPART:
Data 24, 4
Data 36,37,38,39,40,41,42,43,36,37,38,39,40,41,42,43,36,37,38,39,40,41,42,43
Data 44,45,46,47,48,49,50,51,44,45,46,47,48,49,50,51,44,45,46,47,48,49,50,51
Data 52,53,54,55,56,57,58,59,52,53,54,55,56,57,58,59,52,53,54,55,56,57,58,59
Data 60,61,62,63,64,65,66,67,60,61,62,63,64,65,66,67,60,61,62,63,64,65,66,67
` Trees layer tile definition.
TREESPART:
Data 20, 3
Data 8,9,8,9,8,9,8,9,8,9,8,9,8,9,8,9,8,9,8,9
Data 10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11,10,11
Data 12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13,12,13
` Ground and flames layer tile definition.
DECORATIONPART:
Data 20, 6
Data 0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0
Data 0,2,0,0,0,0,2,0,0,0,0,2,0,0,0,0,2,0,0,0
Data 0,3,0,0,0,0,3,0,0,0,0,3,0,0,0,0,3,0,0,0
Data 0,4,0,0,0,0,4,0,0,0,0,4,0,0,0,0,4,0,0,0
Data 0,5,0,0,0,0,5,0,0,0,0,5,0,0,0,0,5,0,0,0
Data 14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,14,15,
` Clouds layer tile definition.
CLOUDYPART:
Data 20, 4
Data 20,21,22,23,20,21,22,23,20,21,22,23,20,21,22,23,20,21,22,23
Data 24,25,26,27,24,25,26,27,24,25,26,27,24,25,26,27,24,25,26,27
Data 28,29,30,31,28,29,30,31,28,29,30,31,28,29,30,31,28,29,30,31
Data 32,33,34,35,32,33,34,35,32,33,34,35,32,33,34,35,32,33,34,35
` Background with moon tile definition.
BACKGROUNDPART:
Data 20, 10
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,16,17,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,18,19,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
A small shot of the scroll demo:
Of course, layers can be saved/loaded to/from disk