Guten Abend,
ich möchte hier die Beta Version meines Tower Defence Spiel vorstellen. Als Grafikschnittstelle habe ich die A2D.ufd genutzt, da mir Gdiplus zu langsam ist. Die Steuerung: Mit den Tasten 1 bis 5 kann man den Turm auswählen. Ist ein Turm gebaut kann man ihn anklicken und updaten oder löschen.
Also hier ist dann noch das Script:
Spoiler anzeigen
#include <GuiConstants.au3>
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#include <Misc.au3>
#include <Array.au3>
#include <Timers.au3>
#include <gebaeude.au3>
#include <OpenGLconstants.au3>
#include <OpenGLfunctions.au3>
#include <A-Stern.au3>
Opt('MustDeclareVars', 1)
Opt('GuiOnEventMode', 1)
Opt('MouseCoordMode', 0)
Global Const $width = 640, $height = 480
;Global Const $width = @DesktopWidth, $height = @DesktopHeight
Global Const $felder_x = 16, $felder_y = 12
Global Const $feld_x = $width / $felder_x, $feld_y = $height / $felder_y
Global Const $feld_scale_x = 2 / $felder_x, $feld_scale_y = 2 / $felder_y
Global $KeyboardState
Global $Rotation
Global $Startpunkt[2] = [0,0]
Global $Zielpunkt[2] = [15,11]
Global $Hindernisse[$felder_x][$felder_y]
Global $Weg_Punkte, $Weg_Punkte_Backup
Global $Geld = 1000
Global $Leben = 20
Global $next_round
[/autoit] [autoit][/autoit] [autoit]Global $Bot[1]
Global $Bot_Pos[1][2]
Global $Bot_Move[1][2]
Global $Bot_Wegpunkt[1]
Global $Bot_Leben[1]
Global $Bot_Speed[1][2]
Global $Bot_Gift[1][2]
Global $Bot_Particle_type[1]
Global $Bots_Next
Global $Bots_Anzahl = 5
Global $Bots_Alive = 5
Global $Bots_Wave
Global Const $Gebaeude_Name[5] = ["Gun","Gift","Speed","Freeze","Dawn"]
Global Const $Gebaeude_Kosten[5][3] = [[10,20,40],[15,40,100],[20,50,150],[25,75,180],[50,100,250]]
Global Const $Gebaeude_Damage[5][3] = [[5,15,40],[1,2,10],[5,20,50],[1,2,10],[30,80,200]]
Global Const $Gebaeude_Reichweite[5][3] = [[10,20,40],[10,15,25],[10,20,40],[10,15,25],[20,40,50]]
Global Const $Gebaeude_Feuerrate[5][3] = [[1,1,1.5],[1,1,1.5],[2,4,8],[0.5,0.5,1],[0.5,0.5,1]]
Global Const $Gebaeude_Freeze[5][3] = [[1,1,1],[1,1,1],[1,1,1],[0.5,0.25,0.125],[1,1,1]]
Global Const $Gebaeude_Gift[5][3] = [[0,0,0],[5,20,50],[0,0,0],[0,0,0],[0,0,0]]
Global Const $Gebaeude_Schuss_type[5] = [1,0,1,0,2]
Global $Gebaeude_Type[$felder_x][$felder_y]
Global $Gebaeude_Timer[$felder_x][$felder_y]
Global $Gebaeude_Update[$felder_x][$felder_y]
Global $schuss_array[1][7]
Global Const $type_strahl = 0, $type_points = 1, $type_lines = 2
Global $particle_array[1][6]
Global Const $type_spred = 0, $type_doublespred = 1, $type_spred_lines = 2, $type_doublespred_lines = 3
;DEV Varibales
[/autoit] [autoit][/autoit] [autoit]Global $schuss_timer
Global $string
Global $gebaeude_zu_bauen
Global $gebaeude_zu_bearbeiten
Global $marked_position[2]
Local $mouse_pos[2], $mouse_pos_a[2]
[/autoit] [autoit][/autoit] [autoit]Global $hGUI = GUICreate("Moe´s TD", $width, $height, -1, -1, $WS_POPUP);, $WS_EX_TOPMOST)
GUISetOnEvent($GUI_EVENT_CLOSE, "_beenden")
Global $hWnd = WinGetHandle("Moe´s TD")
;GUIRegisterMsg(0x020A, "_Mousewheel")
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit]Global $DC
EnableOpenGL($hGUI, $DC)
glMatrixMode($GL_PROJECTION)
;glEnable($GL_BLEND)
Global $ViewMaus
Global $ViewPoint_x = 0, $ViewPoint_y = 0
Global $ViewPort_x = 640, $ViewPort_y = 480
glViewport($ViewPoint_x, $ViewPoint_y, $ViewPort_x, $ViewPort_y)
[/autoit] [autoit][/autoit] [autoit];glGenTextures( 1, "texture" )
[/autoit] [autoit][/autoit] [autoit]Local $sxi = $feld_scale_x / 2
Local $syi = $feld_scale_y / 2
create_gebaeude()
_Next_Round()
; Schuss_add($vonx, $vony, $nachx, $nachy, $interval, $type)
; particle_add_effect($x, $y, $particle_anzahl, $size, $type)
$weg_punkte = weg($startpunkt[0], $startpunkt[1], $zielpunkt[0], $zielpunkt[1], $felder_x, $felder_y, $hindernisse, False)
[/autoit] [autoit][/autoit] [autoit]Global Const $frames = 25
[/autoit] [autoit][/autoit] [autoit]Local $c
[/autoit] [autoit][/autoit] [autoit]AdlibEnable("Main", $frames)
[/autoit] [autoit][/autoit] [autoit]While True
Sleep(1000)
WEnd
Func Main()
[/autoit] [autoit][/autoit] [autoit]$KeyboardState = _WinAPI_GetKeyboardState()
[/autoit] [autoit][/autoit] [autoit];View()
;glViewport($ViewPoint_x + $ViewPort_x / 4, $ViewPoint_y + $ViewPort_y / 4, $ViewPort_x, $ViewPort_y)
glClear(BitOR($GL_COLOR_BUFFER_BIT, $GL_DEPTH_BUFFER_BIT));
[/autoit] [autoit][/autoit] [autoit]If BitAND($KeyboardState[02], 0xF0) = 128 Then Sleep(1000) ;_ArrayDisplay($schuss_array)
If BitAND($KeyboardState[83], 0xF0) = 128 Then save_map()
If BitAND($KeyboardState[76], 0xF0) = 128 Then load_map()
If BitAND($KeyboardState[68], 0xF0) = 128 Then erease_map()
Bauen()
Bot()
Zeichnen()
Schieszen()
particle()
SwapBuffers($dc)
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func View()
[/autoit] [autoit][/autoit] [autoit]If BitAND($KeyboardState[1], 0xF0) = 128 Then
[/autoit] [autoit][/autoit] [autoit]If IsArray($ViewMaus) Then
[/autoit] [autoit][/autoit] [autoit]$ViewPoint_x += MouseGetPos(0) - $ViewMaus[0]
$ViewPoint_y -= MouseGetPos(1) - $ViewMaus[1]
EndIf
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]$ViewMaus = MouseGetPos()
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Bauen()
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To 4 Step 1
If BitAND($KeyboardState[49 + $i], 0xF0) = 128 Then
$gebaeude_zu_bauen = $i + 1
$gebaeude_zu_bearbeiten = False
EndIf
Next
$mouse_pos = _mouse_feld_pos()
[/autoit] [autoit][/autoit] [autoit]If BitAND($KeyboardState[1], 0xF0) = 128 And IsArray($mouse_pos) Then ; Wenn geklickt wurde und die Maus im Fenster ist
$gebaeude_zu_bearbeiten = True
$marked_position[0] = $mouse_pos[0]
$marked_position[1] = $mouse_pos[1]
EndIf
If $gebaeude_zu_bauen <> 0 And $gebaeude_zu_bearbeiten = True Then ; Wenn ein Gebäude gebaut werden soll #########################################################################
[/autoit] [autoit][/autoit] [autoit]If $Geld - $Gebaeude_Kosten[$gebaeude_zu_bauen - 1][0] >= 0 Then ; Wenn man genug Geld hat
[/autoit] [autoit][/autoit] [autoit]If $mouse_pos[0] <> $mouse_pos_a[0] Or $mouse_pos[1] <> $mouse_pos_a[1] Then
[/autoit] [autoit][/autoit] [autoit]If $hindernisse[$mouse_pos[0]][$mouse_pos[1]] = False Then ; Wenn kein Gebäude existiert
[/autoit] [autoit][/autoit] [autoit]If ($Startpunkt[0] <> $mouse_pos[0] Or $Startpunkt[1] <> $mouse_pos[1]) And ($Zielpunkt[0] <> $mouse_pos[0] Or $Zielpunkt[1] <> $mouse_pos[1]) Then ; Verhindert das Bauen auf dem Spawnpunkt
[/autoit] [autoit][/autoit] [autoit]$hindernisse[$mouse_pos[0]][$mouse_pos[1]] = True
$weg_punkte_backup = $weg_punkte
$weg_punkte = weg($startpunkt[0], $startpunkt[1], $zielpunkt[0], $zielpunkt[1], $felder_x, $felder_y, $hindernisse, False)
If Not IsArray($weg_punkte) Then ; Wenn das Gebäude die Bots blockiert
$weg_punkte = $weg_punkte_backup
$hindernisse[$mouse_pos[0]][$mouse_pos[1]] = False
Else ; Wenn das Gebäude gebaut werden kann
$Geld -= $Gebaeude_Kosten[$gebaeude_zu_bauen - 1][0]
;MsgBox(0,"",$gebaeude_zu_bauen)
$Gebaeude_Type[$mouse_pos[0]][$mouse_pos[1]] = $gebaeude_zu_bauen
$Gebaeude_Update[$mouse_pos[0]][$mouse_pos[1]] = 1
_Bot_Reset()
EndIf
$mouse_pos_a = $mouse_pos
EndIf
$mouse_pos_a[0] = -1
$mouse_pos_a[1] = -1
EndIf
EndIf
EndIf
$gebaeude_zu_bauen = 0
$gebaeude_zu_bearbeiten = False
ElseIf $gebaeude_zu_bearbeiten Then ; Wenn geupdatet oder gelöscht werden soll ###################################################################################################
[/autoit] [autoit][/autoit] [autoit]If $hindernisse[$marked_position[0]][$marked_position[1]] = True Then
If BitAND($KeyboardState[85], 0xF0) = 128 Then ; Wenn "u" gedrückt ist
If $Gebaeude_Update[$marked_position[0]][$marked_position[1]] < 3 Then
[/autoit] [autoit][/autoit] [autoit]If $Geld - $Gebaeude_Kosten[$Gebaeude_type[$marked_position[0]][$marked_position[1]] - 1][$Gebaeude_Update[$marked_position[0]][$marked_position[1]] - 1] > 0 Then
$Geld -= $Gebaeude_Kosten[$Gebaeude_type[$marked_position[0]][$marked_position[1]] - 1][$Gebaeude_Update[$marked_position[0]][$marked_position[1]] - 1]
$Gebaeude_Update[$marked_position[0]][$marked_position[1]] += 1
$gebaeude_zu_bearbeiten = False
EndIf
EndIf
ElseIf BitAND($KeyboardState[46], 0xF0) = 128 Then ; Wenn "del" gedrückt ist
[/autoit] [autoit][/autoit] [autoit]$hindernisse[$marked_position[0]][$marked_position[1]] = False
$Gebaeude_type[$marked_position[0]][$marked_position[1]] = 0
$Gebaeude_update[$marked_position[0]][$marked_position[1]] = 0
$weg_punkte = weg($startpunkt[0], $startpunkt[1], $zielpunkt[0], $zielpunkt[1], $felder_x, $felder_y, $hindernisse, False)
[/autoit] [autoit][/autoit] [autoit]$gebaeude_zu_bearbeiten = False
EndIf
EndIf
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Bots_Move()
[/autoit] [autoit][/autoit] [autoit]Local $a, $b, $c
[/autoit] [autoit][/autoit] [autoit];If IsArray($weg_punkte) Then
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To $Bots_Anzahl - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]If $Bots_Next >= $i Then ; Die Bots kommen nacheinander
[/autoit] [autoit][/autoit] [autoit]If $Bot_Wegpunkt[$i] > UBound($weg_punkte) - 1 Then ; Wenn der Weg neuberechnet wurde und der Bot keinen Wegpunkt mehr hat
$Bot_Wegpunkt[$i] = 0
ElseIf $Bot_Wegpunkt[$i] = UBound($weg_punkte) - 1 Then ; Wenn ein Bot das Ziel erreicht hat
If $Bot_Leben[$i] > 0 Then ; Wenn der Bot noch lebt
$Bot_Leben[$i] = 0
$Bots_Alive -= 1
$Leben -= 1
EndIf
EndIf
If $Bot_Speed[$i][0] > _Punkte_Distance($Bot_Pos[$i][0] / 10, $Bot_Pos[$i][1] / 10, $weg_punkte[$Bot_Wegpunkt[$i]][0] - 0.5, $weg_punkte[$Bot_Wegpunkt[$i]][1] - 0.5) Then
[/autoit] [autoit][/autoit] [autoit]If $i = 0 And $Bot_Wegpunkt[$i] > 1 Then $Bots_Next += 1
[/autoit] [autoit][/autoit] [autoit]$Bot_Wegpunkt[$i] += 1
If $Bot_Wegpunkt[$i] > UBound($weg_punkte) - 1 Then ; Wenn der Bot schein Ziel erreicht hat
$Bot_Wegpunkt[$i] = 1
$Bot_Pos[$i][0] = $Zielpunkt[0] * 10
$Bot_Pos[$i][1] = $Zielpunkt[1] * 10
EndIf
$a = $weg_punkte[$Bot_Wegpunkt[$i]][0] * 10 - $Bot_Pos[$i][0]
$b = $weg_punkte[$Bot_Wegpunkt[$i]][1] * 10 - $Bot_Pos[$i][1]
$c = Sqrt($a * $a + $b * $b)
$Bot_Move[$i][0] = ($a * $Bot_Speed[$i][0]) / $c
$Bot_Move[$i][1] = ($b * $Bot_Speed[$i][0]) / $c
EndIf
EndIf
;ToolTip("Bot Posiotion: " & $Bot_pos[$i][0] & " & " & $Bot_pos[$i][1] & @LF & $a & " & " & $b & " & " & $c & @LF & "Bot Move: " & $Bot_Move[$i][0] & " & " & $Bot_Move[$i][1] & @LF & "Zielpunkt: " & $weg_punkte[$Bot_Wegpunkt[$i]][0] * 10 & " & " & $weg_punkte[$Bot_Wegpunkt[$i]][1] * 10)
$Bot_Pos[$i][0] += $Bot_Move[$i][0]
$Bot_Pos[$i][1] += $Bot_Move[$i][1]
Next
[/autoit] [autoit][/autoit] [autoit];EndIf
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Bot()
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To $Bots_Anzahl - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]If $Bot_Speed[$i][1] <> 0 Then
$Bot_Speed[$i][1] -= 1
If $Bot_Speed[$i][1] = 0 Then $Bot_Speed[$i][0] = 1 + $Bots_Wave * 0.005
EndIf
If $Bot_Gift[$i][1] <> 0 Then
$Bot_Gift[$i][1] -= 1
If $Bot_Gift[$i][1] = 0 Then $Bot_Gift[$i][0] = 0
$Bot_Leben[$i] -= $Bot_Gift[$i][0]
EndIf
Next
[/autoit] [autoit][/autoit] [autoit]If $Bots_Alive > 0 Then
Bots_Move()
Tuerme_schieszen()
$next_round = _Timer_Init()
ElseIf _Timer_Diff($next_round) > 3000 Then
_Next_Round()
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Bot_Reset()
[/autoit] [autoit][/autoit] [autoit]$Bots_Next = 0
$Bots_Alive = $Bots_Anzahl
For $i = 0 To $Bots_Anzahl - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]$Bot_Wegpunkt[$i] = 0
$Bot_Pos[$i][0] = $zielpunkt[0] * 10
$Bot_Pos[$i][1] = $zielpunkt[1] * 10
$Bot_Move[$i][0] = 0
$Bot_Move[$i][1] = 0
$Bot_Leben[$i] = 10 + $Bots_Wave * 5
$Bot_Speed[$i][0] = 1 + $Bots_Wave * 0.005
$Bot_Speed[$i][1] = 0
$Bot_Gift[$i][0] = 0
$Bot_Gift[$i][1] = 0
Next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Tuerme_schieszen()
[/autoit] [autoit][/autoit] [autoit]For $x = 0 To $felder_x - 1 Step 1
For $y = 0 To $felder_y - 1 Step 1
If $Hindernisse[$x][$y] Then
[/autoit] [autoit][/autoit] [autoit]$Gebaeude_Timer[$x][$y] += 1
If $Gebaeude_Timer[$x][$y] >= 20 / $Gebaeude_Feuerrate[$Gebaeude_Type[$x][$y] - 1][$Gebaeude_Update[$x][$y] - 1] Then
For $i = 0 To $Bots_Anzahl - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]If $Bot_Leben[$i] >= 0 Then
If _Punkte_Distance($Bot_Pos[$i][0], $Bot_Pos[$i][1], $x * 10, $y * 10) < $Gebaeude_Reichweite[$Gebaeude_Type[$x][$y] - 1][$Gebaeude_Update[$x][$y] - 1] Then
Schuss_add($x, $y, $Bot_Pos[$i][0] / 10, $Bot_Pos[$i][1] / 10, 100, $Gebaeude_Schuss_type[$Gebaeude_Type[$x][$y] - 1])
[/autoit] [autoit][/autoit] [autoit]$Bot_Leben[$i] -= $Gebaeude_Damage[$Gebaeude_Type[$x][$y] - 1][$Gebaeude_Update[$x][$y] - 1]
$Bot_Speed[$i][0] = $Gebaeude_Freeze[$Gebaeude_Type[$x][$y] - 1][$Gebaeude_Update[$x][$y] - 1]
$Bot_Speed[$i][1] = 20
$Bot_Gift[$i][0] = $Gebaeude_Gift[$Gebaeude_Type[$x][$y] - 1][$Gebaeude_Update[$x][$y] - 1]
$Bot_Gift[$i][1] = 20
If $Bot_Leben[$i] <= 0 Then
$Bots_Alive -= 1
particle_add_effect($Bot_Pos[$i][0] / 10, $Bot_Pos[$i][1] / 10, 10, 2, $Bot_Particle_type[$i])
EndIf
$Gebaeude_Timer[$x][$y] = 0
ExitLoop
EndIf
EndIf
Next
EndIf
EndIf
Next
Next
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Next_Round()
[/autoit] [autoit][/autoit] [autoit]Local $var = Random(0,2,1)
[/autoit] [autoit][/autoit] [autoit]$Bots_Next = 0
[/autoit] [autoit][/autoit] [autoit]$Bots_Wave += 1
[/autoit] [autoit][/autoit] [autoit]ReDim $Bot_Pos[$Bots_Anzahl][2]
ReDim $Bot_Move[$Bots_Anzahl][2]
ReDim $Bot_Wegpunkt[$Bots_Anzahl]
ReDim $Bot_Leben[$Bots_Anzahl]
ReDim $Bot_Speed[$Bots_Anzahl][2]
ReDim $Bot_Gift[$Bots_Anzahl][2]
ReDim $Bot_Particle_type[$Bots_Anzahl]
$Bots_Alive = $Bots_Anzahl
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To $Bots_Anzahl - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]$Bot_Particle_type[$i] = $var
$Bot_Wegpunkt[$i] = 0
$Bot_Pos[$i][0] = $zielpunkt[0] * 10
$Bot_Pos[$i][1] = $zielpunkt[1] * 10
$Bot_Move[$i][0] = 0
$Bot_Move[$i][1] = 0
$Bot_Leben[$i] = 10 + $Bots_Wave * 5
$Bot_Speed[$i][0] = 1 + $Bots_Wave * 0.005
$Bot_Speed[$i][1] = 0
$Bot_Gift[$i][0] = 0
$Bot_Gift[$i][1] = 0
Next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Zeichnen()
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To $felder_x - 1 Step 1
For $j = 0 To $felder_y - 1 Step 1
If $hindernisse[$i][$j] Then
Draw_Objekt($Obj_Turm[$Gebaeude_Type[$i][$j] - 1], $i ,$j) ; Zeichnet ein Objekt von entsprechendem Type
EndIf
Next
Next
;For $i = 0 To UBound($weg_punkte) - 1
;_GDIPlus_GraphicsDrawString($Buffer,$i,$weg_punkte[$i][0] * $feld_x,$weg_punkte[$i][1] * $feld_y)
;_GDIPlus_GraphicsDrawEllipse($Buffer,$weg_punkte[$i][0] * $feld_x,$weg_punkte[$i][1] * $feld_y,$feld_x,$feld_y)
;Next
For $i = 0 To $Bots_Anzahl - 1 Step 1; (50 - Felder / 2) / 100 * 2
If $Bot_Leben[$i] > 0 Then
Draw_Objekt(6, $Bot_pos[$i][0] / 10, $Bot_pos[$i][1] / 10)
EndIf
Next
For $i = 0 To UBound($weg_punkte) - 2 Step 1
line($weg_punkte[$i][0], $weg_punkte[$i][1], $weg_punkte[$i + 1][0], $weg_punkte[$i + 1][1], 255)
Next
If $gebaeude_zu_bearbeiten Then
Draw_Objekt(7, $marked_position[0], $marked_position[1])
Draw_Objekt(8, $marked_position[0], $marked_position[1])
EndIf
Draw_Objekt(1, $Startpunkt[0], $Startpunkt[1])
Draw_Objekt(1, $Zielpunkt[0], $Zielpunkt[1])
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Schuss_add($vonx, $vony, $nachx, $nachy, $interval, $type)
[/autoit] [autoit][/autoit] [autoit]Local $ubound = UBound($schuss_array)
[/autoit] [autoit][/autoit] [autoit]If IsArray($schuss_array) Then
ReDim $schuss_array[$ubound + 1][7]
Else
Dim $schuss_array[$ubound + 1][7]
EndIf
$schuss_array[$ubound][0] = $vonx
$schuss_array[$ubound][1] = $vony
$schuss_array[$ubound][2] = $nachx
$schuss_array[$ubound][3] = $nachy
$schuss_array[$ubound][4] = $interval
$schuss_array[$ubound][5] = $type
$schuss_array[$ubound][6] = 0
Return $ubound
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Schuss_delete($num)
_ArrayDelete($schuss_array, $num)
EndFunc
Func Schieszen()
[/autoit] [autoit][/autoit] [autoit]Local $a, $b ,$c ,$x, $y, $x2, $y2
Local $rate, $del_list[1]
Local $speed = 2
If UBound($schuss_array) >= 1 Then ReDim $del_list[UBound($schuss_array)]
[/autoit] [autoit][/autoit] [autoit]$schuss_timer += 1
If $schuss_timer > 100 Then $schuss_timer = 0
For $i = 0 To UBound($schuss_array) - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]Switch $schuss_array[$i][5] ; Type/Art des Schusses (Strahl,Punkte,Linien)
Case $type_strahl
line($schuss_array[$i][0],$schuss_array[$i][1],$schuss_array[$i][2],$schuss_array[$i][3],255)
$schuss_array[$i][6] += $speed
If $schuss_array[$i][6] >= 20 Then $del_list[$i] = True
Case $type_points
[/autoit] [autoit][/autoit] [autoit]$rate = $schuss_array[$i][4]
[/autoit] [autoit][/autoit] [autoit]$a = $schuss_array[$i][2] - $schuss_array[$i][0]
$b = $schuss_array[$i][3] - $schuss_array[$i][1]
$c = Sqrt($a * $a + $b * $b)
If $schuss_array[$i][6] < 0 Then
[/autoit] [autoit][/autoit] [autoit]For $j = 0 To -$schuss_array[$i][6] Step $rate
$x = -($a / $c) * ($j / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] ;1 Unit C ^= C/X auf X
$y = -($b / $c) * ($j / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] ;1 Unit C ^= C/Y auf Y
punkt($x,$y)
Next
Else
[/autoit] [autoit][/autoit] [autoit]For $j = 0 To -$schuss_array[$i][6] Step -$rate
$x = -($a / $c) * ($j / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] + $a ;1 Unit C ^= C/X auf X
$y = -($b / $c) * ($j / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] + $b ;1 Unit C ^= C/Y auf Y
punkt($x,$y)
Next
EndIf
[/autoit] [autoit][/autoit] [autoit]$schuss_array[$i][6] -= $speed
If $schuss_array[$i][6] <= -$c * 10 Then $schuss_array[$i][6] = $c * 10
If Int($schuss_array[$i][6]) = 0 Then $del_list[$i] = True
Case $type_lines
[/autoit] [autoit][/autoit] [autoit]$rate = $schuss_array[$i][4]
[/autoit] [autoit][/autoit] [autoit]$a = $schuss_array[$i][2] - $schuss_array[$i][0]
$b = $schuss_array[$i][3] - $schuss_array[$i][1]
$c = Sqrt($a * $a + $b * $b)
If $schuss_array[$i][6] < 0 Then
[/autoit] [autoit][/autoit] [autoit]For $j = 0 To -$schuss_array[$i][6] Step $rate
$x = -($a / $c) * ($j / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] ;1 Unit C ^= C/X auf X
$y = -($b / $c) * ($j / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] ;1 Unit C ^= C/Y auf Y
$x2 = -($a / $c) * (($j + 4) / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] ;1 Unit C ^= C/X auf X
$y2 = -($b / $c) * (($j + 4) / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] ;1 Unit C ^= C/Y auf Y
line($x,$y,$x2,$y2,255)
Next
Else
[/autoit] [autoit][/autoit] [autoit]For $j = 0 To -$schuss_array[$i][6] Step -$rate
$x = -($a / $c) * ($j / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] + $a ;1 Unit C ^= C/X auf X
$y = -($b / $c) * ($j / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] + $b ;1 Unit C ^= C/Y auf Y
$x2 = -($a / $c) * (($j + 4) / 10) + ($a / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][0] + $a ;1 Unit C ^= C/X auf X
$y2 = -($b / $c) * (($j + 4) / 10) + ($b / $c) * -$schuss_array[$i][6] / 10 + $schuss_array[$i][1] + $b ;1 Unit C ^= C/Y auf Y
line($x,$y,$x2,$y2,255)
Next
EndIf
[/autoit] [autoit][/autoit] [autoit]$schuss_array[$i][6] -= $speed
If $schuss_array[$i][6] <= -$c * 10 Then $schuss_array[$i][6] = $c * 10
If Int($schuss_array[$i][6]) = 0 Then $del_list[$i] = True
EndSwitch
Next
[/autoit] [autoit][/autoit] [autoit]Local $i = 0
[/autoit] [autoit][/autoit] [autoit]If IsArray($schuss_array) Then
[/autoit] [autoit][/autoit] [autoit]Do
[/autoit] [autoit][/autoit] [autoit]If $del_list[$i] Then Schuss_delete($i)
[/autoit] [autoit][/autoit] [autoit]$i += 1
[/autoit] [autoit][/autoit] [autoit]Until $i >= UBound($del_list) - 1
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func particle_add_effect($x, $y, $particle_anzahl, $size, $type)
[/autoit] [autoit][/autoit] [autoit]Local $ubound = UBound($particle_array)
[/autoit] [autoit][/autoit] [autoit]If IsArray($particle_array) Then
ReDim $particle_array[$ubound + 1][6]
Else
Dim $particle_array[$ubound + 1][6]
EndIf
$particle_array[$ubound][0] = $x
$particle_array[$ubound][1] = $y
$particle_array[$ubound][2] = $particle_anzahl
$particle_array[$ubound][3] = $size
$particle_array[$ubound][4] = $type
$particle_array[$ubound][5] = 0
Return $ubound
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func particle_delete_effect($num)
_ArrayDelete($particle_array, $num)
EndFunc
Func particle()
[/autoit] [autoit][/autoit] [autoit]Local $x, $y, $x2, $y2, $speed = 0.5, $distance = 2
[/autoit] [autoit][/autoit] [autoit]For $i = 0 To UBound($particle_array) - 1 Step 1
[/autoit] [autoit][/autoit] [autoit]Switch $particle_array[$i][4] ; Type/Art des Effektes
Case $type_spred
For $deg = 0 To 360 Step 360 / $particle_array[$i][2] ; So wird nur die Anzahl an Partikeln gezeichnet
[/autoit] [autoit][/autoit] [autoit]$x = Sin ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][0]
$y = Cos ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][1]
punkt($x,$y)
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]$particle_array[$i][5] += $speed
[/autoit] [autoit][/autoit] [autoit]Case $type_doublespred
[/autoit] [autoit][/autoit] [autoit]For $deg = 0 To 360 Step 360 / $particle_array[$i][2] ; So wird nur die Anzahl an Partikeln gezeichnet
[/autoit] [autoit][/autoit] [autoit]$x = Sin ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][0]
$y = Cos ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][1]
punkt($x,$y)
[/autoit] [autoit][/autoit] [autoit]$x = Sin (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][0]
$y = Cos (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][1]
punkt($x,$y)
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]$particle_array[$i][5] += $speed
[/autoit] [autoit][/autoit] [autoit]Case $type_spred_lines
[/autoit] [autoit][/autoit] [autoit]For $deg = 0 To 360 Step 360 / $particle_array[$i][2] ; So wird nur die Anzahl an Partikeln gezeichnet
[/autoit] [autoit][/autoit] [autoit]$x = Sin ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][0]
$y = Cos ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][1]
$x2 = Sin ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][0]
$y2 = Cos ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][1]
line($x,$y,$x2,$y2, 255 - ($particle_array[$i][5] / 10) / $particle_array[$i][3] * 255)
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]$particle_array[$i][5] += $speed
[/autoit] [autoit][/autoit] [autoit]Case $type_doublespred_lines
[/autoit] [autoit][/autoit] [autoit]For $deg = 0 To 360 Step 360 / $particle_array[$i][2] ; So wird nur die Anzahl an Partikeln gezeichnet
[/autoit] [autoit][/autoit] [autoit]$x = Sin ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][0]
$y = Cos ($deg * $pi_div_180) * ($particle_array[$i][5]) / 10 + $particle_array[$i][1]
$x2 = Sin ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][0]
$y2 = Cos ($deg * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][1]
line($x,$y,$x2,$y2, 255 - ($particle_array[$i][5] / 10) / $particle_array[$i][3] * 255)
[/autoit] [autoit][/autoit] [autoit]$x = Sin (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][0]
$y = Cos (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance) / 10 + $particle_array[$i][1]
$x2 = Sin (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance * 2) / 10 + $particle_array[$i][0]
$y2 = Cos (($deg + 360 / $particle_array[$i][2] / 2) * $pi_div_180) * ($particle_array[$i][5] - $distance * 2) / 10 + $particle_array[$i][1]
line($x,$y,$x2,$y2, 255 - ($particle_array[$i][5] / 10) / $particle_array[$i][3] * 255)
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]$particle_array[$i][5] += $speed
[/autoit] [autoit][/autoit] [autoit]EndSwitch
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]Local $i = 0
[/autoit] [autoit][/autoit] [autoit]If IsArray($particle_array) Then
[/autoit] [autoit][/autoit] [autoit]Do
[/autoit] [autoit][/autoit] [autoit]If $particle_array[$i][5] / 10 >= $particle_array[$i][3] Then
particle_delete_effect($i)
EndIf
$i += 1
[/autoit] [autoit][/autoit] [autoit]Until $i >= UBound($particle_array) - 1
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func line($x1,$y1,$x2,$y2,$alpha)
[/autoit] [autoit][/autoit] [autoit]glBlendFunc($GL_SRC_ALPHA, $GL_ONE)
glBegin($GL_LINE_STRIP)
If $alpha = 255 Then
glColor3f(0.2, 0.2, 1.0)
Else
glColor4f(0.2, 0.2, 1.0, $alpha);Random(0,255,1))
EndIf
glVertex2d(-(1 - $feld_scale_x * $x1 - $feld_scale_x / 2), (1 - $feld_scale_y * $y1 - $feld_scale_y / 2))
glVertex2d(-(1 - $feld_scale_x * $x2 - $feld_scale_x / 2), (1 - $feld_scale_y * $y2 - $feld_scale_y / 2))
glEnd()
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func punkt($x,$y)
[/autoit] [autoit][/autoit] [autoit]glBegin($GL_POINTS)
glColor3f(1, 1, 0)
glVertex2d(-(1 - $feld_scale_x * $x - $feld_scale_x / 2), (1 - $feld_scale_y * $y - $feld_scale_y / 2))
glEnd()
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Draw_Objekt($objekti, $xi, $yi)
[/autoit] [autoit][/autoit] [autoit]glPushMatrix()
gltranslatef(-(1 - $feld_scale_x * $xi - $feld_scale_x / 2), (1 - $feld_scale_y * $yi - $feld_scale_y / 2),0)
;glRotated($rotation, 0, 0, -1)
glCallList($objekti)
glPopMatrix()
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func Weg_neuberechnen()
[/autoit] [autoit][/autoit] [autoit];For $i = 0 To UBound($weg_punkte) - 1 Step 1
[/autoit] [autoit][/autoit] [autoit];If $weg_punkte[$i][0] = $mouse_pos[0] And $weg_punkte[$i][1] = $mouse_pos[1] Then
;$weg_punkte_backup = $weg_punkte
;$weg_punkte = weg($startpunkt[0], $startpunkt[1], $zielpunkt[0], $zielpunkt[1], $felder_x, $felder_y, $hindernisse, False)
;If Not IsArray($weg_punkte) Then
;$weg_punkte = $weg_punkte_backup
;$hindernisse[$mouse_pos[0]][$mouse_pos[1]] = False
;EndIf
;EndIf
;Next
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Mouse_feld_pos()
[/autoit] [autoit][/autoit] [autoit];ToolTip("Doing2")
[/autoit] [autoit][/autoit] [autoit]Local $pos[2]
[/autoit] [autoit][/autoit] [autoit]$pos[0] = Int(MouseGetPos(0) / $feld_x)
$pos[1] = Int(MouseGetPos(1) / $feld_y)
If $pos[0] >= 0 And $pos[1] >= 0 And $pos[0] < $felder_x And $pos[1] < $felder_y Then
Return $pos
Else
SetError(1)
Return 0
EndIf
EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _Punkte_Distance($x1, $y1, $x2, $y2) ;Pythagoras theorem
[/autoit] [autoit][/autoit] [autoit]Local $a, $b, $c
[/autoit] [autoit][/autoit] [autoit]If $x2 = $x1 And $y2 = $y1 Then
Return 0
Else
$a = $y2 - $y1
$b = $x2 - $x1
$c = Sqrt($a * $a + $b * $b)
Return $c
EndIf
EndFunc ;==>Pixel_Distance
Func _Mousewheel($hWnd, $msg, $l, $r)
[/autoit] [autoit][/autoit] [autoit]If $l = 0xFF880000 Then
$ViewPort_x += 20
$ViewPort_y += 20
ElseIf $l = 0x00780000 Then
$ViewPort_x -= 20
$ViewPort_y -= 20
EndIf
EndFunc ;==>_Mousewheel
[/autoit] [autoit][/autoit] [autoit]Func _WinAPI_GetKeyboardState($iFlag = 0)
Local $aDllRet, $lpKeyState = DllStructCreate("byte[256]")
$aDllRet = DllCall("User32.dll", "int", "GetKeyboardState", "ptr", DllStructGetPtr($lpKeyState))
If @error Then Return SetError(@error, 0, 0)
If $aDllRet[0] = 0 Then
Return SetError(1, 0, 0)
Else
Switch $iFlag
Case 0
Local $aReturn[256]
For $i = 1 To 256
$aReturn[$i - 1] = DllStructGetData($lpKeyState, 1, $i)
Next
Return $aReturn
Case Else
Return DllStructGetData($lpKeyState, 1)
EndSwitch
EndIf
EndFunc ;==>_WinAPI_GetKeyboardState
Func _Beenden()
[/autoit] [autoit][/autoit] [autoit];DllClose ($dll)
[/autoit] [autoit][/autoit] [autoit]Exit
EndFunc; ==> beenden und speicher wieder frei geben
Edit: NEUE BETA VERSION! 01.11.09 :
autoit.de/wcf/attachment/7134/
autoit.de/wcf/attachment/7135/
Veränderungen:
- Kleines Interface zum updaten und löschen der Gebäude
- Neue Anzeigen
- Mehr Texturen
- Pausen Funktion auf der Pause Taste
- Und kleine Veränderungen
Und hier noch nen bild:
[Blockierte Grafik: http://img229.imageshack.us/img229/9830/bsp2.th.jpg]