So habe ich die Perspektive erzeugt....
Code: Alles auswählen
InitSprite()
InitKeyboard()
#screenw = 800
#screenh = 600
OpenScreen(#screenw,#screenh,32,"Perspektive mit Sprite3D")
Global posx.f, posy.f, gain.f, swh.l, shh.l
gain = 1.5
swh = #screenw/2
shh = #screenh/2
Repeat
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up)
posy -10
EndIf
If KeyboardPushed(#PB_Key_Down)
posy + 10
EndIf
If KeyboardPushed(#PB_Key_Left)
posx-10
EndIf
If KeyboardPushed(#PB_Key_Right)
posx+10
EndIf
If KeyboardPushed(#PB_Key_A)
gain + 0.01
EndIf
If KeyboardPushed(#PB_Key_Z)
gain - 0.01
EndIf
StartDrawing(ScreenOutput())
LineXY(swh+posx-32,shh+posy-32,swh+(posx-32)*gain,shh+(posy-32)*gain,RGB(100,100,100))
LineXY(swh+posx+32,shh+posy-32,swh+(posx+32)*gain,shh+(posy-32)*gain,RGB(100,100,100))
LineXY(swh+posx+32,shh+posy+32,swh+(posx+32)*gain,shh+(posy+32)*gain,RGB(100,100,100))
LineXY(swh+posx-32,shh+posy+32,swh+(posx-32)*gain,shh+(posy+32)*gain,RGB(100,100,100))
LineXY(swh+(posx-32)*gain,shh+(posy-32)*gain,swh+(posx+32)*gain,shh+(posy-32)*gain,RGB(100,100,100))
LineXY(swh+(posx+32)*gain,shh+(posy-32)*gain,swh+(posx+32)*gain,shh+(posy+32)*gain,RGB(100,100,100))
LineXY(swh+(posx+32)*gain,shh+(posy+32)*gain,swh+(posx-32)*gain,shh+(posy+32)*gain,RGB(100,100,100))
LineXY(swh+(posx-32)*gain,shh+(posy+32)*gain,swh+(posx-32)*gain,shh+(posy-32)*gain,RGB(100,100,100))
Circle(swh+posx-32,shh+posy-32,3,RGB(255,255,0))
Circle(swh+posx+32,shh+posy-32,3,RGB(255,255,0))
Circle(swh+posx+32,shh+posy+32,3,RGB(255,255,0))
Circle(swh+posx-32,shh+posy+32,3,RGB(255,255,0))
Circle(swh+(posx-32)*gain,shh+(posy-32)*gain,3,RGB(0,255,0))
Circle(swh+(posx+32)*gain,shh+(posy-32)*gain,3,RGB(0,255,0))
Circle(swh+(posx+32)*gain,shh+(posy+32)*gain,3,RGB(0,255,0))
Circle(swh+(posx-32)*gain,shh+(posy+32)*gain,3,RGB(0,255,0))
DrawText(0,0,StrF(gain,2))
StopDrawing()
FlipBuffers()
ClearScreen(0)
Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()