voici son code en version 5.10 corrigé (la version 5.21 en dessous )
Code : Tout sélectionner
Global xres.w , yres.w , loop.w ,xp.w , yp.w , t.s , tptr.w , sco.b
#ScreenWidth = 800 : #ScreenHeight = 600 : #ScreenDepth = 32
#scrw = 800
#scrh = 600
#centerofscrw = #scrw/2
#centerofscrh = #scrh/2
#scrd = 32
SSum.w = 8000 ; Amount of Stars
Cspeed.f=22
CameraZ.f=0
xres = 800 ; ScreenWidth
yres = 600 ; ScreenHeight
sco = 0
tptr = 1
t.s = " "
t.s = t.s + "SINUS SCROLL JMG@2014 PUREBASIC !!!..............."
t.s = t.s + "POUR DU BASIC ...... "
t.s = t.s + "C'EST PLUTOT FLUIDE ............ "
t.s = t.s + " "
Gosub InitStarField
;-------- Init all needed Stuff --------
InitSprite()
InitKeyboard()
InitMouse()
InitSound()
LoadModule(1, "dgroove.xm")
OpenScreen(#scrw,#scrh,#scrd,"jmg")
SetFrameRate(60)
UsePNGImageDecoder() ; Needed to work with PNG Image
font = LoadSprite (#PB_Any, "1.PNG") ; Load the font PNG as Sprite
StartDrawing(ScreenOutput())
For l = 0 To 479
Restore couleur
For i = 0 To 479
Read.l coul
Plot(l, i, coul)
Next i
Next l
StopDrawing()
For i = 0 To 29
GrabSprite(i + 1, i * 8, i* 16, 240 - i * 8, 16)
Next
CentreX = (#ScreenWidth - SpriteWidth(1)) / 2
CentreY = (#ScreenHeight - SpriteHeight(1)) / 2
Vitesse.f = 1.7
Angle.f = 0
Amplitude = 280
Pas.f = 3.8
;-------- MainLoop --------
PlayModule(1)
Repeat
;///////////////////////////////
For i = 1 To 30
DisplayTransparentSprite(i, CentreX + i * 4, CentreY + Sin((Angle + i * Pas * 2) * 0.0174533) * Amplitude)
Next i
Angle + Vitesse
;//////////////////////////////
cco = 0
For cc = 0 To 25
letter = Asc(Mid(t.s, tptr+cc, 1))-31
yCharPos = letter / 10
xCharPos = letter % 10
If xCharPos = -1 : xCharPos = 9
ElseIf xCharPos > 0 : xCharPos = xCharPos - 1
EndIf
ClipSprite(font, xCharPos*32, yCharPos*33, 31, 32)
DisplayTransparentSprite(font, sco+cco, 300+50*Sin((cc+cco+sco+m)/120))
cco = cco + 32
Next
m = m -5
sco = sco -3
;
If sco < -32
tptr = tptr + 1
sco = sco + 32
EndIf
;
If tptr > Len(t.s)-30
tptr = 1
EndIf
StartDrawing(ScreenOutput())
DrawingMode(1)
Gosub DrawStarField
StopDrawing()
Gosub MoveCamera
FlipBuffers()
ClearScreen($0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;--------- Procs / Subs -------------
; #### INITSTARFIELD ####
InitStarField:
; Structure of a star ...
Structure _3DStar
x.f ; X-Coordinate
y.f ; Y-Coordinate
z.f ; Z-Coordinate
EndStructure
; Init Starfield ...
Dim Stars._3DStar(SSum)
For dummy = 0 To SSum
Stars(dummy)\x = Random(10000)-5000
Stars(dummy)\y = Random(10000)-5000
Stars(dummy)\z = 100 + Random(1000)
Next dummy
Return
; ### Move Camera ###
MoveCamera:
If CameraZ>1000
Direction=-1
ElseIf CameraZ<-1000
Direction=1
EndIf
If Direction=1 And Cspeed<10
Cspeed=Cspeed+0.1
ElseIf Direction=-1 And Cspeed>-10
Cspeed=Cspeed-0.1
EndIf
CameraZ=CameraZ+Cspeed
Return
; #### Draw StarField ####
DrawStarField:
For dummy = 0 To SSum
If Stars(dummy)\z<CameraZ
Stars(dummy)\z=CameraZ+1000
ElseIf Stars(dummy)\z>(CameraZ+1000)
Stars(dummy)\z=CameraZ
EndIf
SX = Stars(dummy)\x / (Stars(dummy)\z-CameraZ)*100+#centerofscrw
SY = Stars(dummy)\y / (Stars(dummy)\z-CameraZ)*100+#centerofscrh
If (SX<#scrw) And (SY<#scrh) And (SX>1) And (SY>1)
b.f = 255-(((Stars(dummy)\z)-CameraZ)*(255./1000.))
c=Int(b)
Plot ( SX, SY, RGB(c,c,c))
EndIf
Next dummy
Return
DataSection
couleur :
Data.l $13, $30, $50, $70, $8E, $AE, $CF, $EC
Data.l $FF, $EB, $CF, $AF, $8E, $71, $50, $30
Data.l $0, $30914, $61632, $92454, $D3373, $104193, $144FB5, $185CD2
Data.l $1A65E7, $185CD2, $144FB4, $114193, $D3373, $A2554, $51632, $30A15
Data.l $1D2D, $314B, $4569, $5785, $6BA3, $7EC1, $90DC, $9CEE
Data.l $90DB, $7FC2, $6BA3, $5785, $4569, $314B, $1D2C, $D12
Data.l $62518, $B3E27, $F5837, $136F46, $178755, $1CA165, $1FB673, $22C67D
Data.l $20B773, $1CA166, $178755, $136F46, $F5837, $B3F28, $62518, $30F0A
Data.l $152516, $233E25, $315735, $3F6D43, $4D8652, $5B9F62, $67B56F, $70C478
Data.l $67B56E, $5BA062, $4D8752, $3E6D43, $325635, $243E26, $152417, $80F0A
Data.l $152209, $24390F, $324F15, $3F651A, $4E7C20, $5C9226, $69A62C, $72B42F
Data.l $69A62C, $5C9226, $4E7C20, $40641A, $324F15, $24390E, $152209, $90E04
Data.l $22230B, $393A13, $50511A, $666621, $7C7E29, $939631, $A7AA38, $B5B83C
Data.l $A7AA37, $939631, $7C7E2A, $656621, $50521B, $393A13, $22230B, $E0E05
Data.l $423411, $5E4919, $785D1F, $927226, $AD872D, $C89C34, $DFAE3B, $EFBB3F
Data.l $DEAE3B, $C79C34, $AD872D, $927227, $785D1F, $5D4A18, $423412, $271E0A
Data.l $251A12, $3E2C1E, $573C2A, $6E4D35, $875F41, $A0704D, $B68058, $C58A5F
Data.l $B58057, $A0704D, $875F41, $6E4D35, $573D29, $3E2B1E, $251A12, $F0A07
Data.l $211513, $372321, $4E302D, $633D39, $784C46, $8F5953, $A3665F, $B06E66
Data.l $A3655E, $8F5A53, $794B46, $623D39, $4E312D, $372220, $211514, $D0808
Data.l $C0609, $1D0F14, $311921, $44232F, $562C3B, $693649, $7D4056, $8E4961
Data.l $9A4F6A, $8E4962, $7D4056, $693648, $562C3B, $44232F, $311921, $1D0F14
Data.l $1D101B, $311B2D, $44263F, $573050, $6B3B62, $7E4673, $8F4F83, $9B568E
Data.l $8F5083, $7E4673, $6A3B61, $573050, $45263E, $301B2D, $1D101A, $C070B
Data.l $C0912, $1E142C, $31214A, $452F69, $583C84, $6D49A3, $8157C0, $9262DA
Data.l $9E6BED, $9262DB, $8157C0, $6D4AA2, $583C85, $462F69, $32224B, $1E152C
Data.l $211D42, $2E2A5D, $3B3676, $484190, $564EAB, $635AC5, $6E63DC, $766BEC
Data.l $6E64DC, $6259C6, $554EAB, $48418F, $3B3676, $2F2A5C, $211D41, $141227
Data.l $18003F, $220058, $2C0070, $350089, $3F00A3, $4900BD, $5100D2, $5700E1
Data.l $5100D1, $4800BC, $3F00A3, $350089, $2C0070, $220059, $18003E, $E0025
Data.l $23003E, $320059, $3F0071, $4D008A, $5C00A3, $6A00BD, $7600D3, $7F00E2
Data.l $7700D2, $6A00BD, $5C00A4, $4D0089, $400071, $320058, $23003F, $150025
Data.l $220029, $310039, $3E0049, $4B0059, $59006A, $66007A, $720088, $7B0092
Data.l $730088, $67007A, $59006A, $4A0059, $3E0049, $300039, $220028, $140018
Data.l $22031C, $310328, $3D0433, $4B053E, $59064A, $670755, $73085F, $7B0966
Data.l $73085F, $670855, $590649, $4A053E, $3D0433, $300428, $22021C, $140111
Data.l $220511, $300718, $3E081E, $4A0B25, $590D2C, $670E33, $721038, $7B113D
Data.l $721039, $670E33, $590C2C, $4A0A25, $3E091F, $300718, $220510, $14030A
Data.l $29130E, $3A1B13, $4B2219, $5A291F, $6C3125, $7C382A, $8B3E2F, $954332
Data.l $8B3F2F, $7C382A, $6C3025, $5A291E, $4A2219, $3B1A14, $2A130E, $190B08
Data.l $E0800, $221400, $382100, $4F2F00, $643B00, $7A4800, $915500, $A56100
Data.l $B36900, $A56000, $925600, $7B4800, $643B00, $4F2F00, $382100, $221300
Data.l $120D00, $2C2100, $4A3800, $684E00, $836300, $A17A00, $BF9000, $D9A400
Data.l $EBB200, $D9A400, $BF9100, $A17A00, $836400, $684E00, $4A3900, $2C2200
Data.l $D0D00, $1D1F00, $323400, $464900, $595C00, $6C7100, $808500, $929700
Data.l $9EA400, $919700, $808600, $6C7100, $585B00, $464800, $323300, $1E1F00
Data.l $1B2C00, $273E00, $314F00, $3B6000, $477300, $528500, $5C9400, $629F00
Data.l $5B9400, $518500, $477300, $3C6100, $315000, $263E00, $1B2C00, $101A00
Data.l $50E00, $B2100, $133700, $1A4D00, $216200, $287800, $308F00, $36A200
Data.l $3BB000, $37A200, $308E00, $297900, $216200, $1A4E00, $133800, $B2100
Data.l $93722, $D4D31, $11633F, $15794C, $198F5A, $1DA669, $20B975, $22C67D
Data.l $20B975, $1CA568, $18905B, $15784C, $11633E, $D4E30, $93723, $62114
Data.l $4344, $5F62, $7A7D, $9497, $B0B4, $CCD0, $E3E8, $F4F9
Data.l $E3E8, $CCD0, $B1B5, $9597, $7A7D, $6062, $4344, $2829
Data.l $2B42, $3E5E, $4E77, $5F90, $71AC, $82C7, $91DD, $9CEE
Data.l $92DE, $83C7, $71AD, $5F91, $4E77, $3D5D, $2B41, $1A27
Data.l $20812, $4132C, $81F48, $B2C66, $F3881, $12469E, $1552BC, $185DD5
Data.l $1A65E7, $185DD5, $1552BB, $12459F, $F3881, $B2D66, $82049, $5132C
Data.l $40011, $8002A, $D0046, $120063, $17007C, $1C0099, $2200B5, $2600CE
Data.l $2900DF, $2500CE, $2100B5, $1C0099, $17007C, $120063, $D0046, $80029
EndDataSection
; Epb
ET voici le code en V 5.21
Code : Tout sélectionner
Global xres.w , yres.w , loop.w ,xp.w , yp.w , t.s , tptr.w , sco.b
#ScreenWidth = 800 : #ScreenHeight = 600 : #ScreenDepth = 32
#scrw = 800
#scrh = 600
#centerofscrw = #scrw/2
#centerofscrh = #scrh/2
#scrd = 32
SSum.w = 8000 ; Amount of Stars
Cspeed.f=22
CameraZ.f=0
xres = 800 ; ScreenWidth
yres = 600 ; ScreenHeight
sco = 0
tptr = 1
t.s = " "
t.s = t.s + "SINUS SCROLL JMG@2014 PUREBASIC !!!..............."
t.s = t.s + "POUR DU BASIC ...... "
t.s = t.s + "C'EST PLUTOT FLUIDE ............ "
t.s = t.s + " "
Gosub InitStarField
;-------- Init all needed Stuff --------
InitSprite()
InitKeyboard()
InitMouse()
InitSound()
LoadMusic(1, "dgroove.xm")
OpenScreen(#scrw,#scrh,#scrd,"jmg")
SetFrameRate(60)
UsePNGImageDecoder() ; Needed to work with PNG Image
font = LoadSprite (#PB_Any, "1.PNG") ; Load the font PNG as Sprite
StartDrawing(ScreenOutput())
For l = 0 To 479
Restore couleur
For i = 0 To 479
Read.l coul
Plot(l, i, coul)
Next i
Next l
StopDrawing()
For i = 0 To 29
GrabSprite(i + 1, i * 8, i* 16, 240 - i * 8, 16)
Next
CentreX = (#ScreenWidth - SpriteWidth(1)) / 2
CentreY = (#ScreenHeight - SpriteHeight(1)) / 2
Vitesse.f = 1.7
Angle.f = 0
Amplitude = 280
Pas.f = 3.8
;-------- MainLoop --------
PlayMusic(1)
Repeat
;///////////////////////////////
For i = 1 To 30
DisplayTransparentSprite(i, CentreX + i * 4, CentreY + Sin((Angle + i * Pas * 2) * 0.0174533) * Amplitude)
Next i
Angle + Vitesse
;//////////////////////////////
cco = 0
For cc = 0 To 25
letter = Asc(Mid(t.s, tptr+cc, 1))-31
yCharPos = letter / 10
xCharPos = letter % 10
If xCharPos = -1 : xCharPos = 9
ElseIf xCharPos > 0 : xCharPos = xCharPos - 1
EndIf
ClipSprite(font, xCharPos*32, yCharPos*33, 31, 32)
DisplayTransparentSprite(font, sco+cco, 300+50*Sin((cc+cco+sco+m)/120))
cco = cco + 32
Next
m = m -5
sco = sco -3
;
If sco < -32
tptr = tptr + 1
sco = sco + 32
EndIf
;
If tptr > Len(t.s)-30
tptr = 1
EndIf
StartDrawing(ScreenOutput())
DrawingMode(1)
Gosub DrawStarField
StopDrawing()
Gosub MoveCamera
FlipBuffers()
ClearScreen($0)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;--------- Procs / Subs -------------
; #### INITSTARFIELD ####
InitStarField:
; Structure of a star ...
Structure _3DStar
x.f ; X-Coordinate
y.f ; Y-Coordinate
z.f ; Z-Coordinate
EndStructure
; Init Starfield ...
Dim Stars._3DStar(SSum)
For dummy = 0 To SSum
Stars(dummy)\x = Random(10000)-5000
Stars(dummy)\y = Random(10000)-5000
Stars(dummy)\z = 100 + Random(1000)
Next dummy
Return
; ### Move Camera ###
MoveCamera:
If CameraZ>1000
Direction=-1
ElseIf CameraZ<-1000
Direction=1
EndIf
If Direction=1 And Cspeed<10
Cspeed=Cspeed+0.1
ElseIf Direction=-1 And Cspeed>-10
Cspeed=Cspeed-0.1
EndIf
CameraZ=CameraZ+Cspeed
Return
; #### Draw StarField ####
DrawStarField:
For dummy = 0 To SSum
If Stars(dummy)\z<CameraZ
Stars(dummy)\z=CameraZ+1000
ElseIf Stars(dummy)\z>(CameraZ+1000)
Stars(dummy)\z=CameraZ
EndIf
SX = Stars(dummy)\x / (Stars(dummy)\z-CameraZ)*100+#centerofscrw
SY = Stars(dummy)\y / (Stars(dummy)\z-CameraZ)*100+#centerofscrh
If (SX<#scrw) And (SY<#scrh) And (SX>1) And (SY>1)
b.f = 255-(((Stars(dummy)\z)-CameraZ)*(255./1000.))
c=Int(b)
Plot ( SX, SY, RGB(c,c,c))
EndIf
Next dummy
Return
DataSection
couleur:
Data.l $13, $30, $50, $70, $8E, $AE, $CF, $EC
Data.l $FF, $EB, $CF, $AF, $8E, $71, $50, $30
Data.l $0, $30914, $61632, $92454, $D3373, $104193, $144FB5, $185CD2
Data.l $1A65E7, $185CD2, $144FB4, $114193, $D3373, $A2554, $51632, $30A15
Data.l $1D2D, $314B, $4569, $5785, $6BA3, $7EC1, $90DC, $9CEE
Data.l $90DB, $7FC2, $6BA3, $5785, $4569, $314B, $1D2C, $D12
Data.l $62518, $B3E27, $F5837, $136F46, $178755, $1CA165, $1FB673, $22C67D
Data.l $20B773, $1CA166, $178755, $136F46, $F5837, $B3F28, $62518, $30F0A
Data.l $152516, $233E25, $315735, $3F6D43, $4D8652, $5B9F62, $67B56F, $70C478
Data.l $67B56E, $5BA062, $4D8752, $3E6D43, $325635, $243E26, $152417, $80F0A
Data.l $152209, $24390F, $324F15, $3F651A, $4E7C20, $5C9226, $69A62C, $72B42F
Data.l $69A62C, $5C9226, $4E7C20, $40641A, $324F15, $24390E, $152209, $90E04
Data.l $22230B, $393A13, $50511A, $666621, $7C7E29, $939631, $A7AA38, $B5B83C
Data.l $A7AA37, $939631, $7C7E2A, $656621, $50521B, $393A13, $22230B, $E0E05
Data.l $423411, $5E4919, $785D1F, $927226, $AD872D, $C89C34, $DFAE3B, $EFBB3F
Data.l $DEAE3B, $C79C34, $AD872D, $927227, $785D1F, $5D4A18, $423412, $271E0A
Data.l $251A12, $3E2C1E, $573C2A, $6E4D35, $875F41, $A0704D, $B68058, $C58A5F
Data.l $B58057, $A0704D, $875F41, $6E4D35, $573D29, $3E2B1E, $251A12, $F0A07
Data.l $211513, $372321, $4E302D, $633D39, $784C46, $8F5953, $A3665F, $B06E66
Data.l $A3655E, $8F5A53, $794B46, $623D39, $4E312D, $372220, $211514, $D0808
Data.l $C0609, $1D0F14, $311921, $44232F, $562C3B, $693649, $7D4056, $8E4961
Data.l $9A4F6A, $8E4962, $7D4056, $693648, $562C3B, $44232F, $311921, $1D0F14
Data.l $1D101B, $311B2D, $44263F, $573050, $6B3B62, $7E4673, $8F4F83, $9B568E
Data.l $8F5083, $7E4673, $6A3B61, $573050, $45263E, $301B2D, $1D101A, $C070B
Data.l $C0912, $1E142C, $31214A, $452F69, $583C84, $6D49A3, $8157C0, $9262DA
Data.l $9E6BED, $9262DB, $8157C0, $6D4AA2, $583C85, $462F69, $32224B, $1E152C
Data.l $211D42, $2E2A5D, $3B3676, $484190, $564EAB, $635AC5, $6E63DC, $766BEC
Data.l $6E64DC, $6259C6, $554EAB, $48418F, $3B3676, $2F2A5C, $211D41, $141227
Data.l $18003F, $220058, $2C0070, $350089, $3F00A3, $4900BD, $5100D2, $5700E1
Data.l $5100D1, $4800BC, $3F00A3, $350089, $2C0070, $220059, $18003E, $E0025
Data.l $23003E, $320059, $3F0071, $4D008A, $5C00A3, $6A00BD, $7600D3, $7F00E2
Data.l $7700D2, $6A00BD, $5C00A4, $4D0089, $400071, $320058, $23003F, $150025
Data.l $220029, $310039, $3E0049, $4B0059, $59006A, $66007A, $720088, $7B0092
Data.l $730088, $67007A, $59006A, $4A0059, $3E0049, $300039, $220028, $140018
Data.l $22031C, $310328, $3D0433, $4B053E, $59064A, $670755, $73085F, $7B0966
Data.l $73085F, $670855, $590649, $4A053E, $3D0433, $300428, $22021C, $140111
Data.l $220511, $300718, $3E081E, $4A0B25, $590D2C, $670E33, $721038, $7B113D
Data.l $721039, $670E33, $590C2C, $4A0A25, $3E091F, $300718, $220510, $14030A
Data.l $29130E, $3A1B13, $4B2219, $5A291F, $6C3125, $7C382A, $8B3E2F, $954332
Data.l $8B3F2F, $7C382A, $6C3025, $5A291E, $4A2219, $3B1A14, $2A130E, $190B08
Data.l $E0800, $221400, $382100, $4F2F00, $643B00, $7A4800, $915500, $A56100
Data.l $B36900, $A56000, $925600, $7B4800, $643B00, $4F2F00, $382100, $221300
Data.l $120D00, $2C2100, $4A3800, $684E00, $836300, $A17A00, $BF9000, $D9A400
Data.l $EBB200, $D9A400, $BF9100, $A17A00, $836400, $684E00, $4A3900, $2C2200
Data.l $D0D00, $1D1F00, $323400, $464900, $595C00, $6C7100, $808500, $929700
Data.l $9EA400, $919700, $808600, $6C7100, $585B00, $464800, $323300, $1E1F00
Data.l $1B2C00, $273E00, $314F00, $3B6000, $477300, $528500, $5C9400, $629F00
Data.l $5B9400, $518500, $477300, $3C6100, $315000, $263E00, $1B2C00, $101A00
Data.l $50E00, $B2100, $133700, $1A4D00, $216200, $287800, $308F00, $36A200
Data.l $3BB000, $37A200, $308E00, $297900, $216200, $1A4E00, $133800, $B2100
Data.l $93722, $D4D31, $11633F, $15794C, $198F5A, $1DA669, $20B975, $22C67D
Data.l $20B975, $1CA568, $18905B, $15784C, $11633E, $D4E30, $93723, $62114
Data.l $4344, $5F62, $7A7D, $9497, $B0B4, $CCD0, $E3E8, $F4F9
Data.l $E3E8, $CCD0, $B1B5, $9597, $7A7D, $6062, $4344, $2829
Data.l $2B42, $3E5E, $4E77, $5F90, $71AC, $82C7, $91DD, $9CEE
Data.l $92DE, $83C7, $71AD, $5F91, $4E77, $3D5D, $2B41, $1A27
Data.l $20812, $4132C, $81F48, $B2C66, $F3881, $12469E, $1552BC, $185DD5
Data.l $1A65E7, $185DD5, $1552BB, $12459F, $F3881, $B2D66, $82049, $5132C
Data.l $40011, $8002A, $D0046, $120063, $17007C, $1C0099, $2200B5, $2600CE
Data.l $2900DF, $2500CE, $2100B5, $1C0099, $17007C, $120063, $D0046, $80029
EndDataSection
; IDE Options = PureBasic 5.11 (Windows - x86)
; CursorPosition = 110
; EnableUnicode
; EnableXP
; Executable = fusion4.exe
;
; Epb