• So, endlich fertig (Freude):
    Jetzt ca. 5 Tage dran gearbeitet, zuerst komische Bugs,aber dann ging es laufend ^^
    Rausgekommen ein schönes Defense

    Mit 680 Zeilen, sogerade nicht mein längstes Script :P

    Also, Screenshot:
    autoit.de/wcf/attachment/9721/

    Code
    [autoit]


    #NoTrayIcon
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_icon=TheShadowAE.ico
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    ;Coder: TheShadowAE
    ;~ #include <GDIP.au3>
    #include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    #include <GuiConstantsEx.au3>
    #include <Misc.au3>
    #include <Sound.au3>

    [/autoit] [autoit][/autoit] [autoit]

    ;Funcvars
    Global $font,$format

    [/autoit] [autoit][/autoit] [autoit]

    ;Variablen
    Global $title="Defense 1.0 by TheShadowAE"
    Global $winx=400,$winy=400
    Global $gx=400,$gy=320

    [/autoit] [autoit][/autoit] [autoit]

    Global $map[20][16]
    Global $turm[20][16][5] ;range,power,load,nowload,winkel
    Global $turmnorm[3][3]=[[2,4,800],[4,5,500],[5,3,100]] ;range,power,load
    Global $turmkosten[3]=[50,100,350]
    Global $enemyinfos=8
    Global $enemy[1][8] ;px,py,x,y,gesundheit,geschwindigkeit ,oldx,oldy
    Global $normene[3][3] ;gesundheit,geschwindigkeit,geld
    Global $enemyname[3]=["Smileyvirus","Augenbazille","Feuerkürbis"]
    Global $imgene[3]
    Global $nowene,$nextene
    Global $enein=0,$enemys,$enemysin=0
    Global $enewinkel=0,$minene=5,$maxene=15
    Global $eneskill

    [/autoit] [autoit][/autoit] [autoit]

    Global $user32=DllOpen("user32.dll")
    Global $timer=TimerInit()
    Global $pos[2]
    Global $bau
    Global $info

    [/autoit] [autoit][/autoit] [autoit]

    Global $gra,$buffer,$backgra,$gui
    Global $infobg,$street,$field,$street2
    Global $brush,$pen
    Global $imgturm[3]
    Global $sendalpha=160,$malpha=160,$fxalpha=160
    Global $clickmx,$clickfx

    [/autoit] [autoit][/autoit] [autoit]

    Global $level,$money,$lifes,$score

    [/autoit] [autoit][/autoit] [autoit]

    Global $menubg,$cardead,$shotsound[3]
    Global $soundon=1,$fxon=1

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;GUI
    $gui=GUICreate($title,$winx,$winy)
    GUISetBkColor("0x000000")
    GUISetState()
    Opt("GuiOnEventMode",1)
    GUISetOnEvent($GUI_EVENT_CLOSE,"_exit")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;GDI+
    _GDIPlus_Startup()
    $gra=_GDIPlus_GraphicsCreateFromHWND($gui)
    $buffer=_GDIPlus_BitmapCreateFromGraphics($winx,$winy,$gra)
    $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
    _GDIPlus_GraphicsSetSmoothingMode($backgra,2)

    [/autoit] [autoit][/autoit] [autoit]

    FileChangeDir(@ScriptDir&"\GFX")
    $infobg=_GDIPlus_ImageLoadFromFile("infobg.png")
    $street=_GDIPlus_ImageLoadFromFile("street.png")
    $street2=_GDIPlus_ImageLoadFromFile("street2.png")
    $field=_GDIPlus_ImageLoadFromFile("field.png")
    $imgturm[0]=_GDIPlus_ImageLoadFromFile("tower_1.png")
    $imgturm[1]=_GDIPlus_ImageLoadFromFile("tower_2.png")
    $imgturm[2]=_GDIPlus_ImageLoadFromFile("tower_3.png")
    $imgene[0]=_GDIPlus_ImageLoadFromFile("ufo.png")
    $imgene[1]=_GDIPlus_ImageLoadFromFile("ufo2.png")
    $imgene[2]=_GDIPlus_ImageLoadFromFile("ufo3.png")
    $brush=_GDIPlus_BrushCreateSolid("0xFFFFFFFF")
    $pen=_GDIPlus_PenCreate("0xFFFFFFFF",2)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Sound
    FileChangeDir(@ScriptDir&"\SFX")
    $shotsound[0]=_SoundOpen("cannon.mp3")
    $shotsound[1]=_SoundOpen("rocket.mp3")
    $shotsound[2]=_SoundOpen("shot.mp3")
    $menubg=_SoundOpen("menubg.mp3")
    $cardead=_SoundOpen("cardead.mp3")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Hauptprogramm
    _DSStart("Arial",8,1);Fett
    _G_Start()

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    ;Tasten
    $mps=_WinAPI_GetMousePos(True,$gui)
    $pos[0]=DllStructGetData($mps,"X")
    $pos[1]=DllStructGetData($mps,"Y")
    ;~ ToolTip("X:"&$pos[0]&" Y:"&$pos[1])
    If WinActive($gui)<>0 Then
    Select
    Case $pos[0]>=$gx-60 And $pos[0]<=$gx And $pos[1]>=$gy-20 And $pos[1]<=$gy
    $sendalpha=255
    If _IsPressed("1",$user32) And $enemysin=0 Then
    $enemysin=1
    $enein=0
    $nowene=$nextene
    $nextene=Random(0,2,1)
    $enemys=Random($minene,$maxene,1)
    ReDim $enemy[$enemys][$enemyinfos]
    AdlibRegister("sendin",1500)
    EndIf
    Case $pos[0]>=75 And $pos[1]>=325 And $pos[0]<=100 And $pos[1]<=350
    $info=0
    If _IsPressed("1",$user32) And $money>=$turmkosten[0] Then
    $bau=3
    EndIf
    Case $pos[0]>=107 And $pos[1]>=325 And $pos[0]<=132 And $pos[1]<=350
    $info=1
    If _IsPressed("1",$user32) And $money>=$turmkosten[1] Then
    $bau=4
    EndIf
    Case $pos[0]>=77 And $pos[1]>=360 And $pos[0]<=102 And $pos[1]<=385
    $info=2
    If _IsPressed("1",$user32) And $money>=$turmkosten[2] Then
    $bau=5
    EndIf
    Case $pos[0]>=360 And $pos[0]<=400 And $pos[1]>=0 And $pos[1]<=20
    If $pos[0]<=380 Then
    $fxalpha=255
    $malpha=160
    If _IsPressed("1",$user32) And TimerDiff($timer)>=$clickfx+150 Then
    _change($fxon)
    $clickfx=TimerDiff($timer)
    EndIf
    Else
    $fxalpha=160
    $malpha=255
    If _IsPressed("1",$user32) And TimerDiff($timer)>=$clickmx+150 Then
    _change($soundon)
    If $soundon=0 Then
    _SoundPause($menubg)
    Else
    _SoundResume($menubg)
    EndIf
    $clickmx=TimerDiff($timer)
    EndIf
    EndIf
    Case Else
    $sendalpha=160
    $fxalpha=160
    $malpha=160
    EndSelect
    EndIf
    ;Variablen
    If $lifes<=0 Then _G_over()
    ;usw
    If $soundon Then
    If _SoundPos($menubg,2)>=_SoundLength($menubg,2)-150 Then
    _SoundSeek($menubg,0,0,0)
    _SoundPlay($menubg)
    EndIf
    EndIf
    ;##Malen
    ;#oben ...+winkel
    For $x=0 To 19
    For $y=0 To 15
    Switch $map[$x][$y]
    Case 0
    _GDIPlus_GraphicsDrawImageRect($backgra,$field,$x*20,$y*20,20,20)
    Case 1
    _GDIPlus_GraphicsDrawImageRect($backgra,$street,$x*20,$y*20,20,20)
    Case 2
    _GDIPlus_GraphicsDrawImageRect($backgra,$street2,$x*20,$y*20,20,20)
    Case 3
    _dotower($x,$y)
    _plattform($backgra,$x*20,$y*20,20,20,"0xFFDDDD00")
    _DrawTurned($backgra,$imgturm[$map[$x][$y]-3],$turm[$x][$y][4],$x*20,$y*20)
    Case 4
    _dotower($x,$y)
    _plattform($backgra,$x*20,$y*20,20,20,"0xFF00AA00")
    _DrawTurned($backgra,$imgturm[$map[$x][$y]-3],$turm[$x][$y][4],$x*20,$y*20)
    Case 5
    _dotower($x,$y)
    _plattform($backgra,$x*20,$y*20,20,20,"0xFFAAAAAA")
    _DrawTurned($backgra,$imgturm[$map[$x][$y]-3],$turm[$x][$y][4],$x*20,$y*20)
    EndSwitch
    Next
    Next
    ;Startusw
    If $bau<>0 Then
    $x=Floor($pos[0]/20.01)
    $y=Floor($pos[1]/20.01)
    $color="0xFFDDDD00"
    If $bau=4 Then $color="0xFF00AA00"
    If $bau=5 Then $color="0xFFAAAAAA"
    _plattform($backgra,$x*20,$y*20,20,20,$color)
    _GDIPlus_GraphicsDrawImageRect($backgra,$imgturm[$bau-3],$x*20,$y*20,20,20)
    If _IsPressed("2",$user32) Then
    $bau=0
    ElseIf _IsPressed("1",$user32) Then
    Select
    Case $x<0
    Case $y<0
    Case $x>19
    Case $y>15
    Case $x>=18 And $y=0
    Case $y=15 And $x>=17
    Case Else
    If $map[$x][$y]=0 And $money>=$turmkosten[$bau-3] Then
    $map[$x][$y]=$bau
    $turm[$x][$y][0]=$turmnorm[$bau-3][0]
    $turm[$x][$y][1]=$turmnorm[$bau-3][1]
    $turm[$x][$y][2]=$turmnorm[$bau-3][2]
    $turm[$x][$y][3]=TimerDiff($timer)
    $turm[$x][$y][4]=0
    $money-=$turmkosten[$bau-3]
    $bau=0
    EndIf
    EndSelect
    EndIf
    EndIf
    For $x=0 To $enein-1
    If $enemy[$x][2]*20>Round($enemy[$x][0],0) Then
    $enemy[$x][0]+=$enemy[$x][5]
    ElseIf $enemy[$x][2]*20<Round($enemy[$x][0],0) Then
    $enemy[$x][0]-=$enemy[$x][5]
    ElseIf $enemy[$x][3]*20<Round($enemy[$x][1],0) Then
    $enemy[$x][1]-=$enemy[$x][5]
    ElseIf $enemy[$x][3]*20>Round($enemy[$x][1],0) Then
    $enemy[$x][1]+=$enemy[$x][5]
    Else
    If $enemy[$x][2]=19 And $enemy[$x][3]=3 Then
    $enemy[$x][6]=$enemy[$x][2]
    $enemy[$x][7]=$enemy[$x][3]
    $enemy[$x][2]=20
    $enemy[$x][3]=3
    _doittoo()
    ContinueLoop
    EndIf
    If $enemy[$x][2]>=20 Then
    $enein-=1
    $score+=1
    $lifes-=1
    $enemys-=1
    If $fxon Then _SoundPlay($cardead)
    If $enein<=0 Then
    $enemysin=0
    $enewinkel=0
    $level+=1
    _levelup()
    EndIf
    For $y=$x To $enein-1
    For $z=0 To $enemyinfos-1
    $enemy[$y][$z]=$enemy[$y+1][$z]
    Next
    Next
    EndIf
    $checkx=$enemy[$x][2]-1
    $checky=$enemy[$x][3]
    If $checkx>=0 And ($enemy[$x][6]<>$checkx Or $enemy[$x][7]<>$checky) Then
    If $map[$checkx][$checky]=1 Or $map[$checkx][$checky]=2 Then
    $enemy[$x][6]=$enemy[$x][2]
    $enemy[$x][7]=$enemy[$x][3]
    $enemy[$x][2]=$checkx
    $enemy[$x][3]=$checky
    _doittoo()
    ContinueLoop
    EndIf
    EndIf
    $checkx=$enemy[$x][2]
    $checky=$enemy[$x][3]-1
    If $checky>=0 And ($enemy[$x][6]<>$checkx Or $enemy[$x][7]<>$checky) Then
    If $checkx>=20 Then ContinueLoop
    If $map[$checkx][$checky]=1 Or $map[$checkx][$checky]=2 Then
    $enemy[$x][6]=$enemy[$x][2]
    $enemy[$x][7]=$enemy[$x][3]
    $enemy[$x][2]=$checkx
    $enemy[$x][3]=$checky
    _doittoo()
    ContinueLoop
    EndIf
    EndIf
    $checkx=$enemy[$x][2]+1
    $checky=$enemy[$x][3]
    If $checkx<=19 And ($enemy[$x][6]<>$checkx Or $enemy[$x][7]<>$checky) Then
    If $map[$checkx][$checky]=1 Or $map[$checkx][$checky]=2 Then
    $enemy[$x][6]=$enemy[$x][2]
    $enemy[$x][7]=$enemy[$x][3]
    $enemy[$x][2]=$checkx
    $enemy[$x][3]=$checky
    _doittoo()
    ContinueLoop
    EndIf
    EndIf
    $checkx=$enemy[$x][2]
    $checky=$enemy[$x][3]+1
    If $checky<=15 And ($enemy[$x][6]<>$checkx Or $enemy[$x][7]<>$checky) Then
    If $map[$checkx][$checky]=1 Or $map[$checkx][$checky]=2 Then
    $enemy[$x][6]=$enemy[$x][2]
    $enemy[$x][7]=$enemy[$x][3]
    $enemy[$x][2]=$checkx
    $enemy[$x][3]=$checky
    _doittoo()
    ContinueLoop
    EndIf
    EndIf
    EndIf
    Next
    $enewinkel+=1
    If $enewinkel>=360 Then $enewinkel=0
    $factor=$normene[$nowene][0]/20
    For $x=0 To $enein-1
    _DrawTurned($backgra,$imgene[$nowene],$enewinkel,$enemy[$x][0],$enemy[$x][1])
    _GDIPlus_GraphicsFillRect($backgra,$enemy[$x][0],$enemy[$x][1],Round($enemy[$x][4]/$factor,0),2,_setbrush("0xFFAAAA00"))
    Next
    ;Endusw
    ;#unten
    _GDIPlus_GraphicsDrawImageRect($backgra,$infobg,0,$gy,$winx,$winy-$gy)
    _DrawString($backgra,"Level: "&Int($level),16,$gy+18,_setbrush("0xFFFFFFFF"))
    _DrawString($backgra,"Geld: "&Int($money)&"€",16,$gy+18+14,_setbrush("0xFFFFFF00"))
    _DrawString($backgra,"Leben: "&Int($lifes),16,$gy+18+14*2,_setbrush("0xFF00AA00"))
    _DrawString($backgra,"Score: "&Int($score),16,$gy+18+14*3,_setbrush("0xFFDD0000"))
    _GDIPlus_GraphicsDrawImageRect($backgra,$imgturm[$info],155,330,40,40)
    _DrawString($backgra,"Stärke: "&Int($turmnorm[$info][1]),200,330,_setbrush("0xFF00BB00"))
    _DrawString($backgra,"Ladezeit: "&Int($turmnorm[$info][2]),200,345,_setbrush("0xFFFFFF00"))
    _DrawString($backgra,"Reichweite: "&Int($turmnorm[$info][0]),200,360,_setbrush("0xFF0000FF"))
    _DrawString($backgra,"Kosten: "&Int($turmkosten[$info])&"€",200,375,_setbrush("0xFFFF0000"))
    _DrawString($backgra,$enemyname[$nowene],310,326,_setbrush("0xFFFFFFFF"))
    _DrawString($backgra,"Schutz: "&Int($normene[$nowene][0]),320,337,_setbrush("0xFFDD0000"))
    _DrawString($backgra,"Speed: "&$normene[$nowene][1],320,347,_setbrush("0xFF0000DD"))
    _DrawString($backgra,"Lohn: "&Int($normene[$nowene][2])&"€",320,357,_setbrush("0xFF00AA00"))
    _GDIPlus_GraphicsDrawLine($backgra,310,373,395,373,$pen)
    _DrawString($backgra,$enemyname[$nextene],310,375,_setbrush("0xFFFFFFFF"))
    ;zusammenstellen
    _GDIPlus_GraphicsFillRect($backgra,$gx-60,$gy-20,60,20,_setbrush("0x"&Hex($sendalpha,2)&"FF8811"))
    _DrawString($backgra,"Schicken",$gx-55,$gy-15,_setbrush("0x"&Hex($sendalpha,2)&"FFFFFF"))
    _DrawTonAnAus($fxalpha,$malpha)
    _GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$winx,$winy)
    ;Prozessor
    Sleep(10)
    WEnd
    _exit()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Ende
    Func _exit()
    AdlibUnRegister()
    For $x=0 To UBound($imgturm,1)-1
    _GDIPlus_ImageDispose($imgturm[$x])
    Next
    For $x=0 To UBound($imgene,1)-1
    _GDIPlus_ImageDispose($imgene[$x])
    Next
    _SoundClose($menubg)
    For $x=0 To UBound($shotsound,1)-1
    _SoundClose($shotsound[$x])
    Next
    _SoundClose($cardead)
    _DSEnd()
    _GDIPlus_ImageDispose($infobg)
    _GDIPlus_ImageDispose($street)
    _GDIPlus_ImageDispose($street2)
    _GDIPlus_ImageDispose($field)
    _GDIPlus_PenDispose($pen)
    _GDIPlus_BrushDispose($brush)
    _GDIPlus_GraphicsDispose($backgra)
    _GDIPlus_BitmapDispose($buffer)
    _GDIPlus_GraphicsDispose($gra)
    _GDIPlus_Shutdown()
    GUIDelete($gui)
    DllClose($user32)
    Exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;Funktionen
    Func _DSStart($face="Arial",$size=12,$style=0) ;Um auch Brush angeben zu können
    Local $family=_GDIPlus_FontFamilyCreate($face)
    $font=_GDIPlus_FontCreate($family,$size,$style)
    _GDIPlus_FontFamilyDispose($family)
    $format=_GDIPlus_StringFormatCreate()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawString($gra,$str,$x=0,$y=0,$brush=0)
    Local $layout=_GDIPlus_RectFCreate($x,$y)
    _GDIPlus_GraphicsDrawStringEx($gra,$str,$font,$layout,$format,$brush)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DSEnd()
    _GDIPlus_FontDispose($font)
    _GDIPlus_StringFormatDispose($format)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawStr($gra,$str,$x=0,$y=0,$brush=0,$size=12,$flag=0,$face="Arial") ;Wenn man es nicht schnell braucht und nur 1 Befehl haben will
    Local $family=_GDIPlus_FontFamilyCreate($face)
    Local $font=_GDIPlus_FontCreate($family,$size,$flag)
    _GDIPlus_FontFamilyDispose($family)
    Local $format=_GDIPlus_StringFormatCreate()
    Local $layout=_GDIPlus_RectFCreate($x,$y)
    _GDIPlus_GraphicsDrawStringEx($gra,$str,$font,$layout,$format,$brush)
    _GDIPlus_FontDispose($font)
    _GDIPlus_StringFormatDispose($format)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _setbrush($color)
    _GDIPlus_BrushSetSolidColor($brush,$color)
    Return $brush
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _createmap()
    Local $tmp[16],$x,$y,$split
    $tmp[0]= "0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
    $tmp[1]= "1,1,1,1,1,1,0,1,1,1,2,0,0,0,0,0,0,0,0,0"
    $tmp[2]= "0,0,0,0,0,2,0,2,0,0,2,0,0,0,0,0,0,0,0,0"
    $tmp[3]= "0,0,0,0,0,2,1,1,0,0,2,0,0,0,0,2,1,1,1,1"
    $tmp[4]= "0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0"
    $tmp[5]= "0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2,0,0,0,0"
    $tmp[6]= "0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,2,0,0,0,0"
    $tmp[7]= "0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0"
    $tmp[8]= "0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,2,0,0,0,0"
    $tmp[9]= "0,0,0,0,1,1,2,0,0,0,0,0,0,0,0,2,0,0,0,0"
    $tmp[10]="0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0"
    $tmp[11]="0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,1,0,0,0,0"
    $tmp[12]="0,0,0,0,2,1,0,0,0,0,0,0,0,2,1,0,0,0,0,0"
    $tmp[13]="0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0"
    $tmp[14]="0,0,0,0,0,2,1,1,1,1,1,1,1,1,0,0,0,0,0,0"
    $tmp[15]="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
    For $y=0 to 15
    $split=StringSplit($tmp[$y],",")
    For $x=0 To 19
    $map[$x][$y]=$split[$x+1]
    Next
    Next
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _plattform($backgra,$x,$y,$w,$h,$color)
    _GDIPlus_GraphicsFillRect($backgra,$x,$y,$w,$h,_setbrush($color))
    Local $cd=_dunkler($color,50)
    _setbrush($cd)
    _GDIPlus_GraphicsFillRect($backgra,$x,$y,$w,2,$brush)
    _GDIPlus_GraphicsFillRect($backgra,$x+$w-2,$y,2,$h,$brush)
    _GDIPlus_GraphicsFillRect($backgra,$x,$y,2,$h,$brush)
    _GDIPlus_GraphicsFillRect($backgra,$x,$y+$h-2,$w,2,$brush)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _dunkler($color,$um=25)
    $r=Int(Dec(StringMid($color,5,2)))-$um
    $g=Int(Dec(StringMid($color,7,2)))-$um
    $b=Int(Dec(StringMid($color,9,2)))-$um
    If $r>255 Then $r=255
    If $r<0 Then $r=0
    If $g>255 Then $g=255
    If $g<0 Then $g=0
    If $b>255 Then $b=255
    If $b<0 Then $b=0
    Return ("0x"&StringMid($color,3,2)&Hex($r,2)&Hex($g,2)&Hex($b,2))
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawTurned($backgra,$img,$winkel,$x,$y,$w=20,$h=20)
    If $img=0 Then Return 0
    Local $matrix=_GDIPlus_MatrixCreate()
    _GDIPlus_MatrixTranslate($matrix,$x+$w/2,$y+$h/2)
    _GDIPlus_MatrixRotate($matrix,$winkel)
    _GDIPlus_GraphicsSetTransform($backgra,$matrix)
    _GDIPlus_GraphicsDrawImageRect($backgra,$img,-$w/2,-$h/2,$w,$h)
    _GDIPlus_MatrixRotate($matrix,-$winkel)
    _GDIPlus_MatrixTranslate($matrix,-$x-$w/2,-$y-$h/2)
    _GDIPlus_GraphicsSetTransform($backgra,$matrix)
    _GDIPlus_MatrixDispose($matrix)
    Return 1
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _AngelFromPoints($mx,$my,$px,$py);Mittelpunkt des Kreises und Punkt auf Kreis
    If $mx=$px And $my=$py Then Return 0
    Local $angel=Round(ATan2($py-$my,$px-$mx)*180/ACos(-1),0)+90
    If $px<$mx Then
    $angel+=180
    EndIf
    If $my>$py And $px=$mx Then $angel-=180
    Return $angel
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func ATan2($x,$y)
    If $x=0 Then Return 0
    If $y=0 Then Return 1.5707963267949
    Return ATan($x/$y)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _G_Start()
    $money=100
    $normene[0][0]=20
    $normene[0][1]=1
    $normene[0][2]=3
    $normene[1][0]=15
    $normene[1][1]=2
    $normene[1][2]=2
    $normene[2][0]=30
    $normene[2][1]=0.6
    $normene[2][2]=4
    if $soundon Then _SoundPlay($menubg)
    _createmap()
    $score=0
    $level=1
    $lifes=20
    $nextene=Random(0,2,1)
    $enein=0
    $enemysin=0
    $enewinkel=0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _DrawTonAnAus($alpha=255,$alpha2=255)
    _GDIPlus_GraphicsFillRect($backgra,360,0,20,20,_setbrush("0x"&Hex($alpha,2)&"DDDDDD"))
    Local $points[8][2]=[[7,0],[361,10],[363,15],[373,15],[379,19],[379,1],[373,5],[363,5]]
    _GDIPlus_GraphicsFillPolygon($backgra,$points,_setbrush("0x"&Hex($alpha,2)&"0000FF"))
    _DrawStr($backgra,"FX",364,4,_setbrush("0x"&Hex($alpha,2)&"FFFF11"),8,1)
    Local $pen=_GDIPlus_PenCreate("0x"&Hex($alpha,2)&"FF0000",2)
    If $fxon=0 Then
    _GDIPlus_GraphicsDrawLine($backgra,360,0,380,20,$pen)
    _GDIPlus_GraphicsDrawLine($backgra,360,20,380,0,$pen)
    EndIf
    _GDIPlus_PenSetColor($pen,"0x"&Hex($alpha2,2)&"FF0000")
    _GDIPlus_GraphicsFillRect($backgra,380,0,20,20,_setbrush("0x"&Hex($alpha2,2)&"DDDDDD"))
    Local $points[8][2]=[[7,0],[381,10],[383,15],[393,15],[399,19],[399,1],[393,5],[383,5]]
    _GDIPlus_GraphicsFillPolygon($backgra,$points,_setbrush("0x"&Hex($alpha2,2)&"0000FF"))
    _DrawStr($backgra,"MX",382,4,_setbrush("0x"&Hex($alpha2,2)&"FFFF11"),8,1)
    If $soundon=0 Then
    _GDIPlus_GraphicsDrawLine($backgra,380,0,400,20,$pen)
    _GDIPlus_GraphicsDrawLine($backgra,380,20,400,0,$pen)
    EndIf
    _GDIPlus_PenDispose($pen)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _change(ByRef $var)
    If $var=0 Then
    $var=1
    Else
    $var=0
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _G_over()
    AdlibUnRegister("sendin")
    _SoundStop($menubg)
    Local $bmp=_GDIPlus_BitmapCloneArea($buffer,0,0,$winx,$winy)
    Local $linbrush=_GDIPlus_BrushCreateLinear(0,0,$winx,$winy,"0xFFFF0000","0xFFFFFF00")
    Local $linbrush2=_GDIPlus_BrushCreateLinear(0,250,200,300,"0xFF00AA00","0xFFAAFF00")
    Local $pos[2]
    Local $nowbutton=0
    While 1
    $mps=_WinAPI_GetMousePos(True,$gui)
    $pos[0]=DllStructGetData($mps,"X")
    $pos[1]=DllStructGetData($mps,"Y")
    If $pos[1]>=270 And $pos[1]<=310 And WinActive($gui)<>0 Then
    If $pos[0]>=30 And $pos[0]<=165 Then
    $nowbutton=1
    If _IsPressed("1",$user32) Then
    ExitLoop
    EndIf
    ElseIf $pos[0]>=205 And $pos[0]<=350 Then
    $nowbutton=2
    If _IsPressed("1",$user32) Then
    _GDIPlus_BrushDispose($linbrush)
    _GDIPlus_BrushDispose($linbrush2)
    _GDIPlus_BitmapDispose($bmp)
    _exit()
    EndIf
    Else
    $nowbutton=0
    EndIf
    Else
    $nowbutton=0
    EndIf
    _GDIPlus_GraphicsDrawImageRect($backgra,$bmp,0,0,$winx,$winy)
    _GDIPlus_GraphicsFillRect($backgra,0,0,$winx,$winy,_setbrush("0xAAFFFFFF"))
    _DrawStr($backgra,"Game",-10,0,$linbrush,100)
    _DrawStr($backgra,"over",50,100,$linbrush,100)
    If $nowbutton=1 Then _GDIPlus_GraphicsFillRect($backgra,30,270,135,40,_setbrush("0xFF2222FF"))
    If $nowbutton=2 Then _GDIPlus_GraphicsFillRect($backgra,205,270,145,40,_setbrush("0xFF2222FF"))
    _DrawStr($backgra,"Nochmal",30,270,$linbrush2,25)
    _DrawStr($backgra,"Schließen",200,270,$linbrush2,25)
    _GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$winx,$winy)
    Sleep(10)
    WEnd
    _GDIPlus_BrushDispose($linbrush)
    _GDIPlus_BrushDispose($linbrush2)
    _GDIPlus_BitmapDispose($bmp)
    _G_Start()
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _GDIPlus_BrushCreateLinear($iX1, $iY1, $iX2, $iY2, $iARGB1 = 0xFF000000, $iARGB2 = 0xFFFFFFFF)
    Local $aResult, $start, $end, $sPoint, $ePoint

    [/autoit] [autoit][/autoit] [autoit]

    $start = DllStructCreate("int X;int Y")
    DllStructSetData($start, "X", $iX1)
    DllStructSetData($start, "Y", $iY1)
    $sPoint = DllStructGetPtr($start)

    [/autoit] [autoit][/autoit] [autoit]

    $end = DllStructCreate("int X;int Y")
    DllStructSetData($end, "X", $iX2)
    DllStructSetData($end, "Y", $iY2)
    $ePoint = DllStructGetPtr($end)

    [/autoit] [autoit][/autoit] [autoit]

    $aResult = DllCall($ghGDIPDll, "int", "GdipCreateLineBrushI", "ptr", $sPoint, "ptr", $ePoint, "int", $iARGB1, "int", $iARGB2, "int", 0, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)

    [/autoit] [autoit][/autoit] [autoit]

    Return SetError(0, $aResult[0], $aResult[6])
    EndFunc ;==>_GDIPlus_BrushCreateLinear

    [/autoit] [autoit][/autoit] [autoit]

    Func sendin()
    $enein+=1
    If $enein>$enemys Then
    $enein-=1
    AdlibUnRegister("sendin")
    Return
    EndIf
    $enemy[$enein-1][0]=-20
    $enemy[$enein-1][1]=20
    $enemy[$enein-1][2]=0
    $enemy[$enein-1][3]=1
    $enemy[$enein-1][4]=$normene[$nowene][0]
    $enemy[$enein-1][5]=$normene[$nowene][1]
    $enemy[$enein-1][6]=0
    $enemy[$enein-1][7]=0
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _doittoo()
    If $enemy[$x][2]*20>Round($enemy[$x][0],0) Then
    $enemy[$x][0]+=$enemy[$x][5]
    ElseIf $enemy[$x][2]*20<Round($enemy[$x][0],0) Then
    $enemy[$x][0]-=$enemy[$x][5]
    ElseIf $enemy[$x][3]*20<Round($enemy[$x][1],0) Then
    $enemy[$x][1]-=$enemy[$x][5]
    ElseIf $enemy[$x][3]*20>Round($enemy[$x][1],0) Then
    $enemy[$x][1]+=$enemy[$x][5]
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _dotower($xx,$yy)
    Local $tower=$map[$xx][$yy]-3
    Local $range=$turm[$xx][$yy][0]
    Local $ex,$ey,$getx,$found=0
    For $x=0 To $enein-1
    $ex=$enemy[$x][2]
    $ey=$enemy[$x][3]
    If Abs($xx-$ex)<=$range And Abs($yy-$ey)<=$range Then
    $getx=$x
    $found=1
    ExitLoop
    EndIf
    Next
    If $found=1 Then
    $turm[$xx][$yy][4]=_AngelFromPoints($xx*20+10,$yy*20+10,$enemy[$getx][0]+10,$enemy[$getx][1]+10)
    If TimerDiff($timer)>=$turm[$xx][$yy][3]+$turm[$xx][$yy][2] Then
    $enemy[$getx][4]-=$turm[$xx][$yy][1]
    If $fxon Then _SoundPlay($shotsound[$tower])
    If $enemy[$getx][4]<=0 Then
    $enein-=1
    $score+=1
    $enemys-=1
    $money+=$normene[$nowene][2]
    If $fxon Then _SoundPlay($cardead)
    If $enein<=0 Then
    $enemysin=0
    $enewinkel=0
    $level+=1
    _levelup()
    EndIf
    For $y=$getx To $enein-1
    For $z=0 To $enemyinfos-1
    $enemy[$y][$z]=$enemy[$y+1][$z]
    Next
    Next
    EndIf
    $turm[$xx][$yy][3]=TimerDiff($timer)
    EndIf
    EndIf
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _levelup()
    For $x=0 To 2
    $normene[$x][0]*=1.2;health
    $normene[$x][2]*=1.2;money
    Next
    EndFunc

    [/autoit]

    Komplett im Anhang.
    Hoffe dass es euch gefällt und freue mich über Kritik, Anregungen und alle anderen Antworten ;)


    EDIT:
    Kosteninfo vergessen, so jetzt drin ;) [DL6]

  • Seeehr cremig! :rock:
    Habe als alter Towerdefenser folgende Zeile geändert, um den Schwierigkeitsgrad etwas hochzusetzen

    [autoit]

    Global $turmnorm[3][3]=[[2,3,800],[4,2,500],[5,1,200]] ;range,power,load

    [/autoit]

    ciao
    Andy


    "Schlechtes Benehmen halten die Leute doch nur deswegen für eine Art Vorrecht, weil keiner ihnen aufs Maul haut." Klaus Kinski
    "Hint: Write comments after each line. So you can (better) see what your program does and what it not does. And we can see what you're thinking what your program does and we can point to the missunderstandings." A-Jay

    Wie man Fragen richtig stellt... Tutorial: Wie man Script-Fehler findet und beseitigt...X-Y-Problem

    2 Mal editiert, zuletzt von Andy (21. Mai 2010 um 10:53)

  • Danke, das "perfekt" einstellen habe ich jetzt nicht gemacht, ich wollte nicht mehr testen.
    Aber die Feinstimmung müsste eindeutig noch besser werden, mann kann undendlich spielen, wenn man die Mitte erledigt hat

  • So, ich finde es ri chtig cool, und zocke es auch O.o

    Aber später hat man ja genug kohle die höheren zu kaufen !

    Die anfänglichen sind aber noch da, vielleicht kannst du ja löschen einfügen, und man bekommt 50 % dessen was man gezahlt hat wiedeer !!!

    Das wäre gut wenn man später nur noch high türme hat !

    Es gibt sehr viele Leute, die glauben. Aber aus Aberglauben.
    - Blaise Pascal