SHARE
TWEET

Untitled

a guest Jul 13th, 2019 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Procedure.f GSin(winkel.f)
  2.    ProcedureReturn Sin(winkel*(2*3.14159265/360))
  3. EndProcedure
  4.  
  5. Procedure.f GCos(winkel.f)
  6.    ProcedureReturn Cos(winkel*(2*3.14159265/360))
  7. EndProcedure
  8.  
  9. CompilerIf #PB_Compiler_OS <> #PB_OS_Windows
  10.    Structure POINT
  11.      x.l
  12.      y.l
  13.    EndStructure
  14. CompilerEndIf
  15.  
  16. #sw = 1024
  17. #sh = 768
  18. #sn = "Sinus"
  19.  
  20. #hsw = #sw/2 : #hsh = #sh/2
  21.  
  22. If InitSprite()=0 Or InitKeyboard()=0
  23.   MessageRequester("ERROR","Cant init game engine !"):End
  24. EndIf
  25.  
  26. If OpenScreen(#sw,#sh,32,#sn)=0
  27.   If OpenScreen(#sw,#sh,24,#sn)=0
  28.         MessageRequester("ERROR","Cant open screen !"):End
  29. EndIf:EndIf
  30.  
  31. Procedure Point3Dto2D(x.f,y.f,z.f,*pt.POINT)
  32.   #proj = 100 ; gew√∂hnlich 100
  33.   z + 1
  34.   *pt\x = Round((x/z)* #proj+#hsw,1)
  35.   *pt\y = Round((y/z)*-#proj+#hsh,1)
  36. EndProcedure
  37.  
  38. Procedure Line3D(x1.f,y1.f,z1.f,x2.f,y2.f,z2.f,color)
  39.   ; draw a line in 3D space
  40.   Point3Dto2D(x1,y1,z1,p1.POINT)
  41.   Point3Dto2D(x2,y2,z2,p2.POINT)
  42.   If color = -1
  43.     LineXY(p1\x,p1\y,p2\x,p2\y)
  44.   Else
  45.     LineXY(p1\x,p1\y,p2\x,p2\y,color)
  46.   EndIf
  47. EndProcedure
  48.  
  49. schrittweite = 5 : z.f = 0 : obj_y.f = 0 : obj_x.f = 0 : obj_z.f = -0.5
  50.  
  51. Repeat
  52.     ExamineKeyboard()
  53.     FlipBuffers()
  54.     If IsScreenActive()
  55.       ClearScreen (0)
  56.       If StartDrawing(ScreenOutput())
  57.           FrontColor(RGB($FF,$FF,$00))
  58.           z.f = 0.0
  59.           For i = 0 To 5
  60.               Line3D(obj_x-0.5,obj_y-0.5,obj_z+z,obj_x+0.5,obj_y-0.5,obj_z+z,$FFFFFF)
  61.               Line3D(obj_x-0.5,obj_y+0.5,obj_z+z,obj_x+0.5,obj_y+0.5,obj_z+z,$FFFFFF)
  62.               Line3D(obj_x-0.5,obj_y-0.5,obj_z+z,obj_x-0.5,obj_y+0.5,obj_z+z,$FFFFFF)
  63.               Line3D(obj_x+0.5,obj_y-0.5,obj_z+z,obj_x+0.5,obj_y+0.5,obj_z+z,$FFFFFF)
  64.           z - 0.03
  65.           Next
  66.           FrontColor(RGB(255, 255, 255))
  67.           DrawingMode(1)
  68.           DrawText(50,50, "Cursor Keys left/right & up/down to move object")
  69.           DrawText(50,70, "Keypad +/- to z00m object")
  70.           StopDrawing()
  71.       EndIf
  72.  
  73.       If KeyboardPushed(#PB_Key_Up)
  74.         obj_y + 0.01
  75.       ElseIf KeyboardPushed(#PB_Key_Down)
  76.         obj_y - 0.01
  77.       ElseIf KeyboardPushed(#PB_Key_Left)
  78.         obj_x - 0.01
  79.       ElseIf KeyboardPushed(#PB_Key_Right)
  80.         obj_x + 0.01
  81.       ElseIf KeyboardPushed(#PB_Key_Add)      ; keypad +
  82.         obj_z - 0.01
  83.       ElseIf KeyboardPushed(#PB_Key_Subtract) ; keypad -
  84.         obj_z + 0.01
  85.       EndIf
  86.       If keypressed : keypressed - 1 : EndIf    
  87.  
  88.       Delay(10)
  89.  
  90.     EndIf
  91. Until KeyboardPushed(#PB_Key_Escape)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top