Hi!
Hier kommt die Schlange
Ich wart auf eure Levels, meine wurden bei dem vielen Testen langsam langweilig^^
Hier der Snakecode:
Spoiler anzeigen
C
#include <GUIConstants.au3>
#include <misc.au3>
#include <Color.au3>
Opt("PixelCoordMode",2)
HotKeySet("{LEFT}","moveLEFT_relative")
HotKeySet("{RIGHT}","moveRIGHT_relative")
HotKeySet("{ESC}","_exit")
HotKeySet("{PAUSE}","_pause")
HotKeySet("p","_pause")
HotKeySet("q","speedup")
HotKeySet("r","antisoundfunction")
;HotKeySet("a","speeddown")
Global $direction="right"
Global $x=100
Global $y=100
Global $x_apfel=200
Global $y_apfel=200
Global $apfel=0
Global $apfel_menge=20
Global $insgesamt_apfel=0
Global $sleep=60
Global $snake_teil_bild[90]
Global $snake_teil=1
Global $snake_teil_kopf=0
Global $snake_length=8
Global $richtungsaenderung=""
Global $pause=0
Global $level=1
Global $hindernis_bild[1000]
Global $hindernis_x_pos[1000]
Global $hindernis_y_pos[1000]
Global $balken_x_pos[100]
Global $balken_y_pos[100]
Global $balken[100]
Global $balken_direction[100]
Global $balken_grenze_links[100]
Global $balken_grenze_rechts[100]
Global $balken_anzahl=0
Global $balken_senkrecht[100]
Global $balken_senkrecht_direction[100]
Global $balken_senkrecht_x_pos[100]
Global $balken_senkrecht_y_pos[100]
Global $balken_senkrecht_grenze_oben[100]
Global $balken_senkrecht_grenze_unten[100]
Global $balken_senkrecht_anzahl=0
Global $level_anzahl=3
Global $levelpath[100]
#cs
Global $vorherig_x_pos=1000
Global $vorherig_y_pos=0
#ce
$snake_gui=GUICreate("Snake",1200,800,0,0)
GUICtrlCreateGroup("Snakecontrol",1020,20,160,90)
$radio_not_relative=GUICtrlCreateRadio("move with 4 arrow keys",1030,40,140,20 )
$radio_relative=GUICtrlCreateRadio("move with left/right arrow (relative to direction)",1030,60,140,40,$BS_MULTILINE )
GUICtrlSetState(-1,$GUI_CHECKED)
GUICtrlCreateGroup("",-99,-99,1,1)
GUISetBkColor(0x00FF00)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_links.bmp",0,0,10,1000)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_links.bmp",990,0,10,1000)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_oben.bmp",10,0,980,10)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_oben.bmp",10,790,980,10)
$id_label_apples=GUICtrlCreateLabel(22-$snake_length/4 & " apples remaining" & @CRLF & @CRLF & "Sleeptime: " & $sleep,1020,140,160,50,-1,$WS_EX_STATICEDGE )
$button_level_hinzufuegen=GUICtrlCreateButton("add level to playlist",1020,275,160,20)
$button_combo_refreshen=GUICtrlCreateButton("refresh combo",1020,250,160,20)
$combo_levels=GUICtrlCreateCombo("",1020,220,160,20)
$list=GUICtrlCreateList("",1020,340,160,200,BitOr($WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY))
$level_anzahl=IniRead(@ScriptDir & "\Playlist.ini","levels","Level_Anzahl",0)
For $i=1 To $level_anzahl
$levelpath[$i]=IniRead(@ScriptDir & "\Playlist.ini","levels","Level" & $i,"")
GuiCtrlSetData(-1, $i& ". " &$levelpath[$i], "1. " & $levelpath[1])
Next
$button_play_level=GUICtrlCreateButton("play level",1020,540,160,20)
$button_save_levels=GUICtrlCreateButton("save playlist",1020,565,160,20)
$button_remove_level=GUICtrlCreateButton("remove item",1020,590,160,20)
GUISetState(@SW_SHOW)
$search=FileFindFirstFile(@ScriptDir & "\Level\*.ini")
If $search<>-1 Then
While 1
$speicherini=FileFindNextFile($search)
If @error=1 Then ExitLoop
GUICtrlSetData($combo_levels,StringReplace ( $speicherini, ".ini" , "" ),StringReplace ( $speicherini, ".ini" , "" ))
WEnd
EndIf
FileClose($search)
For $i=1 To 99
$balken[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken.bmp",-99,-99,50,10)
Next
For $i=1 To 99
$balken_senkrecht[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken_senkrecht.bmp",-99,-99,10,50)
Next
For $i=1 To 88
$snake_teil_bild[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\Snake.bmp",-99,-99,15,15)
Next
For $i=1 To 399
$hindernis_bild[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\Hindernis.bmp",-99,-99,30,30)
Next
$apfel_bild=GUICtrlCreatePic(@ScriptDir & "\Bilder\Apfel.bmp",200,200,20,20)
_level_laden($levelpath[1])
While 1
If WinActive($snake_gui) Then $snake_an=1
$msg=GUIGetMsg()
If $msg=$radio_not_relative Then
HotKeySet("{UP}","moveUP")
HotKeySet("{DOWN}","moveDOWN")
HotKeySet("{LEFT}","moveLEFT")
HotKeySet("{RIGHT}","moveRIGHT")
EndIf
If $msg=$radio_relative Then
HotKeySet("{LEFT}","moveLEFT_relative")
HotKeySet("{RIGHT}","moveRIGHT_relative")
HotKeySet("{UP}")
HotKeySet("{DOWN}")
EndIf
If $msg=$GUI_EVENT_CLOSE Then Exit
If $msg=$button_level_hinzufuegen Then
$level_anzahl=$level_anzahl+1
$levelpath[$level_anzahl]=GUICtrlRead($combo_levels)
GuiCtrlSetData($list,$level_anzahl & ". " &GUICtrlRead($combo_levels))
EndIf
If $msg=$button_play_level Then
$level=StringLeft(GUICtrlRead($list),3)
$level=StringReplace($level,".","")
$level=StringReplace($level," ","")
_level_laden($levelpath[$level])
EndIf
If $msg=$button_combo_refreshen Then
GUICtrlSetData($combo_levels,"")
$search=FileFindFirstFile(@ScriptDir & "\Level\*.ini")
If $search<>-1 Then
While 1
$speicherini=FileFindNextFile($search)
If @error=1 Then ExitLoop
GUICtrlSetData($combo_levels,StringReplace ( $speicherini, ".ini" , "" ),StringReplace ( $speicherini, ".ini" , "" ))
WEnd
EndIf
FileClose($search)
EndIf
If $msg=$button_save_levels Then
IniWrite(@ScriptDir & "\Playlist.ini","levels","Level_Anzahl",$level_anzahl)
For $i=1 To $level_anzahl
IniWrite(@ScriptDir & "\Playlist.ini","levels","Level" & $i,$levelpath[$i])
Next
EndIf
If $msg=$button_remove_level Then
$removing_item_level_number=StringLeft(GUICtrlRead($list),1)
If $removing_item_level_number=$level_anzahl Then
$level_anzahl=$level_anzahl-1
ElseIf $removing_item_level_number<$level_anzahl Then
For $u=$removing_item_level_number To $level_anzahl-1
$levelpath[$u]=$levelpath[$u+1]
Next
$level_anzahl=$level_anzahl-1
EndIf
GUICtrlSetData($list,"")
For $i=1 To $level_anzahl
GuiCtrlSetData($list, $i& ". " &$levelpath[$i], "1. " & $levelpath[1])
Next
$level=1
_level_laden($levelpath[$level])
EndIf
If $direction="right" Then
If $richtungsaenderung="up" Then
$direction="up"
$richtungsaenderung=""
ElseIf $richtungsaenderung="down" Then
$direction="down"
$richtungsaenderung=""
Else
$x=$x+15
EndIf
EndIf
If $direction="left" Then
If $richtungsaenderung="up" Then
$direction="up"
$richtungsaenderung=""
ElseIf $richtungsaenderung="down" Then
$direction="down"
$richtungsaenderung=""
Else
$x=$x-15
EndIf
EndIf
If $direction="up" Then
$y=$y-15
EndIf
If $direction="down" Then
$y=$y+15
EndIf
If _IsPressed(52) Then
Sleep(10)
Else
Sleep($sleep)
EndIf
;;; Pixel=red?
If StringMid ( Hex(PixelGetColor($x,$y)),3,2)="FF" Then _exit()
If StringMid ( Hex(PixelGetColor($x+5,$y+5)),3,2)="FF" Then _exit()
If StringMid ( Hex(PixelGetColor($x+10,$y+10)),3,2)="FF" Then _exit()
GUICtrlSetPos($snake_teil_bild[$snake_teil],$x,$y)
If Not $snake_teil_kopf=0 Then GUICtrlSetImage($snake_teil_bild[$snake_teil_kopf],@ScriptDir & "\Bilder\snake.bmp")
If $direction="left" Then GUICtrlSetImage($snake_teil_bild[$snake_teil],@ScriptDir & "\Bilder\snakekopfwest.bmp")
If $direction="right" Then GUICtrlSetImage($snake_teil_bild[$snake_teil],@ScriptDir & "\Bilder\snakekopfost.bmp")
If $direction="up" Then GUICtrlSetImage($snake_teil_bild[$snake_teil],@ScriptDir & "\Bilder\snakekopfnord.bmp")
If $direction="down" Then GUICtrlSetImage($snake_teil_bild[$snake_teil],@ScriptDir & "\Bilder\snakekopfsued.bmp")
$snake_teil_kopf=$snake_teil
For $i=1 To $balken_senkrecht_anzahl
If $balken_senkrecht_direction[$i]="up" Then $balken_senkrecht_y_pos[$i]=$balken_senkrecht_y_pos[$i]-10
If $balken_senkrecht_direction[$i]="down" Then $balken_senkrecht_y_pos[$i]=$balken_senkrecht_y_pos[$i]+10
;TrayTip("",$balken_x_pos,1000)
If $balken_senkrecht_y_pos[$i]=$balken_senkrecht_grenze_oben[$i] Then $balken_senkrecht_direction[$i]="down"
If $balken_senkrecht_y_pos[$i]=$balken_senkrecht_grenze_unten[$i]-50 Then $balken_senkrecht_direction[$i]="up"
GUICtrlSetPos($balken_senkrecht[$i],$balken_senkrecht_x_pos[$i],$balken_senkrecht_y_pos[$i])
Next
For $i=1 To $balken_anzahl
If $balken_direction[$i]="right" Then $balken_x_pos[$i]=$balken_x_pos[$i]+10
If $balken_direction[$i]="left" Then $balken_x_pos[$i]=$balken_x_pos[$i]-10
;TrayTip("",$balken_x_pos,1000)
If $balken_x_pos[$i]=$balken_grenze_rechts[$i]-50 Then $balken_direction[$i]="left"
If $balken_x_pos[$i]=$balken_grenze_links[$i] Then $balken_direction[$i]="right"
GUICtrlSetPos($balken[$i],$balken_x_pos[$i],$balken_y_pos[$i])
Next
$snake_teil=$snake_teil+1
If $snake_teil=$snake_length+1 Then $snake_teil=1
If $x>=$x_apfel-15 And $x<=$x_apfel+20 And $y>=$y_apfel-15 And $y<=$y_apfel+20 Then
$leave=0
While 1
$leave=1
$x_vor=Random ( 1 ,95 , 1 )
$x_apfel=$x_vor*10
$y_vor=Random ( 1 ,75 , 1 )
$y_apfel=$y_vor*10
;;; Pixel=green?
If StringMid ( Hex(PixelGetColor($x_apfel,$y_apfel)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel+15,$y_apfel)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel,$y_apfel+15)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel+15,$y_apfel+15)),5,2)<>"FF" Then $leave=0
;MsgBox(0,"",Hex(PixelGetColor($x+$win_x_pos,$y+$win_y_pos)) & " " &StringMid ( Hex(PixelGetColor($x+$win_x_pos,$y+$win_y_pos)),5,2)& " " & Hex(PixelGetColor($x+$win_x_pos+15,$y+$win_y_pos))& " " & StringMid ( Hex(PixelGetColor($x+$win_x_pos+15,$y+$win_y_pos)),5,2)& " " &Hex(PixelGetColor($x+$win_x_pos,$y+$win_y_pos+15))& " " &StringMid ( Hex(PixelGetColor($x+$win_x_pos,$y+$win_y_pos+15)),5,2)& " " & Hex(PixelGetColor($x+$win_x_pos+15,$y+$win_y_pos+15))& " " &StringMid ( Hex(PixelGetColor($x+$win_x_pos+15,$y+$win_y_pos+15)),5,2)& " " & $leave)
If $leave=1 Then ExitLoop
WEnd
GUICtrlSetPos($apfel_bild,$x_apfel,$y_apfel)
$apfel=$apfel+1
$insgesamt_apfel=$insgesamt_apfel+1
$snake_length=$snake_length+4
GUICtrlSetData($id_label_apples,$apfel_menge-$apfel & " apples remaining" & @CRLF & @CRLF & "Sleeptime: " & $sleep)
EndIf
If $apfel=$apfel_menge Then
MsgBox(0,"You got it!","Get ready for next round!")
If $level=$level_anzahl Then
$level=1
Else
$level=$level+1
EndIf
_level_laden($levelpath[$level])
EndIf
WEnd
Func antisoundfunction()
;blocks ugly sound output while pressing "r"
EndFunc
Func speedup()
If $sleep>0 Then $sleep=$sleep-10
GUICtrlSetData($id_label_apples,22-$snake_length/4 & " apples remaining" & @CRLF & @CRLF & "Sleeptime: " & $sleep)
EndFunc
Func speeddown()
$sleep=$sleep+10
EndFunc
Func moveUP()
If $direction<>"up" And $direction<>"down" Then $richtungsaenderung="up"
EndFunc
Func moveDOWN()
If $direction<>"down" And $direction<>"up" Then $richtungsaenderung="down"
EndFunc
Func moveLEFT()
If $direction<>"right" Then $direction="left"
EndFunc
Func moveRIGHT()
If $direction<>"left" Then $direction="right"
EndFunc
Func moveLEFT_relative()
If $direction="right" Then
$richtungsaenderung="up"
ElseIf $direction="up" Then
$direction="left"
ElseIf $direction="left" Then
$richtungsaenderung="down"
ElseIf $direction="down" Then
$direction="right"
EndIf
EndFunc
Func moveRIGHT_relative()
If $direction="right" Then
$richtungsaenderung="down"
ElseIf $direction="up" Then
$direction="right"
ElseIf $direction="left" Then
$richtungsaenderung="up"
ElseIf $direction="down" Then
$direction="left"
EndIf
EndFunc
Func _pause()
If $pause=0 Then
$pause=1
Else
$pause=0
EndIf
While 1
If $pause=0 Then ExitLoop
$msg=GUIGetMsg()
If $msg=$radio_not_relative Then
HotKeySet("{UP}","moveUP")
HotKeySet("{DOWN}","moveDOWN")
HotKeySet("{LEFT}","moveLEFT")
HotKeySet("{RIGHT}","moveRIGHT")
EndIf
If $msg=$radio_relative Then
HotKeySet("{LEFT}","moveLEFT_relative")
HotKeySet("{RIGHT}","moveRIGHT_relative")
HotKeySet("{UP}")
HotKeySet("{DOWN}")
EndIf
If $msg=$button_level_hinzufuegen Then
$level_anzahl=$level_anzahl+1
GuiCtrlSetData($list,$level_anzahl & ". " &GUICtrlRead($combo_levels))
EndIf
If $msg=$button_play_level Then
$level=StringLeft(GUICtrlRead($list),3)
$level=StringReplace($level,".","")
$level=StringReplace($level," ","")
_level_laden($levelpath[$level])
EndIf
If $msg=$button_combo_refreshen Then
GUICtrlSetData($combo_levels,"")
$search=FileFindFirstFile(@ScriptDir & "\Level\*.ini")
If $search<>-1 Then
While 1
$speicherini=FileFindNextFile($search)
If @error=1 Then ExitLoop
GUICtrlSetData($combo_levels,StringReplace ( $speicherini, ".ini" , "" ),StringReplace ( $speicherini, ".ini" , "" ))
WEnd
EndIf
FileClose($search)
EndIf
If $msg=$button_save_levels Then
IniWrite(@ScriptDir & "\Playlist.ini","levels","Level_Anzahl",$level_anzahl)
For $i=1 To $level_anzahl
IniWrite(@ScriptDir & "\Playlist.ini","levels","Level" & $i,$levelpath[$i])
Next
EndIf
If $msg=$button_remove_level Then
$removing_item_level_number=StringLeft(GUICtrlRead($list),1)
If $removing_item_level_number=$level_anzahl Then
$level_anzahl=$level_anzahl-1
ElseIf $removing_item_level_number<$level_anzahl Then
For $u=$removing_item_level_number To $level_anzahl-1
$levelpath[$u]=$levelpath[$u+1]
Next
$level_anzahl=$level_anzahl-1
EndIf
GUICtrlSetData($list,"")
For $i=1 To $level_anzahl
GuiCtrlSetData($list, $i& ". " &$levelpath[$i], "1. " & $levelpath[1])
Next
$level=1
_level_laden($levelpath[$level])
EndIf
WEnd
EndFunc
Func _level_laden($pfad)
$levelpfad=@ScriptDir & "\Level\" & $pfad & ".ini"
;MsgBox(0,$levelpfad,"")
$snake_length=8
$snake_teil=1
$apfel=0
GuiCtrlSetData($list, $level & ". " &$levelpath[$level])
For $i=1 To 99
GUICtrlSetPos($balken[$i],-99,-99)
Next
For $i=1 To 99
GUICtrlSetPos($balken_senkrecht[$i],-99,-99)
Next
For $i=1 To 399
GUICtrlSetPos($hindernis_bild[$i],-99,-99)
Next
For $i=1 To 88
GUICtrlSetPos($snake_teil_bild[$i],-99,-99)
Next
$sleep=IniRead($levelpfad,"Settings","Sleep",60)
$direction=IniRead($levelpfad,"Settings","direction","right")
$x=IniRead($levelpfad,"Settings","x_pos",100)
$y=IniRead($levelpfad,"Settings","y_pos",100)
$apfel_menge=IniRead($levelpfad,"Settings","Apfelmenge",20)
GUICtrlSetData($id_label_apples,$apfel_menge-$apfel & " apples remaining" & @CRLF & @CRLF & "Sleeptime: " & $sleep)
$balken_senkrecht_anzahl=IniRead($levelpfad,"Balkensenkrecht","Balken_anzahl",0)
For $i=1 To $balken_senkrecht_anzahl
$balken_senkrecht_x_pos[$i]=IniRead($levelpfad,"Balkensenkrecht","Balken_x_pos_" & $i,0)
$balken_senkrecht_y_pos[$i]=IniRead($levelpfad,"Balkensenkrecht","Balken_y_pos_" & $i,0)
$balken_senkrecht_grenze_oben[$i]=IniRead($levelpfad,"Balkensenkrecht","Balken_grenze_oben_" & $i,0)
$balken_senkrecht_grenze_unten[$i]=IniRead($levelpfad,"Balkensenkrecht","Balken_grenze_unten_" & $i,0)
GUICtrlSetPos($balken_senkrecht[$i],$balken_senkrecht_x_pos[$i],$balken_senkrecht_y_pos[$i])
$balken_senkrecht_direction[$i]="up"
Next
$balken_anzahl=IniRead($levelpfad,"Balken","Balken_anzahl",0)
For $i=1 To $balken_anzahl
$balken_x_pos[$i]=IniRead($levelpfad,"Balken","Balken_x_pos_" & $i,0)
$balken_y_pos[$i]=IniRead($levelpfad,"Balken","Balken_y_pos_" & $i,0)
$balken_grenze_rechts[$i]=IniRead($levelpfad,"Balken","Balken_grenze_rechts_" & $i,0)
$balken_grenze_links[$i]=IniRead($levelpfad,"Balken","Balken_grenze_links_" & $i,0)
GUICtrlSetPos($balken[$i],$balken_x_pos[$i],$balken_y_pos[$i])
$balken_direction[$i]="right"
Next
$hindernis_anzahl=IniRead($levelpfad,"Hindernis","Hindernis_anzahl",0)
For $i=1 To $hindernis_anzahl
$hindernis_x_pos[$i]=IniRead($levelpfad,"Hindernis","Hindernis_x_pos_" & $i,0)
$hindernis_y_pos[$i]=IniRead($levelpfad,"Hindernis","Hindernis_y_pos_" & $i,0)
GUICtrlSetPos($hindernis_bild[$i],$hindernis_x_pos[$i],$hindernis_y_pos[$i])
Next
$leave=0
While 1
$leave=1
$x_vor=Random ( 1 ,95 , 1 )
$x_apfel=$x_vor*10
$y_vor=Random ( 1 ,75 , 1 )
$y_apfel=$y_vor*10
If StringMid ( Hex(PixelGetColor($x_apfel,$y_apfel)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel+15,$y_apfel)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel,$y_apfel+15)),5,2)<>"FF" Then $leave=0
If StringMid ( Hex(PixelGetColor($x_apfel+15,$y_apfel+15)),5,2)<>"FF" Then $leave=0
If $leave=1 Then ExitLoop
WEnd
GUICtrlSetPos($apfel_bild,$x_apfel,$y_apfel)
EndFunc
Func _exit()
If $insgesamt_apfel=1 Then
$restart=MsgBox(4,"Gameover","You got " & $insgesamt_apfel & " apple!" & @crlf & @crlf & "Restart?")
Else
$restart=MsgBox(4,"Gameover","You got " & $insgesamt_apfel & " apples!" & @crlf & @crlf & "Restart?")
EndIf
If $restart=7 Then
Exit
Else
$insgesamt_apfel=0
$level=1
GUICtrlSetData($list,"1. " & $levelpath[$level])
_level_laden($levelpath[$level])
WinActivate($snake_gui)
EndIf
EndFunc
Alles anzeigen
und natürlich der Editor:
Spoiler anzeigen
C
#include <GUIConstants.au3>
#include <misc.au3>
HotKeySet("{DEL}","delete")
Global $mode="hand"
Global $hindernis[10000]
Global $hindernis_x_pos[10000]
Global $hindernis_y_pos[10000]
Global $hindernis_anzahl=0
Global $balken[100]
Global $balken_x_pos[100]
Global $balken_y_pos[100]
Global $balken_grenze_links[100]
Global $balken_grenze_rechts[100]
Global $balken_senkrecht[100]
Global $balken_senkrecht_x_pos[100]
Global $balken_senkrecht_y_pos[100]
Global $balken_senkrecht_grenze_oben[100]
Global $balken_senkrecht_grenze_unten[100]
Global $balken_anzahl=0
Global $balken_senkrecht_anzahl=0
Global $grenzen_bei=-1
Global $grenzen_senkrecht_bei=-1
Global $outcome_x=100
Global $outcome_y=100
Global $handbei=0
Global $handbeicontrol=""
Opt("MouseCoordMode",2)
$level_editor=GUICreate("Snake Level Editor",1160,800,0,0)
GUISetBkColor(0x00FF00)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_links.bmp",0,0,10,1000)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_links.bmp",990,0,10,1000)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_oben.bmp",10,0,980,10)
GUICtrlCreatePic(@ScriptDir & "\Bilder\hintergrund_oben.bmp",10,790,980,10)
$hindernis_mouse=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",-99,-99,30,30)
$balken_mouse=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken.bmp",-99,-99,50,10)
$balken_senkrecht_mouse=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken_senkrecht.bmp",-99,-99,10,50)
$balken_grenze_links_pic=GUICtrlCreatePic(@ScriptDir & "\Bilder\pfeil_links.bmp",-99,-99,6,10)
$balken_grenze_rechts_pic=GUICtrlCreatePic(@ScriptDir & "\Bilder\pfeil_rechts.bmp",-99,-99,6,10)
$balken_grenze_oben_pic=GUICtrlCreatePic(@ScriptDir & "\Bilder\pfeil_oben.bmp",-99,-99,10,6)
$balken_grenze_unten_pic=GUICtrlCreatePic(@ScriptDir & "\Bilder\pfeil_unten.bmp",-99,-99,10,6)
$outcome_pic=GUICtrlCreatePic(@ScriptDir & "\Bilder\outcome.bmp",100,100,15,15)
GUICtrlSetTip(-1,"Snake will come out here")
$radio_hindernis=GUICtrlCreateRadio("", 1030, 50, 50, 50, 0x1040)
GUICtrlSetImage(-1, @ScriptDir & "\Bilder\hindernis.bmp")
$radio_hand=GUICtrlCreateRadio("", 1080, 50, 50, 50, 0x1040)
GUICtrlSetImage(-1, @ScriptDir & "\Bilder\hmove.cur")
GUICtrlSetState(-1,$GUI_CHECKED)
$radio_balken=GUICtrlCreateRadio("", 1030, 100, 50, 50, 0x1040)
GUICtrlSetImage(-1, @ScriptDir & "\Bilder\balken_waagerecht.ico")
$radio_balken_senkrecht=GUICtrlCreateRadio("", 1080, 100, 50, 50, 0x1040)
GUICtrlSetImage(-1, @ScriptDir & "\Bilder\balken_senkrecht.ico")
$button_speichern=GUICtrlCreateButton("save level",1030,200,100,20)
$input_speichername=GUICtrlCreateInput("MyLevel1",1030,230,100,20)
$button_laden=GUICtrlCreateButton("load level",1030,400,100,20)
$button_refresh=GUICtrlCreateButton("refresh combo",1030,425,100,20)
$input_ladname=GUICtrlCreateCombo("MyLevel1",1030,370,100,20)
GUICtrlCreateLabel("Sleeptime (ms):",1030,260,100,20)
$input_sleep=GUICtrlCreateInput("60",1030,280,100,20)
GUICtrlCreateLabel("move direction:",1030,310,100,20)
$combo_direction=GUICtrlCreateCombo("right",1030,330,100,20)
GUICtrlSetData(-1,"left|up|down","right")
GUICtrlCreateLabel("number of apples:",1030,460,100,20)
$input_apfel_menge=GUICtrlCreateInput("20",1030,480,100,20)
GUISetState()
$search=FileFindFirstFile(@ScriptDir & "\Level\*.ini")
If $search<>-1 Then
While 1
$speicherini=FileFindNextFile($search)
If @error=1 Then ExitLoop
GUICtrlSetData($input_ladname,StringReplace ( $speicherini, ".ini" , "" ),StringReplace ( $speicherini, ".ini" , "" ))
WEnd
EndIf
FileClose($search)
While 1
;TrayTip("",$balken_anzahl,1000)
$msg=GUIGetMsg()
Select
Case $msg=$GUI_EVENT_CLOSE
Exit
Case $msg=$button_refresh
GUICtrlSetData($input_ladname,"")
$search=FileFindFirstFile(@ScriptDir & "\Level\*.ini")
If $search<>-1 Then
While 1
$speicherini=FileFindNextFile($search)
If @error=1 Then ExitLoop
GUICtrlSetData($input_ladname,StringReplace ( $speicherini, ".ini" , "" ),StringReplace ( $speicherini, ".ini" , "" ))
WEnd
EndIf
FileClose($search)
Case $msg=$radio_hindernis
If $mode="balken" Then GUICtrlSetPos($balken_mouse,-99,-99)
If $mode="balkensenkrecht" Then GUICtrlSetPos($balken_senkrecht_mouse,-99,-99)
$mode="hindernis"
Case $msg=$radio_hand
If $mode="hindernis" Then GUICtrlSetPos($hindernis_mouse,-99,-99)
If $mode="balken" Then GUICtrlSetPos($balken_mouse,-99,-99)
If $mode="balkensenkrecht" Then GUICtrlSetPos($balken_senkrecht_mouse,-99,-99)
$mode="hand"
Case $msg=$radio_balken
If $mode="hindernis" Then GUICtrlSetPos($hindernis_mouse,-99,-99)
If $mode="balkensenkrecht" Then GUICtrlSetPos($balken_senkrecht_mouse,-99,-99)
$mode="balken"
Case $msg=$radio_balken_senkrecht
If $mode="hindernis" Then GUICtrlSetPos($hindernis_mouse,-99,-99)
If $mode="balken" Then GUICtrlSetPos($balken_mouse,-99,-99)
$mode="balkensenkrecht"
Case $msg=$button_speichern
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Settings","Sleep",GUICtrlRead($input_sleep))
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Settings","direction",GUICtrlRead($combo_direction))
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Settings","x_pos",$outcome_x)
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Settings","y_pos",$outcome_y)
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Settings","Apfelmenge",GUICtrlRead($input_apfel_menge))
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Balkensenkrecht","Balken_anzahl",$balken_senkrecht_anzahl)
For $i=1 To $balken_senkrecht_anzahl
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balkensenkrecht","Balken_x_pos_" & $i,$balken_senkrecht_x_pos[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balkensenkrecht","Balken_y_pos_" & $i,$balken_senkrecht_y_pos[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balkensenkrecht","Balken_grenze_oben_" & $i,$balken_senkrecht_grenze_oben[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balkensenkrecht","Balken_grenze_unten_" & $i,$balken_senkrecht_grenze_unten[$i])
Next
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername) & ".ini","Balken","Balken_anzahl",$balken_anzahl)
For $i=1 To $balken_anzahl
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balken","Balken_x_pos_" & $i,$balken_x_pos[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balken","Balken_y_pos_" & $i,$balken_y_pos[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balken","Balken_grenze_rechts_" & $i,$balken_grenze_rechts[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Balken","Balken_grenze_links_" & $i,$balken_grenze_links[$i])
Next
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Hindernis","Hindernis_anzahl",$hindernis_anzahl)
For $i=1 To $hindernis_anzahl
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Hindernis","Hindernis_x_pos_" & $i,$hindernis_x_pos[$i])
IniWrite(@ScriptDir & "\Level\" & GUICtrlRead($input_speichername)& ".ini","Hindernis","Hindernis_y_pos_" & $i,$hindernis_y_pos[$i])
Next
Case $msg=$button_laden
For $i=1 To $balken_anzahl
GUICtrlDelete($balken[$i])
Next
For $i=1 To $balken_senkrecht_anzahl
GUICtrlDelete($balken_senkrecht[$i])
Next
For $i=1 To $hindernis_anzahl
GUICtrlDelete($hindernis[$i])
Next
GUICtrlSetPos($balken_grenze_rechts_pic,-99,-99)
GUICtrlSetPos($balken_grenze_links_pic,-99,-99)
GUICtrlSetPos($balken_grenze_oben_pic,-99,-99)
GUICtrlSetPos($balken_grenze_unten_pic,-99,-99)
$sleep=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Settings","Sleep",60)
GUICtrlSetData($input_sleep,$sleep)
$direction=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Settings","direction","right")
GUICtrlSetData($combo_direction,$direction)
$outcome_x=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Settings","x_pos",100)
$outcome_y=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Settings","y_pos",100)
GUICtrlSetPos($outcome_pic,$outcome_x,$outcome_y)
$balken_senkrecht_anzahl=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Balkensenkrecht","Balken_anzahl",0)
For $i=1 To $balken_senkrecht_anzahl
$balken_senkrecht_x_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balkensenkrecht","Balken_x_pos_" & $i,0)
$balken_senkrecht_y_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balkensenkrecht","Balken_y_pos_" & $i,0)
$balken_senkrecht_grenze_oben[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balkensenkrecht","Balken_grenze_oben_" & $i,0)
$balken_senkrecht_grenze_unten[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balkensenkrecht","Balken_grenze_unten_" & $i,0)
$balken_senkrecht[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken_senkrecht.bmp",$balken_senkrecht_x_pos[$i],$balken_senkrecht_y_pos[$i],10,50)
Next
$balken_anzahl=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname) & ".ini","Balken","Balken_anzahl",0)
For $i=1 To $balken_anzahl
$balken_x_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balken","Balken_x_pos_" & $i,0)
$balken_y_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balken","Balken_y_pos_" & $i,0)
$balken_grenze_rechts[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balken","Balken_grenze_rechts_" & $i,0)
$balken_grenze_links[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Balken","Balken_grenze_links_" & $i,0)
$balken[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken.bmp",$balken_x_pos[$i],$balken_y_pos[$i],50,10)
Next
$hindernis_anzahl=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Hindernis","Hindernis_anzahl",0)
For $i=1 To $hindernis_anzahl
$hindernis_x_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Hindernis","Hindernis_x_pos_" & $i,0)
$hindernis_y_pos[$i]=IniRead(@ScriptDir & "\Level\" & GUICtrlRead($input_ladname)& ".ini","Hindernis","Hindernis_y_pos_" & $i,0)
$hindernis[$i]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$i],$hindernis_y_pos[$i],30,30)
Next
EndSelect
If WinActive($level_editor) Then
#region ---hand mode---
If $msg=$outcome_pic Then
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$outcome_x=Round($pos[0]/15)*15-5
$outcome_y=Round($pos[1]/15)*15-5
GUICtrlSetPos($outcome_pic,$outcome_x,$outcome_y)
WEnd
EndIf
For $i=1 To $balken_anzahl
If $msg=$balken[$i] Then
$handbeicontrol="Balken"
$handbei=$i
GUICtrlSetPos($balken_grenze_links_pic,$balken_grenze_links[$i],$balken_y_pos[$i])
GUICtrlSetPos($balken_grenze_rechts_pic,$balken_grenze_rechts[$i],$balken_y_pos[$i])
$grenzen_bei=$i
$pos=MouseGetPos()
$abstand_links=Round($pos[0]/10)*10-$balken_x_pos[$i]
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$balken_grenze_links[$i]=$balken_grenze_links[$i]-$balken_x_pos[$i]+Round($pos[0]/10)*10-$abstand_links
$balken_grenze_rechts[$i]=$balken_grenze_rechts[$i]-$balken_x_pos[$i]+Round($pos[0]/10)*10-$abstand_links
$balken_x_pos[$i]=Round($pos[0]/10)*10-$abstand_links
$balken_y_pos[$i]=Round($pos[1]/10)*10
GUICtrlSetPos($balken[$i],$balken_x_pos[$i],$balken_y_pos[$grenzen_bei])
GUICtrlSetPos($balken_grenze_links_pic,$balken_grenze_links[$i],$balken_y_pos[$grenzen_bei])
GUICtrlSetPos($balken_grenze_rechts_pic,$balken_grenze_rechts[$i]-6,$balken_y_pos[$grenzen_bei])
WEnd
EndIf
Next
For $i=1 To $balken_senkrecht_anzahl
If $msg=$balken_senkrecht[$i] Then
$handbeicontrol="Balkensen"
$handbei=$i
GUICtrlSetPos($balken_grenze_oben_pic,$balken_senkrecht_x_pos[$i],$balken_senkrecht_grenze_oben[$i])
GUICtrlSetPos($balken_grenze_unten_pic,$balken_senkrecht_x_pos[$i],$balken_senkrecht_grenze_unten[$i]-6)
$grenzen_senkrecht_bei=$i
$pos=MouseGetPos()
$abstand_hoch=Round($pos[1]/10)*10-$balken_senkrecht_y_pos[$i]
While _IsPressed(01)
Sleep(10)
;TrayTip("",$balken_senkrecht_grenze_oben[$i] & " " & $balken_senkrecht_grenze_unten[$i],1000)
$pos=MouseGetPos()
$balken_senkrecht_grenze_oben[$i]=$balken_senkrecht_grenze_oben[$i]-$balken_senkrecht_y_pos[$i]+Round($pos[1]/10)*10-$abstand_hoch
$balken_senkrecht_grenze_unten[$i]=$balken_senkrecht_grenze_unten[$i]-$balken_senkrecht_y_pos[$i]+Round($pos[1]/10)*10-$abstand_hoch
$balken_senkrecht_x_pos[$i]=Round($pos[0]/10)*10
$balken_senkrecht_y_pos[$i]=Round($pos[1]/10)*10-$abstand_hoch
GUICtrlSetPos($balken_senkrecht[$i],$balken_senkrecht_x_pos[$i],$balken_senkrecht_y_pos[$i])
GUICtrlSetPos($balken_grenze_oben_pic,$balken_senkrecht_x_pos[$i],$balken_senkrecht_grenze_oben[$i])
GUICtrlSetPos($balken_grenze_unten_pic,$balken_senkrecht_x_pos[$i],$balken_senkrecht_grenze_unten[$i]-6)
WEnd
EndIf
Next
For $i=1 To $hindernis_anzahl
If $msg=$hindernis[$i] Then
$handbeicontrol="Hindernis"
$handbei=$i
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$hindernis_x_pos[$i]=Round($pos[0]/10)*10
$hindernis_y_pos[$i]=Round($pos[1]/10)*10
GUICtrlSetPos($hindernis[$i],$hindernis_x_pos[$i],$hindernis_y_pos[$i])
WEnd
EndIf
Next
If $msg=$balken_grenze_links_pic Then
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$balken_grenze_links_vorlaeufig=Round($pos[0]/10)*10
GUICtrlSetPos($balken_grenze_links_pic,$balken_grenze_links_vorlaeufig,$balken_y_pos[$grenzen_bei])
WEnd
$balken_grenze_links[$grenzen_bei]=$balken_grenze_links_vorlaeufig
EndIf
If $msg=$balken_grenze_rechts_pic Then
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$balken_grenze_rechts_vorlaeufig=Round($pos[0]/10)*10
GUICtrlSetPos($balken_grenze_rechts_pic,$balken_grenze_rechts_vorlaeufig-6,$balken_y_pos[$grenzen_bei])
WEnd
$balken_grenze_rechts[$grenzen_bei]=$balken_grenze_rechts_vorlaeufig
EndIf
If $msg=$balken_grenze_oben_pic Then
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$balken_grenze_oben_vorlaeufig=Round($pos[1]/10)*10
GUICtrlSetPos($balken_grenze_oben_pic,$balken_senkrecht_x_pos[$grenzen_senkrecht_bei],$balken_grenze_oben_vorlaeufig)
WEnd
$balken_senkrecht_grenze_oben[$grenzen_senkrecht_bei]=$balken_grenze_oben_vorlaeufig
EndIf
If $msg=$balken_grenze_unten_pic Then
While _IsPressed(01)
Sleep(10)
$pos=MouseGetPos()
$balken_grenze_unten_vorlaeufig=Round($pos[1]/10)*10
GUICtrlSetPos($balken_grenze_unten_pic,$balken_senkrecht_x_pos[$grenzen_senkrecht_bei],$balken_grenze_unten_vorlaeufig-6)
WEnd
$balken_senkrecht_grenze_unten[$grenzen_senkrecht_bei]=$balken_grenze_unten_vorlaeufig
EndIf
#endregion ---hand mode---
#region ---balken mode---
If $mode="balken" Then
$pos=MouseGetPos()
If Round($pos[0]/10)*10<=940 And Round($pos[0]/10)*10>=10 And Round($pos[1]/10)*10<=780 And Round($pos[1]/10)*10>=10 Then GUICtrlSetPos($balken_mouse,Round($pos[0]/10)*10,Round($pos[1]/10)*10)
EndIf
If _IsPressed(01) And $mode="balken" Then
$pos=MouseGetPos()
$balken_x_pos[$balken_anzahl+1]=Round($pos[0]/10)*10
$balken_y_pos[$balken_anzahl+1]=Round($pos[1]/10)*10
$belegt=0
If $balken_anzahl>0 Then
For $i=1 To $balken_anzahl
If $balken_x_pos[$balken_anzahl+1]=$balken_x_pos[$i] And $balken_y_pos[$balken_anzahl+1]=$balken_y_pos[$i] Then $belegt=1
Next
EndIf
;MsgBox(0,$hindernis_x_pos[$hindernis_anzahl+1],$hindernis_y_pos[$hindernis_anzahl+1])
If $balken_x_pos[$balken_anzahl+1]>940 Or $balken_x_pos[$balken_anzahl+1]<10 Or $balken_y_pos[$balken_anzahl+1]>780 Or $balken_y_pos[$balken_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$balken_anzahl=$balken_anzahl+1
$balken[$balken_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken.bmp",$balken_x_pos[$balken_anzahl],$balken_y_pos[$balken_anzahl],50,10)
$balken_grenze_rechts[$balken_anzahl]=$balken_x_pos[$balken_anzahl]+100
$balken_grenze_links[$balken_anzahl]=$balken_x_pos[$balken_anzahl]-50
EndIf
;MsgBox(0,$balken_anzahl,"")
While _IsPressed(01)
Sleep(10)
WEnd
EndIf
#endregion ---balken mode---
#region ---balken mode senkrecht---
If $mode="balkensenkrecht" Then
$pos=MouseGetPos()
If Round($pos[0]/10)*10<=980 And Round($pos[0]/10)*10>=10 And Round($pos[1]/10)*10<=740 And Round($pos[1]/10)*10>=10 Then GUICtrlSetPos($balken_senkrecht_mouse,Round($pos[0]/10)*10,Round($pos[1]/10)*10)
EndIf
If _IsPressed(01) And $mode="balkensenkrecht" Then
$pos=MouseGetPos()
$balken_senkrecht_x_pos[$balken_senkrecht_anzahl+1]=Round($pos[0]/10)*10
$balken_senkrecht_y_pos[$balken_senkrecht_anzahl+1]=Round($pos[1]/10)*10
$belegt=0
If $balken_senkrecht_anzahl>0 Then
For $i=1 To $balken_senkrecht_anzahl
If $balken_senkrecht_x_pos[$balken_senkrecht_anzahl+1]=$balken_senkrecht_x_pos[$i] And $balken_senkrecht_y_pos[$balken_senkrecht_anzahl+1]=$balken_senkrecht_y_pos[$i] Then $belegt=1
Next
EndIf
;MsgBox(0,$hindernis_x_pos[$hindernis_anzahl+1],$hindernis_y_pos[$hindernis_anzahl+1])
If $balken_senkrecht_x_pos[$balken_senkrecht_anzahl+1]>940 Or $balken_senkrecht_x_pos[$balken_senkrecht_anzahl+1]<10 Or $balken_senkrecht_y_pos[$balken_senkrecht_anzahl+1]>780 Or $balken_senkrecht_y_pos[$balken_senkrecht_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$balken_senkrecht_anzahl=$balken_senkrecht_anzahl+1
$balken_senkrecht[$balken_senkrecht_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\balken_senkrecht.bmp",$balken_senkrecht_x_pos[$balken_senkrecht_anzahl],$balken_senkrecht_y_pos[$balken_senkrecht_anzahl],10,50)
$balken_senkrecht_grenze_oben[$balken_senkrecht_anzahl]=$balken_senkrecht_y_pos[$balken_senkrecht_anzahl]-50
$balken_senkrecht_grenze_unten[$balken_senkrecht_anzahl]=$balken_senkrecht_y_pos[$balken_senkrecht_anzahl]+100
EndIf
;MsgBox(0,$balken_anzahl,"")
While _IsPressed(01)
Sleep(10)
WEnd
EndIf
#endregion ---balken mode---
#region ---hindernis mode---
If $mode="hindernis" Then
$pos=MouseGetPos()
If Round($pos[0]/10)*10<=960 And Round($pos[0]/10)*10>=10 And Round($pos[1]/10)*10<=760 And Round($pos[1]/10)*10>=10 Then GUICtrlSetPos($hindernis_mouse,Round($pos[0]/10)*10,Round($pos[1]/10)*10)
EndIf
If _IsPressed(01) And $mode="hindernis" Then
$pos=MouseGetPos()
$hindernis_x_pos[$hindernis_anzahl+1]=Round($pos[0]/10)*10
$hindernis_y_pos[$hindernis_anzahl+1]=Round($pos[1]/10)*10
$belegt=0
If $hindernis_anzahl>0 Then
For $i=1 To $hindernis_anzahl
If $hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$i] And $hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$i] Then $belegt=1
Next
EndIf
;MsgBox(0,$hindernis_x_pos[$hindernis_anzahl+1],$hindernis_y_pos[$hindernis_anzahl+1])
If $hindernis_x_pos[$hindernis_anzahl+1]>960 Or $hindernis_x_pos[$hindernis_anzahl+1]<10 Or $hindernis_y_pos[$hindernis_anzahl+1]>760 Or $hindernis_y_pos[$hindernis_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$hindernis_anzahl=$hindernis_anzahl+1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
;MsgBox(0,$hindernis_anzahl,"")
While 1
$pos=MouseGetPos()
If $hindernis_x_pos[$hindernis_anzahl]-$pos[0]>30 Then
$hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$hindernis_anzahl]-30
$hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$hindernis_anzahl]
$belegt=0
If $hindernis_anzahl>0 Then
For $i=1 To $hindernis_anzahl
If $hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$i] And $hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$i] Then $belegt=1
Next
EndIf
If $hindernis_x_pos[$hindernis_anzahl+1]>960 Or $hindernis_x_pos[$hindernis_anzahl+1]<10 Or $hindernis_y_pos[$hindernis_anzahl+1]>760 Or $hindernis_y_pos[$hindernis_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$hindernis_anzahl=$hindernis_anzahl+1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]=0 Then
While 1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]<>0 Then ExitLoop
WEnd
EndIf
EndIf
ElseIf $hindernis_x_pos[$hindernis_anzahl]-$pos[0]<-30 Then
$hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$hindernis_anzahl]+30
$hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$hindernis_anzahl]
$belegt=0
If $hindernis_anzahl>0 Then
For $i=1 To $hindernis_anzahl
If $hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$i] And $hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$i] Then $belegt=1
Next
EndIf
If $hindernis_x_pos[$hindernis_anzahl+1]>960 Or $hindernis_x_pos[$hindernis_anzahl+1]<10 Or $hindernis_y_pos[$hindernis_anzahl+1]>760 Or $hindernis_y_pos[$hindernis_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$hindernis_anzahl=$hindernis_anzahl+1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]=0 Then
While 1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]<>0 Then ExitLoop
WEnd
EndIf
EndIf
ElseIf $hindernis_y_pos[$hindernis_anzahl]-$pos[1]>30 Then
$hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$hindernis_anzahl]-30
$hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$hindernis_anzahl]
$belegt=0
;TrayTip("",$hindernis_anzahl& " " & $hindernis_x_pos[$hindernis_anzahl+1] & " " &$hindernis_x_pos[$hindernis_anzahl] & " " & $hindernis_y_pos[$hindernis_anzahl+1]& " " &$hindernis_y_pos[$hindernis_anzahl],1000)
;sleep(2000)
If $hindernis_anzahl>0 Then
For $i=1 To $hindernis_anzahl
If $hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$i] And $hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$i] Then $belegt=1
;TrayTip("",$hindernis_anzahl& " " &$i & " " & $hindernis_x_pos[$hindernis_anzahl+1] & " " &$hindernis_x_pos[$i] & " " & $hindernis_x_pos[$hindernis_anzahl+1]& " " &$hindernis_x_pos[$i],1000)
;Sleep(5000)
Next
EndIf
If $hindernis_x_pos[$hindernis_anzahl+1]>960 Or $hindernis_x_pos[$hindernis_anzahl+1]<10 Or $hindernis_y_pos[$hindernis_anzahl+1]>760 Or $hindernis_y_pos[$hindernis_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$hindernis_anzahl=$hindernis_anzahl+1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]=0 Then
While 1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]<>0 Then ExitLoop
WEnd
EndIf
EndIf
ElseIf $hindernis_y_pos[$hindernis_anzahl]-$pos[1]<-30 Then
$hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$hindernis_anzahl]+30
$hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$hindernis_anzahl]
$belegt=0
If $hindernis_anzahl>0 Then
For $i=1 To $hindernis_anzahl
If $hindernis_x_pos[$hindernis_anzahl+1]=$hindernis_x_pos[$i] And $hindernis_y_pos[$hindernis_anzahl+1]=$hindernis_y_pos[$i] Then $belegt=1
Next
EndIf
If $hindernis_x_pos[$hindernis_anzahl+1]>960 Or $hindernis_x_pos[$hindernis_anzahl+1]<10 Or $hindernis_y_pos[$hindernis_anzahl+1]>760 Or $hindernis_y_pos[$hindernis_anzahl+1]<10 Then $belegt=1
If $belegt=0 Then
$hindernis_anzahl=$hindernis_anzahl+1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]=0 Then
While 1
$hindernis[$hindernis_anzahl]=GUICtrlCreatePic(@ScriptDir & "\Bilder\hindernis.bmp",$hindernis_x_pos[$hindernis_anzahl],$hindernis_y_pos[$hindernis_anzahl],30,30)
If $hindernis[$hindernis_anzahl]<>0 Then ExitLoop
WEnd
EndIf
EndIf
EndIf
If Not _IsPressed(01) Then ExitLoop
WEnd
EndIf
EndIf
#endregion ---hindernis mode---
EndIf
WEnd
Func delete()
If $handbeicontrol="Hindernis" Then
GUICtrlDelete($hindernis[$handbei])
If $handbei=$hindernis_anzahl Then
$hindernis_anzahl=$hindernis_anzahl-1
ElseIf $handbei<$hindernis_anzahl Then
For $u=$handbei To $hindernis_anzahl-1
$hindernis_x_pos[$u]=$hindernis_x_pos[$u+1]
$hindernis_y_pos[$u]=$hindernis_y_pos[$u+1]
$hindernis[$u]=$hindernis[$u+1]
Next
$hindernis_anzahl=$hindernis_anzahl-1
EndIf
EndIf
If $handbeicontrol="Balken" Then
GUICtrlDelete($balken[$handbei])
GUICtrlSetPos($balken_grenze_rechts_pic,-99,-99)
GUICtrlSetPos($balken_grenze_links_pic,-99,-99)
If $handbei=$balken_anzahl Then
$balken_anzahl=$balken_anzahl-1
ElseIf $handbei<$balken_anzahl Then
For $u=$handbei To $balken_anzahl-1
$balken[$u]=$balken[$u+1]
$balken_x_pos[$u]=$balken_x_pos[$u+1]
$balken_y_pos[$u]=$balken_y_pos[$u+1]
$balken_grenze_links[$u]=$balken_grenze_links[$u+1]
$balken_grenze_rechts[$u]=$balken_grenze_rechts[$u+1]
Next
$balken_anzahl=$balken_anzahl-1
EndIf
EndIf
If $handbeicontrol="Balkensen" Then
GUICtrlDelete($balken_senkrecht[$handbei])
GUICtrlSetPos($balken_grenze_oben_pic,-99,-99)
GUICtrlSetPos($balken_grenze_unten_pic,-99,-99)
If $handbei=$balken_senkrecht_anzahl Then
$balken_senkrecht_anzahl=$balken_senkrecht_anzahl-1
ElseIf $handbei<$balken_senkrecht_anzahl Then
For $u=$handbei To $balken_senkrecht_anzahl-1
$balken_senkrecht[$u]=$balken_senkrecht[$u+1]
$balken_senkrecht_x_pos[$u]=$balken_senkrecht_x_pos[$u+1]
$balken_senkrecht_y_pos[$u]=$balken_senkrecht_y_pos[$u+1]
$balken_senkrecht_grenze_oben[$u]=$balken_senkrecht_grenze_oben[$u+1]
$balken_senkrecht_grenze_unten[$u]=$balken_senkrecht_grenze_unten[$u+1]
Next
$balken_senkrecht_anzahl=$balken_senkrecht_anzahl-1
EndIf
EndIf
EndFunc
Alles anzeigen
Edit: Formatierung (peethebee)
Es sind ziemleich viele pics und so dabei, also einfach die *.zip entpacken bitte und die ordner so angeordnet lassen.
Viel Spaß!