Sprite richtig am Horizont spiegeln(Wasser-effekt)
Verfasst: 18.11.2007 16:43
Code: Alles auswählen
If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Can't open DirectX 7 Or later", 0)
End
EndIf
If InitSprite3D() = 0
MessageRequester("Error", "Direct3D system can't be initialized correctly", 0)
End
EndIf
Procedure SpriteMirrorHorizontal(SpriteID)
;Mirrors a sprite horizontal
StartDrawing(SpriteOutput(SpriteID))
IW = SpriteWidth(SpriteID)
IH = SpriteHeight(SpriteID)
Buffer = DrawingBuffer() ; Get the start address of the screen buffer
Pitch = DrawingBufferPitch() ; Get the length (in byte) took by one horizontal line
*pxData1.LONG = Buffer
*pxData2.LONG = *pxData1 + (IH-1)*Pitch
mem=AllocateMemory(Pitch)
For lines=0 To IH/2-1
CopyMemory(*pxData1,mem,pitch)
CopyMemory(*pxData2,*pxData1,pitch)
CopyMemory(mem,*pxData2,pitch)
*pxData1 + pitch
*pxData2 - pitch
Next
StopDrawing()
If mem: FreeMemory(mem):EndIf
EndProcedure
If OpenScreen(800,600, 32, "Sprite")
LoadSprite(0, "Data\Geebee2.bmp", #PB_Sprite_Texture)
TransparentSpriteColor(0, RGB(255, 0, 255)) ; Our pink is transparent :)
StartDrawing(SpriteOutput(0))
Box(0,0,30,30,RGB(250,250,50))
StopDrawing()
CopySprite(0,1, #PB_Sprite_Texture)
SpriteMirrorHorizontal(1)
TransparentSpriteColor(1, RGB(255, 0, 255)) ; Our pink is transparent :)
CreateSprite3D(0, 0)
CreateSprite3D(1, 1)
ZoomSprite3D(1,SpriteWidth(1),SpriteHeight(1)*1.5)
f1.f=1;0.5
Repeat
FlipBuffers()
ClearScreen(RGB(200,200,255))
StartDrawing(ScreenOutput())
Box (0,130+SpriteHeight(0),800,600-130-SpriteHeight(0),RGB(50,50,250))
StopDrawing()
; Draw our sprite
If Start3D()
DisplaySprite3D(0, 200, 130);original
b=b+f1
If b>5
f1=f1*-1
EndIf
If b<-5
f1=f1*-1
EndIf
ZoomSprite3D(1,SpriteWidth(1),SpriteHeight(1)*1.5 - b)
DisplaySprite3D(1, 200, 130+SpriteHeight(0),64)
Stop3D()
EndIf
ExamineKeyboard()
x+1
Until x > 2500 Or KeyboardPushed(#PB_Key_Escape)
Else
MessageRequester("Error", "Can't open a screen !", 0)
EndIf
End