Lord_Doominik Posted March 5, 2006 Author Share Posted March 5, 2006 (edited) hm, thx... i'll try it... the example with the mosue was a big help, but i had already tryed it before with setting everytime before checking the active gui to the background gui, but it don't worked... but then the coordinates should fit.... hm... i'll try your example and give you a remark then... EDIT: ok, you're right ^^... your example works VERY sloppy ^^... i'll change it a bit, but thx for your help! Edited March 5, 2006 by Lord_Doominik Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 5, 2006 Moderators Share Posted March 5, 2006 hm, thx... i'll try it... the example with the mosue was a big help, but i had already tryed it before with setting everytime before checking the active gui to the background gui, but it don't worked... but then the coordinates should fit.... hm... i'll try your example and give you a remark then...EDIT: ok, you're right ^^... your example works VERY sloppy ^^... i'll change it a bit, but thx for your help!Wow... way to look a gift horse in the mouth! I guess the key point here is "Works"... other than the Start of this thread! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Lord_Doominik Posted March 5, 2006 Author Share Posted March 5, 2006 hehe ye... i know why my earlier example not worked... i thinm i've used GUIChange()... I'm on it, but i rewrite nearly everything for a better performance... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 5, 2006 Moderators Share Posted March 5, 2006 hehe ye... i know why my earlier example not worked... i thinm i've used GUIChange()...I'm on it, but i rewrite nearly everything for a better performance...What / Where is GUIChange()? Do you mean GUISwitch()? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
nfwu Posted March 5, 2006 Share Posted March 5, 2006 (edited) hey, come on, can't anyone just modify the if statement i gave you to work for your game??? Wait a moment, i'm gonna edit it now and post it when i am done. #) Here is the code: Func _CheckHitArenaWalls($bullet_X, $bullet_Y, $arena) $number_of_blocks = IniRead($arena&".ini", "global", "number_of_blocks", 0) For $i = 1 to $number_of_blocks $arena_bottomwall_y = IniRead($arena&".ini", "block", "bottom", 0 ) $arena_leftwall_x = IniRead($arena&".ini", "block", "left", 0 ) $arena_rightwall_x = IniRead($arena&".ini", "block", "right", 0 ) $arena_topwall_y = IniRead($arena&".ini", "block", "top", 0 ) $arena_method = IniRead($arena&".ini", "block", "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 If $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 Next Return 0 EndFunc And here's Arena1.map's ini file: expandcollapse popup[global] number_of_blocks=8 [block1] top=14 bottom=584 left=13 right=778 col_method=out [block2] top=425 bottom=530 left=187 right=229 col_method=in [block3] top=328 bottom=379 left=443 right=793 col_method=in [block4] top=73 bottom=134 left=607 right=616 col_method=in [block5] top=191 bottom=202 left=619 right=681 col_method=in [block6] top=87 bottom=249 left=250 right=296 col_method=in [block7] top=208 bottom=249 left=250 right=434 col_method=in [block8] top=89 bottom=249 left=389 right=434 col_method=in returns 1 = collided with a wall... #) Based of some standrad collision code that i developed a few years ago... Edited March 5, 2006 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Lord_Doominik Posted March 5, 2006 Author Share Posted March 5, 2006 (edited) looks fine, but don't work o.O expandcollapse popup;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 _CheckHitArenaWalls($ShootPosX1[$j], $ShootPosY1[$j], "Arena1") Switch $ShootDir1[$j] Case "N" $ShootPosY1[$j] -= 2 Case "S" $ShootPosY1[$j] += 2 Case "E" $ShootPosX1[$j] -= 2 Case "W" $ShootPosX1[$j] += 2 EndSwitch ControlMove("", "", $bullet1[$j], $ShootPosX1[$j], $ShootPosY1[$j]) Next EndFunc Func _CheckHitArenaWalls($bullet_X, $bullet_Y, $arenaname) $number_of_blocks = IniRead($arena&".dat", "global", "number_of_blocks", 0) For $i = 1 to $number_of_blocks $arena_bottomwall_y = IniRead($arenaname&".dat", "block", "bottom", 0 ) $arena_leftwall_x = IniRead($arenaname&".dat", "block", "left", 0 ) $arena_rightwall_x = IniRead($arenaname&".dat", "block", "right", 0 ) $arena_topwall_y = IniRead($arenaname&".dat", "block", "top", 0 ) $arena_method = IniRead($arenaname&".dat", "block", "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 EndIf If $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 Edited March 5, 2006 by Lord_Doominik Link to comment Share on other sites More sharing options...
Lord_Doominik Posted March 6, 2006 Author Share Posted March 6, 2006 no idea how to fix it with the method??? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now