Jripe Posted May 18, 2005 Share Posted May 18, 2005 (edited) I am working on a project right now that will simulate a program I plan to make later. What it does is draw a line 1 pixel at a time while finding the coords for the pixel by using projectile physics. Right now the #1 problem is that when I click run script, the GUI will not even open. Any help is welcomed (on anything you see wrong, or things that could use improvement). Thanks expandcollapse popup#include <guiconstants.au3> #include <math.au3> #include <Array.au3> Func GUICtrlCreateLine($x1, $y1, $x2, $y2, $size, $color) $deltaX = $x2 - $x1 $deltaY = $y2 - $y1 $slope = $deltaY/$deltaX $length = Sqrt ($deltaX*$deltaX + $deltaY*$deltaY) $incDeltaX = $deltaX/$length $incDeltaY = $deltaY/$length For $i = 1 to _Ceil ($length) GUICtrlSetBkColor(GUICtrlCreateLabel("", $x1 + $incDeltaX*$i, $y1 + $incDeltaY*$i, $size, $size), $color) Next EndFunc $angle = GUICtrlRead(4) $power = GUICtrlRead(3) GUICreate("Gunbound Aimbot Simulation", 800, 600) GUICtrlCreateInput("Power (0 - 40.0)",325,550) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateInput("Angle",250,550, 70) GUICtrlSetLimit(-1,3,0) ;GUICtrlCreateInput("Wind", 325,10) GUICtrlCreateLine(300,300,302,300,5,"0x000000") GUICtrlCreateLine(0,540,805,540,2,"0x000000") GUISetState() GUICtrlCreateButton("Draw it!", 200, 547) Dim $ctime = 0 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = 812 Do DrawPath() $ctime + .1 Until $ctime = $ftime EndSelect WEnd $x1 = 300 $y1 = 300 Func DrawPath() $g = -9.8^2 $vox = $power * (cos($angle) $voy = $power * (sin($angle) $vfy = $voy + $g $t = ($vfy - $voy) / $g Dim Const $xor = 300 Dim Const $yor = 300 If $x2 > $x1 Then Do $x1 + 1 DrawPath() Until $x1 = $x1 + 1 ElseIf $x2 < $x1 Then Do $x1 - 1 DrawPath() Until $x1 = $x1 - 1 EndIf If $y2 > $y1 Then Do $y1 + 1 DrawPath() Until $y1 = $y1 + 1 ElseIf $y2 < $y1 Do $y1 - 1 DrawPath() Until $y1 = $y1 - 1 EndIf $x2 = $x1 + $vox * $t $y2 = $y1 + $voy * $t - 0.5 * $g * $t * $t $t2 = $t * 2 $ftime = Round($t2,1) $rangex = $vox * $t2 GUICtrlCreateLine($x1,$y1,$x2,$y2,2, "0x000000") $start = 1 If $start = 1 Then Do Dim Const $x2str = $x2, $y2str = $y2 $start - 1 Until $start = 0 EndIf If $start < 1 Then GUICtrlCreateLine($x1,$y1,$x1,$y1,2,"0x000000") Do Dim $start = 2 until $start = 2 Endif EndFuncEDIT: Improved it a bit, it now draws. I'm about to go to bed so tommorow I will figure out how to see if something in a control is changed and use it to change the script so I can see how the line drawing changes. Opinions and helpful changes are welcome.EDIT2:Here's my newest script! It's not quite drawing anymore, but I believe it is improved quite a bit. Right now I am working on making my function that draws work. Edited May 19, 2005 by Jripe Link to comment Share on other sites More sharing options...
GaryFrost Posted May 18, 2005 Share Posted May 18, 2005 expandcollapse popup#include <guiconstants.au3> #include <math.au3> #include <Array.au3> Func GUICtrlCreateLine($x1, $y1, $x2, $y2, $size, $color) $deltaX = $x2 - $x1 $deltaY = $y2 - $y1 $slope = $deltaY/$deltaX $length = Sqrt ($deltaX*$deltaX + $deltaY*$deltaY) $incDeltaX = $deltaX/$length $incDeltaY = $deltaY/$length For $i = 1 to _Ceil ($length) GUICtrlSetBkColor(GUICtrlCreateLabel("", $x1 + $incDeltaX*$i, $y1 + $incDeltaY*$i, $size, $size), $color) Next EndFunc $angle = 56 $power = 53 $start = 0 GUICreate("Gunbound Aimbot Simulation", 800, 600) GUICtrlCreateInput("Power (0 - 40)",325,550) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateInput("Angle",250,550, 70) GUICtrlSetLimit(-1,3,0) GUICtrlCreateInput("Wind", 325,10) GUICtrlCreateLine(0,540,805,540,2,"0x000000") GUISetState() ;~ While 1 ProjectilePoints() ;~ Sleep(500) ;~ WEnd While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func ProjectilePoints() $theta = $angle $vo = $power $g = -9.8^2 $ay = $g $vox = $vo * (cos($theta)) $voy = $vo * (sin($theta)) $ayt = $g $vfy = $voy + $ayt $t = ($vfy - $voy) / $ay $x1 = 200 $y1 = 500 $x2 = $x1 + $vox * $t $y2 = $y1 + $voy * $t - 0.5 * $g * $t * $t If $start = 0 Then GUICtrlCreateLine($x1, $y1, $x2, $y2, 2, "0x000000") EndIf GUICtrlCreateLine($x1, $y1, $x2, $y2, 2, "0x000000") $x1 = $x2 $y1 = $y2 $start = $start + 1 EndFunc SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Jripe Posted May 18, 2005 Author Share Posted May 18, 2005 My new and (hopefully) improved script. Now uses a button to draw. Next to add will be: erasing lines to draw new ones, making the script draw each point .1/second apart till the total flight time is over. Once again, comments, suggestions and improvements to the script are welcome. Just for help, if you change things it would be nice if you explain to me what you change because I am quite ignorant to this still, so sometimes I see what you've changed, but do not know how it works. expandcollapse popup#include <guiconstants.au3> #include <math.au3> #include <Array.au3> Func GUICtrlCreateLine($x1, $y1, $x2, $y2, $size, $color) $deltaX = $x2 - $x1 $deltaY = $y2 - $y1 $slope = $deltaY/$deltaX $length = Sqrt ($deltaX*$deltaX + $deltaY*$deltaY) $incDeltaX = $deltaX/$length $incDeltaY = $deltaY/$length For $i = 1 to _Ceil ($length) GUICtrlSetBkColor(GUICtrlCreateLabel("", $x1 + $incDeltaX*$i, $y1 + $incDeltaY*$i, $size, $size), $color) Next EndFunc $angle = GUICtrlRead(4) $power = GUICtrlRead(3) $start = 0 GUICreate("Gunbound Aimbot Simulation", 800, 600) GUICtrlCreateInput("Power (0 - 40.0)",325,550) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateInput("Angle",250,550, 70) GUICtrlSetLimit(-1,3,0) GUICtrlCreateInput("Wind", 325,10) GUICtrlCreateLine(0,540,805,540,2,"0x000000") GUISetState() GUICtrlCreateButton("Draw it!", 220, 550) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = 812 ProjectilePoints() EndSelect WEnd Func ProjectilePoints() $theta = $angle $vo = $power $g = -9.8^2 $ay = $g $vox = $vo * (cos($theta)) $voy = $vo * (sin($theta)) $ayt = $g $vfy = $voy + $ayt $t = ($vfy - $voy) / $ay $x1 = 200 $y1 = 500 $x2 = $x1 + $vox * $t $y2 = $y1 + $voy * $t - 0.5 * $g * $t * $t If $start = 0 Then GUICtrlCreateLine($x1, $y1, $x2, $y2, 2, "0x000000") EndIf GUICtrlCreateLine($x1, $y1, $x2, $y2, 2, "0x000000");DrawPath() Dim $x1 = $x2 Dim $y1 = $y2 $start = $start + 1 Sleep(100) ProjectilePoints() EndFunc ;Func DrawPath() ; GUICtrlCreateLine($x2, $y2, $x2, $y2, 2, "0x000000") ; Sleep(50) ;EndFunc Link to comment Share on other sites More sharing options...
Jripe Posted May 19, 2005 Author Share Posted May 19, 2005 Here's my newest script! It's not quite drawing yet, but I believe it is improved quite a bit. Right now I am working on making my function that draws work. expandcollapse popup#include <guiconstants.au3> #include <math.au3> #include <Array.au3> Func GUICtrlCreateLine($x1, $y1, $x2, $y2, $size, $color) $deltaX = $x2 - $x1 $deltaY = $y2 - $y1 $slope = $deltaY/$deltaX $length = Sqrt ($deltaX*$deltaX + $deltaY*$deltaY) $incDeltaX = $deltaX/$length $incDeltaY = $deltaY/$length For $i = 1 to _Ceil ($length) GUICtrlSetBkColor(GUICtrlCreateLabel("", $x1 + $incDeltaX*$i, $y1 + $incDeltaY*$i, $size, $size), $color) Next EndFunc $angle = GUICtrlRead(4) $power = GUICtrlRead(3) GUICreate("Gunbound Aimbot Simulation", 800, 600) GUICtrlCreateInput("Power (0 - 40.0)",325,550) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateInput("Angle",250,550, 70) GUICtrlSetLimit(-1,3,0) ;GUICtrlCreateInput("Wind", 325,10) GUICtrlCreateLine(300,300,302,300,5,"0x000000") GUICtrlCreateLine(0,540,805,540,2,"0x000000") GUISetState() GUICtrlCreateButton("Draw it!", 200, 547) Dim $ctime = 0 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = 812 Do DrawPath() $ctime + .1 Until $ctime = $ftime EndSelect WEnd $x1 = 300 $y1 = 300 Func DrawPath() $g = -9.8^2 $vox = $power * (cos($angle) $voy = $power * (sin($angle) $vfy = $voy + $g $t = ($vfy - $voy) / $g Dim Const $xor = 300 Dim Const $yor = 300 If $x2 > $x1 Then Do $x1 + 1 DrawPath() Until $x1 = $x1 + 1 ElseIf $x2 < $x1 Then Do $x1 - 1 DrawPath() Until $x1 = $x1 - 1 EndIf If $y2 > $y1 Then Do $y1 + 1 DrawPath() Until $y1 = $y1 + 1 ElseIf $y2 < $y1 Do $y1 - 1 DrawPath() Until $y1 = $y1 - 1 EndIf $x2 = $x1 + $vox * $t $y2 = $y1 + $voy * $t - 0.5 * $g * $t * $t $t2 = $t * 2 $ftime = Round($t2,1) $rangex = $vox * $t2 GUICtrlCreateLine($x1,$y1,$x2,$y2,2, "0x000000") $start = 1 If $start = 1 Then Do Dim Const $x2str = $x2, $y2str = $y2 $start - 1 Until $start = 0 EndIf If $start < 1 Then GUICtrlCreateLine($x1,$y1,$x1,$y1,2,"0x000000") Do Dim $start = 2 until $start = 2 Endif EndFunc Link to comment Share on other sites More sharing options...
GaryFrost Posted May 19, 2005 Share Posted May 19, 2005 The beta version has better graphic functions, such as GUICtrlCreateGraphic and GUICtrlSetGraphic SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Jripe Posted May 19, 2005 Author Share Posted May 19, 2005 Ok, thank you for pointing that out to me. Link to comment Share on other sites More sharing options...
Jripe Posted May 24, 2005 Author Share Posted May 24, 2005 (edited) Here is my updated code. It's prettied up a bit I think. I'm trying to figure out a way to track the projectile to draw its path. I'll needto figure a way out. expandcollapse popup#include <guiconstants.au3> #include <Array.au3> $angle = GUICtrlRead(4) $power = GUICtrlRead(3) GUICreate("Gunbound Aimbot Simulation", 800, 600) GUICtrlCreateInput("Power (0 - 40.0)", 325, 550) GUICtrlSetLimit(-1, 2, 0) GUICtrlCreateInput("Angle", 250, 550, 70) GUICtrlSetLimit(-1, 3, 0) ;GUICtrlCreateInput("Wind", 325,10) GUICtrlCreateButton("Draw it!", 200, 547) $1 = GUICtrlCreateGraphic (0, 0, 800, 540) GUICtrlSetGraphic ($1, $GUI_GR_MOVE, 1, 540) GUICtrlSetGraphic ($1, $GUI_GR_LINE, 803, 540) GUICtrlSetGraphic ($1, $GUI_GR_DOT, 376, 480) GUICtrlCreateButton("Draw Dot!",50,570) GUISetState() Dim $ctime = 0 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = 812 Do DrawPath() $ctime + .1 Until $ctime = $ftime ;Case $msg = 7 ; DrawPath() ; GUICtrlSetGraphic($1,$GUI_GR_MOVE,300,300) ; GUICtrlSetGraphic($1,$GUI_GR_LINE,($rangex + 300),300) EndSelect WEnd $x1 = 300 $y1 = 300 Func DrawPath() GUISetstate(@SW_HIDE) $g = -9.8 ^ 2 $vox = $power * (Cos($angle)) $voy = $power * (Sin($angle)) $vfy = $voy + $g $t = ($vfy - $voy) / $g Dim Const $xor = 300 Dim Const $yor = 300 $x1 = 300 $y1 = 300 $x2 = $x1 + $vox * $t $y2 = $y1 + $voy * $t - 0.5 * $g * $t * $t $t2 = $t * 2 $ftime = Round($t2, 1) Dim $rangex = $vox * $t2 GUICtrlSetGraphic($1,$GUI_GR_MOVE,300,300) GUICtrlSetGraphic($1,$GUI_GR_LINE,($rangex + 300),300) Sleep(10000) GUISetState(@SW_SHOW) $start = 1 ;If $start = 1 Then ; Do Dim Const $x2str = $x2, $y2str = $y2 ; $start - 1 ; Until $start = 0 ;EndIf EndFunc EDIT:Edited again. In this edit I was just trying to draw a dot where the shot will land. Edited May 24, 2005 by Jripe 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