Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
- Structure POINT
- x.l
- y.l
- EndStructure
- CompilerEndIf
- #sw = 1024
- #sh = 768
- #sn = "Sinus"
- #hsw = #sw/2 : #hsh = #sh/2
- If InitSprite()=0 Or InitKeyboard()=0
- MessageRequester("ERROR","Cant init game engine !"):End
- EndIf
- If OpenScreen(#sw,#sh,32,#sn)=0
- If OpenScreen(#sw,#sh,24,#sn)=0
- MessageRequester("ERROR","Cant open screen !"):End
- EndIf:EndIf
- Procedure Point3Dto2D(x.f,y.f,z.f,*pt.POINT)
- #proj = 150 ; gewöhnlich 100
- z + 1
- *pt\x = Round((x/z)* #proj+#hsw,1)
- *pt\y = Round((y/z)*-#proj+#hsh,1)
- EndProcedure
- Procedure Line3D(x1.f,y1.f,z1.f,x2.f,y2.f,z2.f,color)
- ; draw a line in 3D space
- Point3Dto2D(x1,y1,z1,p1.POINT)
- Point3Dto2D(x2,y2,z2,p2.POINT)
- If color = -1
- LineXY(p1\x,p1\y,p2\x,p2\y)
- Else
- LineXY(p1\x,p1\y,p2\x,p2\y,color)
- EndIf
- EndProcedure
- schrittweite = 5 : z.f = 0 : obj_y.f = 0 : obj_x.f = 0 : obj_z.f = -0.5
- Repeat
- ExamineKeyboard()
- FlipBuffers()
- If IsScreenActive()
- ClearScreen (0)
- If StartDrawing(ScreenOutput())
- FrontColor(RGB($FF,$FF,$00))
- For x = 0 To 60 Step 3
- For y = 0 To 60 Step 3
- For c = 0 To 10
- Line3D(obj_x-0.1*x+0.025,obj_y-0.1*y,obj_z+0.01*c,obj_x-0.1*x+0.025,obj_y-0.1*y,obj_z+0.01*c+0.01,RGB(255-25*c,255-25*c,255-25*c))
- Next
- Line3D(obj_x-0.1*x ,obj_y-0.1*y ,obj_z,obj_x-0.1*x+0.05 ,obj_y-0.1*y ,obj_z,$FFFFFF)
- Line3D(obj_x-0.1*x+0.025,obj_y-0.1*y-0.025,obj_z,obj_x-0.1*x+0.025,obj_y-0.1*y+0.025,obj_z,$FFFFFF)
- Next
- Next
- FrontColor(RGB(255, 255, 255))
- DrawingMode(1)
- DrawText(50,50, "Cursor Keys left/right & up/down to move object")
- DrawText(50,70, "Keypad +/- to z00m object")
- StopDrawing()
- EndIf
- If KeyboardPushed(#PB_Key_Up)
- obj_y + 0.01
- ElseIf KeyboardPushed(#PB_Key_Down)
- obj_y - 0.01
- ElseIf KeyboardPushed(#PB_Key_Left)
- obj_x - 0.01
- ElseIf KeyboardPushed(#PB_Key_Right)
- obj_x + 0.01
- ElseIf KeyboardPushed(#PB_Key_Add) ; keypad +
- obj_z - 0.01
- ElseIf KeyboardPushed(#PB_Key_Subtract) ; keypad -
- obj_z + 0.01
- EndIf
- If keypressed : keypressed - 1 : EndIf
- Delay(10)
- EndIf
- Until KeyboardPushed(#PB_Key_Escape)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement