You are right. Thank you for you to loose time to explain me different problems or compatibility.
After these corrections, I updated the first code. (I didn't remove the alpha channel neither the using of sprite 3D. Because sprites 3D get specific transformations which could be very useful for the future effects. If we remove also alpha channel and sprite 3D, processing ressources are different and allow us to use parallax which is executed in the 3rd code.)
Even if it's not electronic, this scrolling could be a good occasion to create a game, studying the basic mechanism.
Code: Select all
; >>>> /!\ ONLY WITH DX7 (PB4.40) <<<<
Procedure RedStone(X.I, Y.I, W.I, H.I)
Box(X + 0, Y + 0, W - 1, H - 1, RGBA(255, 0, 0, 255) )
Box(X + 1, Y + 1, W - 1, H - 1, RGBA(64, 0, 0, 255) )
Box(X + 1, Y + 1, W - 2, H - 2, RGBA(128, 0, 0, 255) )
EndProcedure
Procedure CreateTileTest(No.I, Wi.I, He.I)
CreateImage(No, Wi, He, 32)
StartDrawing(ImageOutput(No) )
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, Wi, He, RGBA(0, 0, 0, 0) )
DrawingMode(#PB_2DDrawing_AlphaBlend)
For K = 0 To 1
For J = -2 To 2 Step 2
For I = 0 To 1
RedStone((I + J) * 8, I * 8 + K * 16, 16, 8)
Next
Next
Next
StopDrawing()
CreateSprite(No, Wi, He, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(No) )
DrawAlphaImage(ImageID(No), 0, 0)
StopDrawing()
CreateSprite3D(No, No)
Start3D()
DisplaySprite3D(No, 0, 0)
Stop3D()
EndProcedure
Procedure CreateTileMono(No.I, Wi.I, He.I, Coef.I)
CreateImage(No, Wi, He, 32)
StartDrawing(ImageOutput(No) )
DrawingMode(#PB_2DDrawing_AlphaChannel)
Box(0, 0, Wi, He, RGBA(0, 0, 0, 0) )
DrawingMode(#PB_2DDrawing_AlphaBlend)
For I = 0 To 15
Color = RGB(0, Coef * 8 + (7 - I / 2), Coef * 16 + (15 - I) )
Box(0, I * 2, Wi, 2, RGBA(Red(Color), Green(Color), Blue(Color), 255) )
Next
StopDrawing()
CreateSprite(No, Wi, He, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(No) )
DrawAlphaImage(ImageID(No), 0, 0)
StopDrawing()
CreateSprite3D(No, No)
Start3D()
DisplaySprite3D(No, 0, 0)
Stop3D()
EndProcedure
InitSprite()
InitSprite3D()
InitKeyboard()
ExamineDesktops()
Dw = DesktopWidth(0)
Dh = DesktopHeight(0)
Dd = DesktopDepth(0)
Wi = 32
He = 32
OpenScreen(Dw, Dh, Dd, "")
CreateTileTest(1, Wi, He)
For I = 0 To 15
CreateTileMono(I + 2, Wi, He, I)
Next I
Global Dim Tile(255, 31)
For I = 0 To 31
For X = 0 To 255
Tile(X, I) = 1
Next
Next
For I = 0 To 15
For X = 0 To 255
Tile(X, 15 - I) = I + 2
Next
Next
For X = 0 To 255
For I = Int(10. + Cos(X / 8.) * 8.) To 15
Tile(X, I) = 1
Next
Next
Repeat
Delay(1)
Start3D()
If OffsetTileX <= 0
OffsetTileX = 0
OffsetX = 0
EndIf
If OffsetTileX => ((255 - (Dw / 32) ) )
OffsetTileX = ((255 - (Dw / 32) ) )
OffsetX = 32 - 1
EndIf
For XS3 = 0 - 32 To Dw - 1 Step 32
For YS3 = 0 To Dh - 1 Step 32
;Debug Str(XS3 / 32 + OffsetTileX) + "; " + Str(YS3 / 32)
XX = XS3 / 32 + OffsetTileX
If XX => 0
Tile = Tile(XX, YS3 / 32)
If Tile
DisplaySprite3D(Tile, XS3 + OffsetX, YS3)
EndIf
EndIf
Next
Next
Stop3D()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Right)
If OffsetXAccel > -16
OffsetXAccel - 2
EndIf
EndIf
If KeyboardPushed(#PB_Key_Left)
If OffsetXAccel < 16
OffsetXAccel + 2
EndIf
EndIf
OffsetX + OffsetXAccel
If OffsetX > 31
OffsetX - 32
OffsetTileX - 1
EndIf
If OffsetX < 0
OffsetX + 32
OffsetTileX + 1
EndIf
If OffsetXAccel > 0
OffsetXAccel - 1
EndIf
If OffsetXAccel < 0
OffsetXAccel + 1
EndIf
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()