Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Array.au3>
- #include <Misc.au3>
- #include <StringConstants.au3>
- #include "au3Irrlicht2.au3"
- #NoTrayIcon
- HotKeySet("{ESC}", "_exit")
- HotKeySet("{F1}", "_defaultPosition")
- HotKeySet("{F2}", "_changeCamera")
- local $MAP_X = 10
- local $MAP_Y = 10
- local $MAP_Z = 10
- global $MapCollision[$MAP_X][$MAP_Z][$MAP_Y]
- local $BLOCKS_AMOUNT_X = $MAP_X
- local $BLOCKS_AMOUNT_Y = 0
- local $BLOCKS_AMOUNT_Z = $MAP_Z
- global $texNum = 3
- local $blocks[$MAP_X][$MAP_Z][$MAP_Y]
- _IrrStart($IRR_EDT_DIRECT3D9, 800, 600, $IRR_BITS_PER_PIXEL_32, $IRR_WINDOWED, $IRR_NO_SHADOWS, $IRR_CAPTURE_EVENTS)
- local $keyStruct
- local $cameraSpeed = 0.5/_IrrGetFPS()
- local $camera = _IrrAddFPSCamera(0, 100.0, $cameraSpeed, -1, 0) ;_IrrAddCamera(0, 0, 0, 5, 0, 5)
- local $cameraPos[3] = [0, $BLOCKS_AMOUNT_Y+2.5, 0]
- local $cameraFPS = true
- _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
- _IrrSetNodeRotation($camera, 0, 0, 0)
- global $fallingSpeed = 10
- local $playerPos = [2, $BLOCKS_AMOUNT_Y+2.5, 2]
- local $playerMesh = _IrrGetMesh("data/player.obj")
- local $playerTexture = _IrrGetTexture("data/player.png")
- local $player = _IrrAddMeshToSceneAsOcttree($playerMesh)
- _IrrSetNodeMaterialTexture($player, $playerTexture, 0)
- _IrrSetNodeMaterialFlag($player, $IRR_EMF_LIGHTING, $IRR_OFF)
- _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
- local $textures[4] = [ _
- _IrrGetTexture("data/cobblestone.png"), _
- _IrrGetTexture("data/bedrock.png"), _
- _IrrGetTexture("data/dirt.png"), _
- _IrrGetTexture("data/ice.png") _
- ]
- _IrrAddStaticText("Minecraft: AutoIt Edition Alpha 0.0.1", 0, 0, 200, 20, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
- _IrrAddStaticText("Windows: " & @OSVersion & " Build " & @OSBuild, 0, 20, 200, 40, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
- _IrrAddStaticText("AutoIt: " & @AutoItVersion, 0, 30, 200, 50, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
- _IrrAddStaticText("Arch: " & @OSArch, 0, 40, 200, 60, $IRR_GUI_NO_BORDER, $IRR_GUI_NO_WRAP)
- CreateMap()
- HotKeySet("{SPACE}", "AddBlock")
- WHILE _IrrRunning()
- local $cameraPos = _IrrGetNodePosition($camera)
- _IrrSetWindowCaption("Minecraft: AutoIt Edition |" & " X: " & $cameraPos[0] & " Y: " & $cameraPos[1] & " Z: " & $cameraPos[2] & " FPS: " & _IrrGetFPS())
- _IrrBeginScene(150, 200, 255)
- if _IsPressed(57) then
- $playerPos[2] += $cameraSpeed
- _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
- endif
- if _IsPressed(53) then
- $playerPos[2] -= $cameraSpeed
- _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
- endif
- if _IsPressed(41) then
- $playerPos[0] += $cameraSpeed
- _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
- endif
- if _IsPressed(44) then
- $playerPos[0] -= $cameraSpeed
- _IrrSetNodePosition($player, $playerPos[0], $playerPos[1], $playerPos[2])
- endif
- _IrrDrawScene()
- if $cameraFPS==false then _IrrDraw2DImage(_IrrGetTexture("data/menu.png"), 80, 60)
- _IrrDrawGUI()
- _IrrEndScene()
- WEND
- _IrrStop()
- func CreateMap()
- local $mesh = _IrrGetMesh( "data/block.obj" )
- For $x = 0 To $BLOCKS_AMOUNT_X-1
- For $z = 0 To $BLOCKS_AMOUNT_Z-1
- $blocks[$x][$z][0] = _IrrAddMeshToSceneAsOcttree($mesh)
- _IrrSetNodeMaterialTexture( $blocks[$x][$z][0], $textures[$texNum], 0)
- _IrrSetNodeMaterialFlag( $blocks[$x][$z][0], $IRR_EMF_LIGHTING, $IRR_OFF )
- _IrrSetNodePosition($blocks[$x][$z][0], $x, 0, $z)
- Next
- Next
- ;Creating blocks and camera collisions
- For $x = 0 To $BLOCKS_AMOUNT_X-1
- For $z = 0 To $BLOCKS_AMOUNT_Z-1
- $MapCollision[$x][$z][0] = _IrrGetCollisionGroupFromComplexMesh($mesh, $blocks[$x][$z][0])
- _IrrAddCollisionAnimator($MapCollision[$x][$z][0], _
- $camera, _
- 0.5,0.5,0.5, _
- 0.0,0.0,0.0, _
- 0.0,1.0,0.0 )
- Next
- Next
- endfunc
- func AddBlock()
- local $camPos = _IrrGetNodePosition($camera)
- local $mesh = _IrrGetMesh( "data/block.obj" )
- $x = int($camPos[0])
- $y = int($camPos[1])
- $z = int($camPos[2])
- if $x > $MAP_X Or $x < 0 Then Return
- if $y > $MAP_Y Or $y < 0 Then Return
- if $z > $MAP_Z Or $z < 0 Then Return
- $blocks[$x][$z][$y] = _IrrAddMeshToSceneAsOcttree($mesh)
- _IrrSetNodeMaterialTexture($blocks[$x][$z][$y], $textures[$texNum], 0)
- _IrrSetNodeMaterialFlag($blocks[$x][$z][$y], $IRR_EMF_LIGHTING, $IRR_OFF)
- _IrrSetNodePosition($blocks[$x][$z][$y], $x, $y-1, $z)
- _IrrSetNodePosition($camera, $camPos[0], $camPos[1]+1, $camPos[2])
- endfunc
- Func _exit()
- _IrrStop()
- Exit
- EndFunc
- func _defaultPosition()
- local $cameraPos[3] = [0, $MAP_Y+2, 0]
- _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
- endfunc
- Func _changeCamera()
- $cameraPos = _IrrGetNodePosition($camera)
- $cameraRot = _IrrGetNodeRotation($camera)
- $cameraTar = _IrrGetCameraTarget($camera)
- if $cameraFPS==true then
- $camera = _IrrAddCamera($cameraPos[0], $cameraPos[1], $cameraPos[2], $cameraTar[0], $cameraTar[1], $cameraTar[2])
- _IrrSetNodeRotation($camera, $cameraRot[0], $cameraRot[1], $cameraRot[2])
- $cameraFPS = false
- elseif $cameraFPS==false then
- $camera = _IrrAddFPSCamera(0, 100.0, $cameraSpeed, -1, 0)
- _IrrSetNodePosition($camera, $cameraPos[0], $cameraPos[1], $cameraPos[2])
- _IrrSetNodeRotation($camera, $cameraRot[0], $cameraRot[1], $cameraRot[2])
- _IrrSetCameraTarget($camera, $cameraTar[0], $cameraTar[1], $cameraTar[2])
- $cameraFPS = true
- endif
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement