May 30, 2020, 02:30:50 AM

Author Topic: [bb] Create a ladder by Boiled Sweets [ 1+ years ago ]  (Read 1032 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Create a ladder by Boiled Sweets [ 1+ years ago ]
« on: June 29, 2017, 12:28:43 AM »
Title : Create a ladder
Author : Boiled Sweets
Posted : 1+ years ago

Description : This is a basic example of how to create a ladder.  The ladder function takes 2 parameters, the first is the length and the second is the wonkyness.  Try 8 and 8 for a rickerty wild west ladder for example!  Creates it as a single surface too.  Simply apply your favourite wood texture and off you go.  Use as you see fit.  Any improvements please let me know.  (BTW took 8 mins to code).

Code :
Code: BlitzBasic
  1. ; CreateCube Example
  2. ; ------------------
  3.  
  4. Graphics3D 1024,768,32
  5. SetBuffer BackBuffer()
  6.  
  7. p = CreatePivot()
  8.  
  9. SeedRnd (MilliSecs())
  10. camera=CreateCamera(p)
  11. PositionEntity camera, 0,0, -4
  12.  
  13. light=CreateLight()
  14. RotateEntity Light,45,0,0
  15.  
  16. height$=Input$("Ladder height?       1-100    :")
  17. wonky$=Input$("Ladder wonnkyness?     0-10    :")
  18.  
  19. createLadder(Int(height), Int(wonky))
  20.  
  21. While Not KeyDown( 1 )
  22.  
  23. If KeyDown(203)
  24.         TurnEntity p, 0, -3, 0
  25. EndIf
  26.  
  27. If KeyDown(205)
  28.         TurnEntity p, 0, 3, 0
  29. EndIf
  30.  
  31. If KeyDown(200)
  32.         TurnEntity p, -3, 0, 0
  33. EndIf
  34.  
  35. If KeyDown(208)
  36.         TurnEntity p, 3, 0, 0
  37. EndIf
  38.  
  39. If KeyDown(30)
  40.         MoveEntity camera, 0, 0, .1
  41. EndIf
  42.  
  43. If KeyDown(44)
  44.         MoveEntity camera, 0, 0, -.1
  45. EndIf
  46.  
  47.  
  48. RenderWorld
  49. Text 10,10, "Cursor keys to turn, A / Z to zoom, escape to quit"
  50. Flip
  51. Wend
  52.  
  53. End
  54.  
  55. Function createLadder(length#, wonky#)
  56.  
  57.         rungs = length * 2
  58.         rung_distance# = (length / (rungs+1))
  59.         length = length / 2
  60.  
  61.         ; legs
  62.        
  63.         leg_left=CreateCube()
  64.         ScaleMesh leg_left, .1, length, .1
  65.         PositionMesh leg_left,-.4, 0, 0
  66.        
  67.         leg_right=CreateCube()
  68.         ScaleMesh leg_right, .1, length, .1
  69.         PositionMesh leg_right, .4, 0, 0
  70.        
  71.         ;rungs
  72.                
  73.         rung_start# = -(rung_distance#/2) - (((rungs-2)/2) * rung_distance#)
  74.  
  75.         For i = 1 To rungs
  76.                 rung=CreateCube()
  77.                 ScaleMesh rung, .6, .07, 0.05
  78.                 RotateMesh rung, 0, 0, Rnd(-wonky, wonky)
  79.                 PositionMesh rung, 0, rung_start#, -0.1
  80.                 rung_start# = rung_start# + rung_distance#
  81.                 AddMesh rung, leg_left
  82.                 FreeEntity rung
  83.         Next
  84.  
  85.         AddMesh leg_right, leg_left    
  86.         FreeEntity leg_right
  87.        
  88.         ;Tex = LoadTexture ("wood02.jpg")
  89.         ;EntityTexture leg_left, Tex
  90.        
  91. End Function


Comments :


Oiduts Studios(Posted 1+ years ago)

 nice


Yasha(Posted 1+ years ago)

 Makes nice railway tracks...


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal