November 25, 2020, 05:24:51 AM

Author Topic: [bb] Crude Little coding Object Pushing! by Neochrome [ 1+ years ago ]  (Read 635 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
Title : Crude Little coding Object Pushing!
Author : Neochrome
Posted : 1+ years ago

Description : I came up with this after playing with the collisions and to understand them! whoohoo

[this is free code]


Code :
Code: BlitzBasic
  1. Graphics3D 800,600,16,2
  2.  
  3. Const coll_world = 1
  4. Const coll_object = 2
  5. Const coll_player = 3
  6.  
  7. Global camera   = CreateCamera()
  8. Global player   = CreateCube()  : EntityColor player,255,0,0
  9. Global level    = CreateCube():ScaleEntity level, 170,10,170: FlipMesh level
  10. Global light    = CreateLight(2)
  11. Global blob             = CreateCube()  : EntityColor blob,255,255,0
  12.  
  13. Global boxed    = CreateCube()  : EntityColor boxed,0,0,255
  14.  
  15.  
  16.  
  17. Collisions coll_player, coll_object, 2, 2
  18. Collisions coll_player, coll_world, 2,2
  19. Collisions coll_object, coll_world, 2, 2
  20.  
  21. EntityType level,       coll_world
  22. EntityType player,      coll_player
  23. EntityType blob,        coll_object
  24.  
  25. PositionEntity boxed,22,-9,0
  26. EntityType boxed, coll_world
  27.  
  28.  
  29.  
  30. While Not KeyHit(1)
  31.         Cls
  32.  
  33.  
  34.        
  35.         If KeyDown(200) Then MoveEntity player,0,0,.2
  36.         If KeyDown(208) Then MoveEntity player,0,0,-.2
  37.        
  38.         If KeyDown(203) Then TurnEntity player,0,4,0
  39.         If KeyDown(205) Then TurnEntity player,0,-4,0
  40.  
  41.         PointEntity camera, player
  42.         TranslateEntity player,0,-.1,0
  43.         TranslateEntity blob,0,-.1,0
  44.  
  45.  
  46.  
  47.         z = EntityCollided(player, coll_object)
  48.         If z = blob
  49.                 i=1
  50.                 Nx# = CollisionNX(player%, i)
  51.                 Ny# = CollisionNY(player%, i)
  52.                 Nz# = CollisionNZ(player%, i)
  53.                                        
  54.                 vy# = VectorYaw(-nx, -ny, -nz)
  55.  
  56.                 tfm_z# = Cos(vy#)/5
  57.                 tfm_x# = -Sin(vy#)/5
  58.                 tfm_y# = VectorPitch(-nx, -ny, -nz)
  59.                 If Abs(tfm_y)<60 Then TranslateEntity blob,tfm_x,0,tfm_z
  60.         End If
  61.        
  62.         UpdateWorld()
  63.         RenderWorld()
  64.  
  65.         Flip
  66. Wend
  67. End


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal