Jump to content

Tank Wars


Recommended Posts

Hm, I've done a shoot system into my Game and it works with the outer walls, that the shoots disappeart, jsut don't know why it don't works with the inner walls...

My second problem is, that the Game get sooo much slower after 3 shoots that is after 6 shots nearly unplayable anymore o.O... Any idea why?

And last but not least my third problem is, that you can't shoot 2 times at the same places... You first have to move the tan before you can do a second shot...

the game is attached, here is the code:

;Name: RobotWars.au3
;Author: Lord_Doominik
;Status: In Progress (15%)
;Version: 0

#include <GUIConstants.au3>
#include <Misc.au3>

$mainGUI = GUICreate("Robot Wars", 800, 625, (@DesktopWidth-800)/2, (@DesktopHeight-600)/2, $WS_MINIMIZEBOX + $WS_SYSMENU)

$Label = GUICtrlCreateLabel("Press Enter to Start", 0, (@DesktopHeight-200)/2, 800, -1, $SS_CENTER)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case _IsPressed("0D")
        ExitLoop
    EndSelect
WEnd

GUICtrlDelete($Label)
#include <Battle.au3>

Func About()
    GUICreate("Robot Wars - About", 351, 180,(@DesktopWidth-351)/2, (@DesktopHeight-180)/2, -1, -1, $mainGUI)
    
    $Logo = GUICtrlCreatePic("Logo.tfp", 20, 20, 320, 80)
    $VersionLabel = GUICtrlCreateLabel("Robot Wars V. 0", 20, 115, 320, 20)
    $Label = GUICtrlCreateLabel("Program made by Dominik Weinrich and Graphics made by Artus Krieger", 20, 130, 320, 20)
    $Label2 = GUICtrlCreateLabel("http://www.ourwebpage.de/", 20, 150, 320, 20)
    GUICtrlSetFont($Label2, 10, 800, 4)
    GUICtrlSetColor($Label2, 0x0000FF)
    GUICtrlSetCursor($Label2, 0)
    
    GUISetState()
    
    While 1
        $msg2 = GUIGetMsg()
        Select
        Case $msg2 = $Label2
    ;HP öffnen
        Case $msg2 = $GUI_EVENT_CLOSE
            ExitLoop
        EndSelect
    WEnd
    GUIDelete()
EndFunc

;Name: Battle.au3
;Author: Lord_Doominik
;Status: In Progress (5%)
;Version: 0

Dim $bullet1[10000]
Dim $ShootDir1[10000]
Dim $ShootPosX1[10000]
Dim $ShootPosY1[10000]

Dim $bullet2[10000]

$i = 0
$reloadtime = TimerInit()

$Arena = GUICtrlCreatePic("Battlefields/Arena1.map", 0, 0, 800, 600)
GUICtrlSetState(-1, $GUI_DISABLE)

$Roboter1 = GUICreate("Roboter1", 32, 32, 330, 175, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
$Roboter1Pic = GUICtrlCreatePic("Vehicles/Panzer1 N.gif", 0, 0, 32, 32)

GUISetState()

$Roboter2 = GUICreate("Roboter2", 11, 21, 203, 550, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
GUICtrlCreatePic("Vehicles/Roboter2.gif", 0, 0, 11, 21)

GUISetState()

ControlFocus("Robot Wars", "", $mainGUI)
While 1
    $bmsg = GUIGetMsg()
    Select
    Case $bmsg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
    
    $WinPos = WinGetPos("Robot Wars")
    
    Action()
    Shot()
WEnd

Func Action()
    $pos1 = WinGetPos("Roboter1")
    $x1 = 0
    $y1 = 0
    
    If _IsPressed("25") Then;Left
        If Hex(PixelGetColor($pos1[0]+4, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+4, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Roboter1Pic, "Vehicles/Panzer1 W.gif")
            $ShootDir1[$i+1] = "E"
            $x1 -= 1
        EndIf
    ElseIf _IsPressed("27") Then;Right
        If Hex(PixelGetColor($pos1[0]+27, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+27, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Roboter1Pic, "Vehicles/Panzer1 O.gif")
            $ShootDir1[$i+1] = "W"
            $x1 += 1
        EndIf
    ElseIf _IsPressed("26") Then;Up
        If Hex(PixelGetColor($pos1[0]+16, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+17, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+18, $pos1[1]-1), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+5, $pos1[1]+2), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+2), 6) <> "000000" Then
            GUICtrlSetImage ($Roboter1Pic, "Vehicles/Panzer1 N.gif")
            $ShootDir1[$i+1] = "N"
            $y1 -= 1
        EndIf
    ElseIf _IsPressed("28") Then;Down
        If Hex(PixelGetColor($pos1[0]+5, $pos1[1]+29), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+29), 6) <> "000000" Then
            GUICtrlSetImage($Roboter1Pic, "Vehicles/Panzer1 S.gif")
            $ShootDir1[$i+1] = "S"
            $y1 += 1
        EndIf
    EndIf

    If (_IsPressed("20")) And (TimerDiff($reloadtime) >= 1000) Then
        GUISwitch($mainGUI)
        $i += 1
        
        Switch $ShootDir1[$i]
        Case "N"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 24
        Case "S"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] + 11
        Case "E"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] - 7
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        Case "W"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 29
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        EndSwitch
        
        $bullet1[$i] = GUICtrlCreateLabel("", $ShootPosX1, $ShootPosY1, 3, 2)
        GUICtrlSetBkColor(-1, 0xFF0000)
        $reloadtime = TimerInit()
    EndIf
    
    ControlMove("Roboter1", "", $Roboter1, $pos1[0]+$x1, $pos1[1]+$y1)
EndFunc

Func Shot()
    For $j = 1 To $i
        Switch $ShootDir1[$j]
        Case "N"
            $ShootPosY1[$j] -= 2
        Case "S"
            $ShootPosY1[$j] += 2
        Case "E"
            $ShootPosX1[$j] -= 2
        Case "W"
            $ShootPosX1[$j] += 2
        EndSwitch
        
        If _CheckHitArenaWalls($ShootPosX1[$j], $ShootPosY1[$j], "Battlefields\Arena1") = 1 Then
            GUICtrlDelete($bullet1[$j])
            $bullet1[$j] = 0
        Else
            ControlMove("", "", $bullet1[$j], $ShootPosX1[$j], $ShootPosY1[$j])
        EndIf
    Next
EndFunc


Func _CheckHitArenaWalls($bullet_X, $bullet_Y, $arenaname)
    $number_of_blocks = IniRead($arenaname&".dat", "global", "number_of_blocks", 0)
    For $k = 1 to $number_of_blocks
        $arena_bottomwall_y = IniRead($arenaname&".dat", "block"&$k, "bottom", 0 )
        $arena_leftwall_x = IniRead($arenaname&".dat", "block"&$k, "left", 0 )
        $arena_rightwall_x = IniRead($arenaname&".dat", "block"&$k, "right", 0 )
        $arena_topwall_y = IniRead($arenaname&".dat", "block"&$k, "top", 0 )
        $arena_method = IniRead($arenaname&".dat", "block"&$k, "col_method", "in")
        If $arena_method = "out" Then
            If $bullet_X <= $arena_leftwall_x Or $bullet_X >= $arena_rightwall_x Or $bullet_Y <= $arena_topwall_y Or $bullet_Y >= $arena_bottomwall_y Then
                return 1
            EndIf
      ;ElseIf $arena_method = "in" Then
;   If $bullet_X >= $arena_leftwall_x Or $bullet_X <= $arena_rightwall_x Or $bullet_Y >= $arena_topwall_y Or $bullet_Y <= $arena_bottomwall_y Then
;       return 1
;   EndIf
        EndIf
    Next
    Return 0
EndFunc

Tank_Wars.rar

Edited by Lord_Doominik
Link to comment
Share on other sites

i tried to visually debug your game....

i notice three possibilities

1 these are huge to start with ( uses lots of memory )

Dim $bullet1[10000]Dim $ShootDir1[10000]

Dim $ShootPosX1[10000]

Dim $ShootPosY1[10000]

Dim $bullet2[10000]

i have NEVER used that large of numbers

**

2 the variable $i is NEVER reset to 0

is it possible to reset it at some point? because it just keeps growing

**

3 you might be able to lower the memory useage with...

AdlibEnable("_reducememory", 1000)

Func _ReduceMemory()
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
Return $ai_Return[0]
EndFunc

just ideas

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

i tried to visually debug your game....

i notice three possibilities

1 these are huge to start with ( uses lots of memory )

i have NEVER used that large of numbers

**

2 the variable $i is NEVER reset to 0

is it possible to reset it at some point? because it just keeps growing

**

3 you might be able to lower the memory useage with...

AdlibEnable("_reducememory", 1000)

Func _ReduceMemory()
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
Return $ai_Return[0]
EndFunc

just ideas

8)

hmmm

reduce memory should be helping a bit!

nice ideas ^^*

[font="Verdana"]In work:[list=1][*]InstallIt[*]New version of SpaceWar[/list] [/font]

Link to comment
Share on other sites

ye, nice ideas, i try to get the array slower and reset $i (#1 and #2 of your ideas) but it don't want to go... tryed it with this:

;Name: Battle.au3
;Author: Lord_Doominik
;Status: In Progress (5%)
;Version: 0

Dim $bullet1[10]
Dim $ShootDir1[10]
Dim $ShootPosX1[10]
Dim $ShootPosY1[10]

Dim $bullet2[10]

$i = 0
$l = 0
$reloadtime = TimerInit()

$Arena = GUICtrlCreatePic("Battlefields/Arena1.map", 0, 0, 800, 600)
GUICtrlSetState(-1, $GUI_DISABLE)

$Tank1 = GUICreate("Tank1", 32, 32, 330, 175, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
$Tank1Pic = GUICtrlCreatePic("Vehicles/Panzer1 N.gif", 0, 0, 32, 32)

GUISetState()

$Tank2 = GUICreate("Tank2", 11, 21, 203, 550, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
GUICtrlCreatePic("Vehicles/Roboter2.gif", 0, 0, 11, 21)

GUISetState()

ControlFocus("Tank Wars", "", $mainGUI)
While 1
    $bmsg = GUIGetMsg()
    Select
    Case $bmsg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
    
    $WinPos = WinGetPos("Tank Wars")
    
    Action()
    Shot()
WEnd

Func Action()
    $pos1 = WinGetPos("Tank1")
    $x1 = 0
    $y1 = 0
    
    If _IsPressed("25") Then;Left
        If Hex(PixelGetColor($pos1[0]+4, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+4, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 W.gif")
            $ShootDir1[$i] = "E"
            $x1 -= 1
        EndIf
    ElseIf _IsPressed("27") Then;Right
        If Hex(PixelGetColor($pos1[0]+27, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+27, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 O.gif")
            $ShootDir1[$i] = "W"
            $x1 += 1
        EndIf
    ElseIf _IsPressed("26") Then;Up
        If Hex(PixelGetColor($pos1[0]+16, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+17, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+18, $pos1[1]-1), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+5, $pos1[1]+2), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+2), 6) <> "000000" Then
            GUICtrlSetImage ($Tank1Pic, "Vehicles/Panzer1 N.gif")
            $ShootDir1[$i] = "N"
            $y1 -= 1
        EndIf
    ElseIf _IsPressed("28") Then;Down
        If Hex(PixelGetColor($pos1[0]+5, $pos1[1]+29), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+29), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 S.gif")
            $ShootDir1[$i] = "S"
            $y1 += 1
        EndIf
    EndIf

    If (_IsPressed("20")) And (TimerDiff($reloadtime) >= 1000) Then
        GUISwitch($mainGUI)
        
        Switch $ShootDir1[$i]
        Case "N"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 24
        Case "S"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] + 11
        Case "E"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] - 7
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        Case "W"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 29
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        EndSwitch
        
        $bullet1[$i] = GUICtrlCreateLabel("", $ShootPosX1, $ShootPosY1, 3, 2)
        GUICtrlSetBkColor(-1, 0xFF0000)
        $reloadtime = TimerInit()
        
        $i += 1
    EndIf
    
    ControlMove("Tank1", "", $Tank1, $pos1[0]+$x1, $pos1[1]+$y1)
EndFunc

Func Shot()
    For $j = 0 To $i-1
        Switch $ShootDir1[$j]
        Case "N"
            $ShootPosY1[$j] -= 2
        Case "S"
            $ShootPosY1[$j] += 2
        Case "E"
            $ShootPosX1[$j] -= 2
        Case "W"
            $ShootPosX1[$j] += 2
        EndSwitch
        
        If _CheckHitArenaWalls($ShootPosX1[$j], $ShootPosY1[$j], "Battlefields\Arena1") = 1 Then
            GUICtrlDelete($bullet1[$j])
            $bullet1[$j] = 0
            $ShootDir1[$j] = 0
            $ShootPosX1[$j] = 0
            $ShootPosY1[$j] = 0
            $l += 1
        Else
            ControlMove("", "", $bullet1[$j], $ShootPosX1[$j], $ShootPosY1[$j])
        EndIf
    Next
    
    If $i <> 0 And $l = $i Then
        $i = 0
        $l = 0
    EndIf
EndFunc


Func _CheckHitArenaWalls($bullet_X, $bullet_Y, $arenaname)
    $number_of_blocks = IniRead($arenaname&".dat", "global", "number_of_blocks", 0)
    For $k = 1 to $number_of_blocks
        $arena_bottomwall_y = IniRead($arenaname&".dat", "block"&$k, "bottom", 0 )
        $arena_leftwall_x = IniRead($arenaname&".dat", "block"&$k, "left", 0 )
        $arena_rightwall_x = IniRead($arenaname&".dat", "block"&$k, "right", 0 )
        $arena_topwall_y = IniRead($arenaname&".dat", "block"&$k, "top", 0 )
        $arena_method = IniRead($arenaname&".dat", "block"&$k, "col_method", "in")
        If $arena_method = "out" Then
            If $bullet_X <= $arena_leftwall_x Or $bullet_X >= $arena_rightwall_x Or $bullet_Y <= $arena_topwall_y Or $bullet_Y >= $arena_bottomwall_y Then
                return 1
            EndIf
       ;ElseIf $arena_method = "in" Then
    ;   If $bullet_X >= $arena_leftwall_x Or $bullet_X <= $arena_rightwall_x Or $bullet_Y >= $arena_topwall_y Or $bullet_Y <= $arena_bottomwall_y Then
    ;       return 1
    ;   EndIf
        EndIf
    Next
    Return 0
EndFunc
Link to comment
Share on other sites

not in the newest version... there it's called tankwars anussi :geek:

EDIT:

AdlibEnable("_reducememory", 1000) don't makes it faster, too :o

EDIT2:

Got it with this Code, but don't raised the performance much... It's better than before, but too slow either:

;Name: Battle.au3
;Author: Lord_Doominik
;Status: In Progress (50%)
;Version: 0.5

Dim $bullet1[50]
Dim $ShootDir1[50]
Dim $ShootPosX1[50]
Dim $ShootPosY1[50]

Dim $bullet2[50]

$i = 0
$l = 0
$reloadtime = TimerInit()

$Arena = GUICtrlCreatePic("Battlefields/Arena1.map", 0, 0, 800, 600)
GUICtrlSetState(-1, $GUI_DISABLE)

$Tank1 = GUICreate("Tank1", 32, 32, 330, 175, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
$Tank1Pic = GUICtrlCreatePic("Vehicles/Panzer1 N.gif", 0, 0, 32, 32)

GUISetState()

$Tank2 = GUICreate("Tank2", 11, 21, 203, 550, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_MDICHILD), $mainGUI)
GUICtrlCreatePic("Vehicles/Roboter2.gif", 0, 0, 11, 21)

GUISetState()

AdlibEnable("_reducememory", 1000)
ControlFocus("Tank Wars", "", $mainGUI)
While 1
    $bmsg = GUIGetMsg()
    Select
    Case $bmsg = $GUI_EVENT_CLOSE
        Exit
    EndSelect
    
    $WinPos = WinGetPos("Tank Wars")
    
    Action()
    Shot()
WEnd

Func Action()
    $pos1 = WinGetPos("Tank1")
    $x1 = 0
    $y1 = 0
    
    If _IsPressed("25") Then;Left
        If Hex(PixelGetColor($pos1[0]+4, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+4, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 W.gif")
            $ShootDir1[$i] = "E"
            $x1 -= 1
        EndIf
    ElseIf _IsPressed("27") Then;Right
        If Hex(PixelGetColor($pos1[0]+27, $pos1[1]), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+27, $pos1[1]+27), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 O.gif")
            $ShootDir1[$i] = "W"
            $x1 += 1
        EndIf
    ElseIf _IsPressed("26") Then;Up
        If Hex(PixelGetColor($pos1[0]+16, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+17, $pos1[1]-1), 6) <> "000000" Or Hex(PixelGetColor($pos1[0]+18, $pos1[1]-1), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+5, $pos1[1]+2), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+2), 6) <> "000000" Then
            GUICtrlSetImage ($Tank1Pic, "Vehicles/Panzer1 N.gif")
            $ShootDir1[$i] = "N"
            $y1 -= 1
        EndIf
    ElseIf _IsPressed("28") Then;Down
        If Hex(PixelGetColor($pos1[0]+5, $pos1[1]+29), 6) <> "000000" And Hex(PixelGetColor($pos1[0]+26, $pos1[1]+29), 6) <> "000000" Then
            GUICtrlSetImage($Tank1Pic, "Vehicles/Panzer1 S.gif")
            $ShootDir1[$i] = "S"
            $y1 += 1
        EndIf
    EndIf

    If (_IsPressed("20")) And (TimerDiff($reloadtime) >= 2000) Then
        GUISwitch($mainGUI)
        
        Switch $ShootDir1[$i]
        Case "N"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 24
        Case "S"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 11.5
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] + 11
        Case "E"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] - 7
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        Case "W"
            $ShootPosX1[$i] = $pos1[0] - $WinPos[0] + 29
            $ShootPosY1[$i] = $pos1[1] - $WinPos[1] - 7
        EndSwitch
        
        $bullet1[$i] = GUICtrlCreateLabel("", $ShootPosX1, $ShootPosY1, 3, 2)
        GUICtrlSetBkColor(-1, 0xFF0000)
        $reloadtime = TimerInit()
        
        $i += 1
    EndIf
    
    ControlMove("Tank1", "", $Tank1, $pos1[0]+$x1, $pos1[1]+$y1)
EndFunc

Func Shot()
    For $j = 0 To $i-1
        Switch $ShootDir1[$j]
        Case "N"
            $ShootPosY1[$j] -= 2
        Case "S"
            $ShootPosY1[$j] += 2
        Case "E"
            $ShootPosX1[$j] -= 2
        Case "W"
            $ShootPosX1[$j] += 2
        EndSwitch
        
        If _CheckHitArenaWalls($ShootPosX1[$j], $ShootPosY1[$j], "Battlefields\Arena1") = 1 And $bullet1[$j] <> 0 Then
            GUICtrlDelete($bullet1[$j])
            $bullet1[$j] = 0
            $ShootDir1[$j] = 0
            $ShootPosX1[$j] = 0
            $ShootPosY1[$j] = 0
            $l += 1
            If $l = $i Then
                $i = 0
                $l = 0
            EndIf
        Else
            GUICtrlSetPos($bullet1[$j], $ShootPosX1[$j], $ShootPosY1[$j])
        EndIf
    Next
EndFunc


Func _CheckHitArenaWalls($bullet_X, $bullet_Y, $arenaname)
    $number_of_blocks = IniRead($arenaname&".dat", "global", "number_of_blocks", 0)
    For $k = 1 to $number_of_blocks
        $arena_bottomwall_y = IniRead($arenaname&".dat", "block"&$k, "bottom", 0 )
        $arena_leftwall_x = IniRead($arenaname&".dat", "block"&$k, "left", 0 )
        $arena_rightwall_x = IniRead($arenaname&".dat", "block"&$k, "right", 0 )
        $arena_topwall_y = IniRead($arenaname&".dat", "block"&$k, "top", 0 )
        $arena_method = IniRead($arenaname&".dat", "block"&$k, "col_method", "in")
        If $arena_method = "out" Then
            If $bullet_X <= $arena_leftwall_x Or $bullet_X >= $arena_rightwall_x Or $bullet_Y <= $arena_topwall_y Or $bullet_Y >= $arena_bottomwall_y Then
                return 1
            EndIf
        ElseIf $arena_method = "in" Then
            If $bullet_X >= $arena_leftwall_x And $bullet_X <= $arena_rightwall_x And $bullet_Y >= $arena_topwall_y And $bullet_Y <= $arena_bottomwall_y Then
                return 1
            EndIf
        EndIf
    Next
    Return 0
EndFunc

Func _ReduceMemory()
    Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
    Return $ai_Return[0]
EndFunc
Edited by Lord_Doominik
Link to comment
Share on other sites

replace your Shot() function with this one

*** it Explodes on Contact *****

Func Shot()
    For $j = 0 To $i-1
        Switch $ShootDir1[$j]
        Case "N"
            $ShootPosY1[$j] -= 2
        Case "S"
            $ShootPosY1[$j] += 2
        Case "E"
            $ShootPosX1[$j] -= 2
        Case "W"
            $ShootPosX1[$j] += 2
        EndSwitch
        
        If _CheckHitArenaWalls($ShootPosX1[$j], $ShootPosY1[$j], "Battlefields\Arena1") = 1 And $bullet1[$j] <> 0 Then
            $bang = GUICtrlCreateLabel("*", $ShootPosX1[$j], $ShootPosY1[$j], 5, 5)
            GUICtrlSetBkColor(-1, 0xFF0000)
            Sleep(200)
            GUICtrlDelete($bullet1[$j])
            GUICtrlDelete($bang)
            $bullet1[$j] = 0
            $ShootDir1[$j] = 0
            $ShootPosX1[$j] = 0
            $ShootPosY1[$j] = 0
            $l += 1
            If $l = $i Then
                $i = 0
                $l = 0
            EndIf
        Else
            GUICtrlSetPos($bullet1[$j], $ShootPosX1[$j], $ShootPosY1[$j])
        EndIf
    Next
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

hm, nice idea but with some bugs and it don't solve my performance problem... and the sleep function inserted is stupid, cause you can't drive in this time, so i would take a timer, but i think i'll first work at the performance, before i think at this... everything else works by the way fine with my newest code but the performance is too bad...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...