Advertisement
Guest User

Ruby Dung 2.0

a guest
Jan 28th, 2018
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 5.36 KB | None | 0 0
  1. #include <Array.au3>
  2. #include <Misc.au3>
  3. #include <StringConstants.au3>
  4. #include "au3Irrlicht2.au3"
  5. #NoTrayIcon
  6. HotKeySet("{ESC}", "_exit")
  7. HotKeySet("{F1}", "_defaultPosition")
  8. HotKeySet("{F2}", "_changeCamera")
  9.  
  10. local $MAP_X = 10
  11. local $MAP_Y = 10
  12. local $MAP_Z = 10
  13. global $MapCollision[$MAP_X][$MAP_Z][$MAP_Y]
  14.  
  15. local $BLOCKS_AMOUNT_X = $MAP_X
  16. local $BLOCKS_AMOUNT_Y = 0
  17. local $BLOCKS_AMOUNT_Z = $MAP_Z
  18.  
  19. global $texNum = 3
  20.  
  21. local $blocks[$MAP_X][$MAP_Z][$MAP_Y]
  22.  
  23. _IrrStart($IRR_EDT_DIRECT3D9, 800, 600, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_CAPTURE_EVENTS)
  24.  
  25. local $keyStruct
  26. local $cameraSpeed = 0.5/_IrrGetFPS()
  27. local $camera = _IrrAddFPSCamera(0, 100.0, $cameraSpeed, -1, 0) ;_IrrAddCamera(0, 0, 0, 5, 0, 5)
  28. local $cameraPos[3] = [0, $BLOCKS_AMOUNT_Y+2.5, 0]
  29. local $cameraFPS = true
  30. _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
  31. _IrrSetNodeRotation($camera, 0, 0, 0)
  32.  
  33. global $fallingSpeed = 10
  34.  
  35. local $playerPos = [2, $BLOCKS_AMOUNT_Y+2.5, 2]
  36. local $playerMesh = _IrrGetMesh("data/player.obj")
  37. local $playerTexture = _IrrGetTexture("data/player.png")
  38. local $player = _IrrAddMeshToSceneAsOcttree($playerMesh)
  39. _IrrSetNodeMaterialTexture($player, $playerTexture, 0)
  40. _IrrSetNodeMaterialFlag($player, $IRR_EMF_LIGHTING, $IRR_OFF)
  41. _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
  42.  
  43. local $textures[4] = [ _
  44.     _IrrGetTexture("data/cobblestone.png"), _
  45.     _IrrGetTexture("data/bedrock.png"), _
  46.     _IrrGetTexture("data/dirt.png"), _
  47.     _IrrGetTexture("data/ice.png") _
  48. ]
  49.  
  50. _IrrAddStaticText("Minecraft: AutoIt Edition Alpha 0.0.1", 0, 0, 200, 20, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
  51. _IrrAddStaticText("Windows: " & @OSVersion & " Build " & @OSBuild, 0, 20, 200, 40, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
  52. _IrrAddStaticText("AutoIt: " & @AutoItVersion, 0, 30, 200, 50, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
  53. _IrrAddStaticText("Arch: " & @OSArch, 0, 40, 200, 60, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
  54.  
  55. CreateMap()
  56.  
  57. HotKeySet("{SPACE}", "AddBlock")
  58.  
  59. WHILE _IrrRunning()
  60.     local $cameraPos = _IrrGetNodePosition($camera)
  61.     _IrrSetWindowCaption("Minecraft: AutoIt Edition |" & " X: " & $cameraPos[0] & " Y: " & $cameraPos[1] & " Z: " & $cameraPos[2]  & "   FPS: " & _IrrGetFPS())
  62.     _IrrBeginScene(150, 200, 255)
  63.  
  64.     if _IsPressed(57) then
  65.         $playerPos[2] += $cameraSpeed
  66.         _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
  67.     endif
  68.     if _IsPressed(53) then
  69.         $playerPos[2] -= $cameraSpeed
  70.         _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
  71.     endif
  72.     if _IsPressed(41) then
  73.         $playerPos[0] += $cameraSpeed
  74.         _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
  75.     endif
  76.     if _IsPressed(44) then
  77.         $playerPos[0] -= $cameraSpeed
  78.         _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
  79.     endif
  80.  
  81.     _IrrDrawScene()
  82.         if $cameraFPS==false then _IrrDraw2DImage(_IrrGetTexture("data/menu.png"), 80, 60)
  83.     _IrrDrawGUI()
  84.     _IrrEndScene()
  85. WEND
  86.  
  87. _IrrStop()
  88.  
  89. func CreateMap()
  90.     local $mesh = _IrrGetMesh( "data/block.obj" )
  91.     For $x = 0 To $BLOCKS_AMOUNT_X-1
  92.         For $z = 0 To $BLOCKS_AMOUNT_Z-1
  93.                 $blocks[$x][$z][0] = _IrrAddMeshToSceneAsOcttree($mesh)
  94.                 _IrrSetNodeMaterialTexture( $blocks[$x][$z][0], $textures[$texNum], 0)
  95.                 _IrrSetNodeMaterialFlag( $blocks[$x][$z][0], $IRR_EMF_LIGHTING, $IRR_OFF )
  96.                 _IrrSetNodePosition($blocks[$x][$z][0], $x, 0, $z)
  97.         Next
  98.     Next
  99.  
  100.     ;Creating blocks and camera collisions
  101.     For $x = 0 To $BLOCKS_AMOUNT_X-1
  102.         For $z = 0 To $BLOCKS_AMOUNT_Z-1
  103.             $MapCollision[$x][$z][0] = _IrrGetCollisionGroupFromComplexMesh($mesh, $blocks[$x][$z][0])
  104.             _IrrAddCollisionAnimator($MapCollision[$x][$z][0], _
  105.                                     $camera, _
  106.                                     0.5,0.5,0.5, _
  107.                                     0.0,0.0,0.0, _
  108.                                     0.0,1.0,0.0 )
  109.         Next
  110.     Next
  111. endfunc
  112.  
  113. func AddBlock()
  114.     local $camPos = _IrrGetNodePosition($camera)
  115.     local $mesh = _IrrGetMesh( "data/block.obj" )
  116.  
  117.     $x = int($camPos[0])
  118.     $y = int($camPos[1])
  119.     $z = int($camPos[2])
  120.     if $x > $MAP_X Or $x < 0 Then Return
  121.     if $y > $MAP_Y Or $y < 0 Then Return
  122.     if $z > $MAP_Z Or $z < 0 Then Return
  123.     $blocks[$x][$z][$y] = _IrrAddMeshToSceneAsOcttree($mesh)
  124.     _IrrSetNodeMaterialTexture($blocks[$x][$z][$y], $textures[$texNum], 0)
  125.     _IrrSetNodeMaterialFlag($blocks[$x][$z][$y], $IRR_EMF_LIGHTING, $IRR_OFF)
  126.     _IrrSetNodePosition($blocks[$x][$z][$y], $x, $y-1, $z)
  127.  
  128.     _IrrSetNodePosition($camera, $camPos[0], $camPos[1]+1, $camPos[2])
  129. endfunc
  130.  
  131.  
  132.  
  133. Func _exit()
  134.     _IrrStop()
  135.     Exit
  136. EndFunc
  137.  
  138. func _defaultPosition()
  139.     local $cameraPos[3] = [0, $MAP_Y+2, 0]
  140.     _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
  141. endfunc
  142.  
  143. Func _changeCamera()
  144.     $cameraPos = _IrrGetNodePosition($camera)
  145.     $cameraRot = _IrrGetNodeRotation($camera)
  146.     $cameraTar = _IrrGetCameraTarget($camera)
  147.  
  148.     if $cameraFPS==true then
  149.         $camera = _IrrAddCamera($cameraPos[0], $cameraPos[1], $cameraPos[2], $cameraTar[0], $cameraTar[1], $cameraTar[2])
  150.         _IrrSetNodeRotation($camera, $cameraRot[0], $cameraRot[1], $cameraRot[2])
  151.         $cameraFPS = false
  152.     elseif $cameraFPS==false then
  153.         $camera = _IrrAddFPSCamera(0, 100.0, $cameraSpeed, -1, 0)
  154.         _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
  155.         _IrrSetNodeRotation($camera, $cameraRot[0], $cameraRot[1], $cameraRot[2])
  156.         _IrrSetCameraTarget($camera, $cameraTar[0], $cameraTar[1], $cameraTar[2])
  157.         $cameraFPS = true
  158.     endif
  159. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement