#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
Local $file = FileOpen("test.txt", 0)
HotKeySet("{LEFT}", "goLeft")
HotKeySet("{RIGHT}", "goRight")
HotKeySet("{DOWN}", "goDown")
HotKeySet("{UP}", "goUp")
global $playerX,$playerY, $player, $volx, $voly
$id = 0
$cl = 0
dim $slot[255][255]
Dim $p[255][255]
Dim $f[255][255]
dim $c[1000]
Global $x=30, $y=30
For $y = 1 To 30 Step 1
Local $line = FileReadLine($file)
$cl += 1
$c[$x] = 0
For $x = 1 to 30 step 1
Local $var = StringMid($line, $x, 1)
If( $var= "1") then
$slot[$x][$y] = '1'
$c[$x] += 1
EndIf
If( $var = "0") then
$slot[$x][$y] = '0'
$c[$x] += 1
EndIf
If( $var = "2") then
Global $px = $x, $py = $y
$slot[$x][$y] = '255'
$c[$x] += 1
EndIf
If( $var = " ") then
$c[$x] += 1
EndIf
If( $var = "") then
ExitLoop
EndIf
Next
Next
GUICreate(" My GUI Icons", 700, 700)
GUISetState()
func draw()
$id = 0
For $y = 1 To $cl Step 1
For $x = 1 to $c[$y] step 1
$f[$x][$y] = GUICtrlCreatePic("fog.bmp", $x*20 , $y*20, 20, 20)
If($slot[$x][$y] = "1") then
$p[$x][$y] = GUICtrlCreatePic("test.bmp", $x*20 , $y*20, 20, 20)
EndIf
If($slot[$x][$y] = "0") then
$p[$x][$y] = GUICtrlCreatePic("test2.bmp", $x*20 , $y*20, 20, 20)
EndIf
If($slot[$x][$y] = " ") then
EndIf
If($slot[$x][$y] = "255") then
$playerX = $x
$playerY = $y
$slot[$x][$y]= '1'
$p[$x][$y] = GUICtrlCreatePic("test.bmp", $x*20 , $y*20, 20, 20)
EndIf
Next
Next
$player = GUICtrlCreatePic("player.bmp", $playerX*20 , $playerY*20, 20, 20)
defog()
EndFunc
func defog()
for $y = -1 to 1 step 1
for $x = -1 to 1
GUICtrlDelete($f[$playerX + $x][$playerY+$y])
Next
Next
EndFunc
draw()
Func goRight()
if $slot[$playerX + 1][$playerY] = 1 Then
$playerX = $playerX + 1
$x = $playerX*20
$y = $playerY*20
GUICtrlSetPos($player, $x, $y)
defog()
EndIf
EndFunc
Func goLeft()
if $slot[$playerX - 1][$playerY] = 1 Then
$playerX = $playerX - 1
$x = $playerX*20
$y = $playerY*20
GUICtrlSetPos($player, $x, $y)
defog()
EndIf
EndFunc
Func goDown()
if $slot[$playerX][$playerY + 1] = 1 Then
$playerY = $playerY + 1
$x = $playerX*20
$y = $playerY*20
GUICtrlSetPos($player, $x, $y)
defog()
EndIf
EndFunc
Func goUp()
if $slot[$playerX][$playerY-1] = 1 Then
$playerY = $playerY - 1
$x = $playerX*20
$y = $playerY*20
GUICtrlSetPos($player, $x, $y)
defog()
EndIf
EndFunc
While 1
$msg = GUIGetMsg()
for $i = 1 to 1000
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
EndSelect
Next
WEnd
GUIDelete()