TheOnlyOne Posted August 20, 2009 Share Posted August 20, 2009 okay my problem is i have a game and i a char and some platforms the problem is i want my char to fall down if im not on a platform like gravity so it should be something like this if $char = not $platform then fall slow down to a new platform here is my code expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <security.au3> #include <gdiplus.au3> #include <icons.au3> hotkeyset("{right}","right") hotkeyset("{left}","left") hotkeyset ("{space}","jump") hotkeyset("{enter}","arrow1") $shoot=false $jump=false global $platform2,$platform3 global $char,$_arrow1,$arrow1,$newleft,$newtop,$mobcount,$platform1 $_arrow1=@ScriptDir&"\arrow1.png" $job=0;1=bowman & 2=mage & 3=warrior global $neweleft global $newtop global $i global $mob[100] $int=3 $dex=3 $str=3 $top=@DesktopHeight-120 $left=100 $map=1 if $map=1 Then $platforms=3 EndIf local $button[3] #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 298, 302, 218) $Label1 = GUICtrlCreateLabel("Choose job", 152, 56, 67, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Butto1 = GUICtrlCreateButton("Bowman", 32, 144, 75, 25, $WS_GROUP) $Butto2 = GUICtrlCreateButton("Mage", 152, 144, 75, 25, $WS_GROUP) $Butto3 = GUICtrlCreateButton("warrior", 280, 144, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch if $nmsg=$butto1 then $dex=$dex+2 $job=1 endif if $nmsg=$butto2 then $int=$int+2 $job=2 endif if $nmsg=$butto3 then $str=$str+2 $job=3 EndIf until $nmsg= $butto1 or $nmsg= $butto2 or $nmsg= $butto3 $gold=100 $hp=100 $points=5 #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Rasmus\Skrivebord\game\city1.kxf $Form1 = GUICreate("Form1", 633, 447, 192, 124) $Button1 = GUICtrlCreateButton("int+", 88, 217, 35, 39, $WS_GROUP) $Button2 = GUICtrlCreateButton("dex+", 40, 216, 35, 41, $WS_GROUP) $Button3 = GUICtrlCreateButton("str+", 136, 216, 35, 41, $WS_GROUP) $Label1 = GUICtrlCreateLabel("int = "&$int, 48, 288, 80, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("dex = "&$dex, 48, 320, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("str = "&$str, 48, 352, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button4 = GUICtrlCreateButton("shop", 168, 88, 75, 25, $WS_GROUP) $Label4 = GUICtrlCreateLabel("gold ="&$gold, 48, 24, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button5 = GUICtrlCreateButton("Go fight", 528, 32, 75, 25, $WS_GROUP) $Label5 = GUICtrlCreateLabel("Points= "&$points, 48, 184, 80, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $Label1 case $Button1 if $points >0 then $int=$int+1 guictrlsetdata($label1,"int = "&$int) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button2 if $points >0 then $dex=$dex+1 guictrlsetdata($label2,"dex = "&$dex) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button3 if $points >0 then $str=$str+1 guictrlsetdata($label3,"str = "&$str) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button5 call ("arena") EndSwitch if $job=1 Then $extradmg=$dex*3.5 EndIf if $job=2 then $extradmg=$int*5.7 endif if $job=3 Then $extradmg=$str*5.8 EndIf $extraMP=$int*2 $extrahp=$str*3 $avoide=1.4*$dex WEnd func arena() #include <GDIPlus.au3> #Include <WinAPI.au3> $png1=@ScriptDir&"\haha.png" Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", @DesktopWidth, @DesktopHeight) GUISetState(@SW_SHOW,$hgui) $char=guictrlcreatepic("",$left,$top,100,100) $platform1=guictrlcreatepic(@ScriptDir&"\platform.jpg",0,@DesktopHeight-20,@DesktopWidth,10) _setimage($char,$png1) do $nmsg2=GUIGetMsg() $stand=1 sleep (150) until $nmsg2=$GUI_EVENT_CLOSE EndFunc func right () $stand=0 $left=$left+5 guictrlsetpos($char,$left,$top,100,100) EndFunc func left () $stand=0 $left=$left-5 guictrlsetpos($char,$left,$top,100,100) EndFunc func jump () if $jump=false Then $jump=true $stand=0 $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $jump=false endif EndFunc func arrow1() if $shoot=false then $shoot=true global $1=0 sleep (10) $_arrow1=@ScriptDir&"\arrow.gif" $newtop=$top $newleft=$left $arrow1=GUICtrlCreatePic("",$newleft,$newtop,48,6) sleep (10) _setimage($arrow1,$_arrow1) GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (10) $range=round ($newleft+200,3) Do $newleft=$newleft+5 $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (3) $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newleft=$newleft+5 $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) until $newleft=$range GUICtrlDelete($arrow1) $shoot=false EndIf EndFunc func mob_check() if $map=1 then if $mobcount<30 then mob_create() EndIf EndIf EndFunc func mob_create() if $map=1 Then $kindmob=3 $howmanymob=$mobcount/$kindmob mob_pig_create() EndIf EndFunc func mob_pig_create() EndFunc so i want to make gravity but how ? Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 http://www.school-for-champions.com/science/gravity_equations_falling.htm You choose the constant factor value of gravity. The reset are time and distance. The generic equation you may use is: (g*t^2)/2 or (gravity * time ^ 2) / 2 Time is achieved using TimerInit() and TimerDiff() functions. The greater the value of t the greater will be the value of the y axis I guess. Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 (edited) but that is not what i ment i mean like this platoforms= ____ $char=* falldown=^ ____ * ^ ______ _____ so here it fall down on the platform but how do i get it to detect that ? Edited August 20, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 You can manage an array collection of $tagRECT corresponding to lines on the client screen, making the rectangles as taller as the player may be but shorter than the roofing line, i.e.: |--| | | |--| <- line |----| | * | |----| <- line and run them each in a loop checking against player coordinates using the _WinAPI_PtInRect(). If the user's coordinates aren't corresponding to any rectangular areas, the user is falling..? Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 (edited) okay i tryed this okay if _WinAPI_PtInRect($char,$platform1)=false Then do $top=$top+1 guictrlsetpos($char,$left,$top,100,100) until _WinAPI_PtInRect($char,$platform1)=true EndIf but dident work :S ? Edited August 20, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 Seems like you're calling it with the parameters switched. If the $platform1 variable supposed to be $tagRECT then it should be the first parameter, and $char should be of type $tagPOINT which is the second parameter. Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 okay i tryd to switch them so now i did like this if _WinAPI_PtInRect($platform1,$char)=false Then do $top=$top+1 guictrlsetpos($char,$left,$top,100,100) until _WinAPI_PtInRect($platform1,$char)=true EndIf but he goes out of the screen ? long way out ? Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 Can you post the relevant bit of code? Again, read the function description in the help file. The second parameter should be $tagPOINT DllStruct and not a control. Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 okay i tryed like you just said but getting a error global Const $tagRECT = "int 0;int 20;int @DesktopWidth;int 0" and this is the error C:\Documents and Settings\Rasmus\Skrivebord\Ny AutoIt v3 Script.au3(14,63) : ERROR: $tagRECT previously declared as a 'Const' global Const $tagRECT = "int 0;int 20;int @DesktopWidth;int 0" what am i doing wrong :S? Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 (edited) Seems like you need to go back and redo (or do) a few tutorials about DllStructs or read the DllStructCreate() function description and examples to get you started. A typical structure variables is declared as follows: Global $myRect = DllStructCreate($tagRECT) DllStructSetData($myRect, 'Left', 0) DllStructSetData($myRect, 'Top', 0) DllStructSetData($myRect, 'Right', @DesktopWidth) DllStructSetData($myRect, 'Bottom', 20) ; ... You could write a function that takes the left, top, right, bottom and returns a $tagRECT type instead of writing such code over and over. Edited August 20, 2009 by Authenticity Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 (edited) Global $myRect = DllStrctCreate($tagRECT) DllStructSetData($myRect, 'Left', 0) DllStructSetData($myRect, 'Top', 0) DllStructSetData($myRect, 'Right', @DesktopWidth) DllStructSetData($myRect, 'Bottom', 20 this still give me error C:\Documents and Settings\Rasmus\Skrivebord\Ny AutoIt v3 Script.au3(15,41) : ERROR: DllStrctCreate(): undefined function. Global $myRect = DllStrctCreate($tagRECT) Edited August 20, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 Heh, 10 seconds after I've posted I modified it so try again. Same for the $tagPOINT. >_ Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 20, 2009 Author Share Posted August 20, 2009 if _WinAPI_PtInRect($myRect,$mypoint)=false Then do sleep (25) $top=$top+1 guictrlsetpos($char,$left,$top,100,100) until _WinAPI_PtInRect($myRect$mypoint)=true EndIf until $nmsg2=$GUI_EVENT_CLOSE : okay now i dont get error but it dosent work.. i tryed to set the char 500pixels away from the platform and that dosent wokr :S Link to comment Share on other sites More sharing options...
Authenticity Posted August 20, 2009 Share Posted August 20, 2009 Update the point as well, it's the point that gets checked against the rectangle after all. Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 21, 2009 Author Share Posted August 21, 2009 (edited) i tryed this expandcollapse popupfunc arena() #include <GDIPlus.au3> #Include <WinAPI.au3> $png1=@ScriptDir&"\haha.png" Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", @DesktopWidth, @DesktopHeight) GUISetState(@SW_SHOW,$hgui) $char=guictrlcreatepic("",$left,$top,100,100) $platform1=guictrlcreatepic(@ScriptDir&"\platform.jpg",0,@DesktopHeight-20,@DesktopWidth,10) _setimage($char,$png1) do Global $myRect = DllStructCreate($tagRECT) DllStructSetData($myRect, 'Left', 0) DllStructSetData($myRect, 'Top', 720) DllStructSetData($myRect, 'Right', @DesktopWidth-100) DllStructSetData($myRect, 'Bottom', 760) Global $mypoint = DllStructCreate($tagPOINT) DllStructSetData($mypoint, 'X', $left) DllStructSetData($mypoint, 'Y', $top) $nmsg2=GUIGetMsg() $stand=1 sleep (150) if _WinAPI_PtInRect($myRect,$mypoint)=false Then do sleep (15) $top=$top+1 guictrlsetpos($char,$left,$top,100,100) until _WinAPI_PtInRect($myRect,$mypoint)=true EndIf until $nmsg2=$GUI_EVENT_CLOSE EndFunc but my char still go down :s? Edited August 21, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
jvanegmond Posted August 21, 2009 Share Posted August 21, 2009 (edited) Some hints: - Post a full _ working _ script. Don't forget to add all variable declarations and includes. Provide dependancies (the haha.png image) - Do not put #include inside functions (includes contain functions, you cannot declare functions within functions) - Clean up your code. Download the extended SciTE and run Tidy!Edit: Lastly - When you post, post in a mature as possible way. Try to write full phrases. "it no work" becomes "It does not work.". Avoid using smiley faces unnecesarily. Edited August 21, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 21, 2009 Author Share Posted August 21, 2009 okay did you see my last post or my first one ? for the first one is my whole code. anyway here is the whole code expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <security.au3> #include <gdiplus.au3> #include <icons.au3> #include <winapi.au3> #include <GDIPlus.au3> #Include <WinAPI.au3> $png1=@ScriptDir&"\haha.png" hotkeyset("{right}","right") hotkeyset("{left}","left") hotkeyset ("{space}","jump") hotkeyset("{enter}","arrow1") $shoot=false $jump=false global $platform2,$platform3 global $char,$_arrow1,$arrow1,$newleft,$newtop,$mobcount,$platform1 $_arrow1=@ScriptDir&"\arrow1.png" $job=0;1=bowman & 2=mage & 3=warrior global $neweleft global $newtop global $i global $mob[100] $int=3 $dex=3 $str=3 $top=@DesktopHeight-420 $left=100 $map=1 if $map=1 Then $platforms=3 EndIf local $button[3] #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 298, 302, 218) $Label1 = GUICtrlCreateLabel("Choose job", 152, 56, 67, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Butto1 = GUICtrlCreateButton("Bowman", 32, 144, 75, 25, $WS_GROUP) $Butto2 = GUICtrlCreateButton("Mage", 152, 144, 75, 25, $WS_GROUP) $Butto3 = GUICtrlCreateButton("warrior", 280, 144, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch if $nmsg=$butto1 then $dex=$dex+2 $job=1 endif if $nmsg=$butto2 then $int=$int+2 $job=2 endif if $nmsg=$butto3 then $str=$str+2 $job=3 EndIf until $nmsg= $butto1 or $nmsg= $butto2 or $nmsg= $butto3 $gold=100 $hp=100 $points=5 #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Rasmus\Skrivebord\game\city1.kxf $Form1 = GUICreate("Form1", 633, 447, 192, 124) $Button1 = GUICtrlCreateButton("int+", 88, 217, 35, 39, $WS_GROUP) $Button2 = GUICtrlCreateButton("dex+", 40, 216, 35, 41, $WS_GROUP) $Button3 = GUICtrlCreateButton("str+", 136, 216, 35, 41, $WS_GROUP) $Label1 = GUICtrlCreateLabel("int = "&$int, 48, 288, 80, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("dex = "&$dex, 48, 320, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("str = "&$str, 48, 352, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button4 = GUICtrlCreateButton("shop", 168, 88, 75, 25, $WS_GROUP) $Label4 = GUICtrlCreateLabel("gold ="&$gold, 48, 24, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button5 = GUICtrlCreateButton("Go fight", 528, 32, 75, 25, $WS_GROUP) $Label5 = GUICtrlCreateLabel("Points= "&$points, 48, 184, 80, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $Label1 case $Button1 if $points >0 then $int=$int+1 guictrlsetdata($label1,"int = "&$int) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button2 if $points >0 then $dex=$dex+1 guictrlsetdata($label2,"dex = "&$dex) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button3 if $points >0 then $str=$str+1 guictrlsetdata($label3,"str = "&$str) $points=$points-1 guictrlsetdata($label5,"Points= "&$points) EndIf case $Button5 call ("arena") EndSwitch if $job=1 Then $extradmg=$dex*3.5 EndIf if $job=2 then $extradmg=$int*5.7 endif if $job=3 Then $extradmg=$str*5.8 EndIf $extraMP=$int*2 $extrahp=$str*3 $avoide=1.4*$dex WEnd func arena() Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", @DesktopWidth, @DesktopHeight) GUISetState(@SW_SHOW,$hgui) $char=guictrlcreatepic("",$left,$top,100,100) $platform1=guictrlcreatepic(@ScriptDir&"\platform.jpg",0,@DesktopHeight-20,@DesktopWidth,10) _setimage($char,$png1) do Global $myRect = DllStructCreate($tagRECT) DllStructSetData($myRect, 'Left', 0) DllStructSetData($myRect, 'Top', 720) DllStructSetData($myRect, 'Right', @DesktopWidth-100) DllStructSetData($myRect, 'Bottom', 760) Global $mypoint = DllStructCreate($tagPOINT) DllStructSetData($mypoint, 'X', $left) DllStructSetData($mypoint, 'Y', $top) $nmsg2=GUIGetMsg() $stand=1 sleep (150) if _WinAPI_PtInRect($myRect,$mypoint)=false Then do sleep (15) $top=$top+1 guictrlsetpos($char,$left,$top,100,100) until _WinAPI_PtInRect($myRect,$mypoint)=true EndIf until $nmsg2=$GUI_EVENT_CLOSE EndFunc func right () $stand=0 $left=$left+5 guictrlsetpos($char,$left,$top,100,100) EndFunc func left () $stand=0 $left=$left-5 guictrlsetpos($char,$left,$top,100,100) EndFunc func jump () if $jump=false Then $jump=true $stand=0 $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top-10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $top=$top+10 guictrlsetpos ($char,$left,$top,100,100) sleep (50) $jump=false endif EndFunc func arrow1() if $shoot=false then $shoot=true global $1=0 sleep (10) $_arrow1=@ScriptDir&"\arrow.gif" $newtop=$top $newleft=$left $arrow1=GUICtrlCreatePic("",$newleft,$newtop,48,6) sleep (10) _setimage($arrow1,$_arrow1) GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (10) $range=round ($newleft+200,3) Do $newleft=$newleft+5 $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (3) $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop+1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newleft=$newleft+5 $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) sleep (2) $newtop=$newtop-1 GUICtrlSetPos($arrow1,$newleft,$newtop,48,6) until $newleft=$range GUICtrlDelete($arrow1) $shoot=false EndIf EndFunc func mob_check() if $map=1 then if $mobcount<30 then mob_create() EndIf EndIf EndFunc func mob_create() if $map=1 Then $kindmob=3 $howmanymob=$mobcount/$kindmob mob_pig_create() EndIf EndFunc func mob_pig_create() EndFunc Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 23, 2009 Author Share Posted August 23, 2009 (edited) bump Edited August 24, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
jvanegmond Posted August 23, 2009 Share Posted August 23, 2009 I asked you to do 4 simple tasks and then I'll assist you further. So far you've only achieved to do one of them. I suggest you put a little more effort into this before you bump this again. github.com/jvanegmond Link to comment Share on other sites More sharing options...
TheOnlyOne Posted August 23, 2009 Author Share Posted August 23, 2009 okay first of all when you said i should do the tasks one of them was allready done (post a full working script (in the top) but anyway sorry for dont fill them out and for the spell mistake here is the code for now expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <security.au3> #include <gdiplus.au3> #include <icons.au3> #include <winapi.au3> #include <GDIPlus.au3> #include <WinAPI.au3> $png1 = @ScriptDir & "\haha.png" HotKeySet("{right}", "right") HotKeySet("{left}", "left") HotKeySet("{space}", "jump") HotKeySet("{enter}", "arrow1") HotKeySet("{f2}", "stop") $shoot = False $jump = False Global $platform2, $platform3 Global $char, $_arrow1, $arrow1, $newleft, $newtop, $mobcount, $platform1 $_arrow1 = @ScriptDir & "\arrow1.png" $job = 0;1=bowman & 2=mage & 3=warrior Global $neweleft Global $newtop Global $i Global $mob[100] $int = 3 $dex = 3 $str = 3 $top = @DesktopHeight - 420 $left = 100 $map = 1 If $map = 1 Then $platforms = 3 EndIf Local $button[3] #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form1", 413, 298, 302, 218) $Label1 = GUICtrlCreateLabel("Choose job", 152, 56, 67, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Butto1 = GUICtrlCreateButton("Bowman", 32, 144, 75, 25, $WS_GROUP) $Butto2 = GUICtrlCreateButton("Mage", 152, 144, 75, 25, $WS_GROUP) $Butto3 = GUICtrlCreateButton("warrior", 280, 144, 75, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Do $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $nMsg = $Butto1 Then $dex = $dex + 2 $job = 1 EndIf If $nMsg = $Butto2 Then $int = $int + 2 $job = 2 EndIf If $nMsg = $Butto3 Then $str = $str + 2 $job = 3 EndIf Until $nMsg = $Butto1 Or $nMsg = $Butto2 Or $nMsg = $Butto3 $gold = 100 $hp = 100 $points = 5 #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Rasmus\Skrivebord\game\city1.kxf $Form1 = GUICreate("Form1", 633, 447, 192, 124) $Button1 = GUICtrlCreateButton("int+", 88, 217, 35, 39, $WS_GROUP) $Button2 = GUICtrlCreateButton("dex+", 40, 216, 35, 41, $WS_GROUP) $Button3 = GUICtrlCreateButton("str+", 136, 216, 35, 41, $WS_GROUP) $Label1 = GUICtrlCreateLabel("int = " & $int, 48, 288, 80, 20) GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("dex = " & $dex, 48, 320, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("str = " & $str, 48, 352, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button4 = GUICtrlCreateButton("shop", 168, 88, 75, 25, $WS_GROUP) $Label4 = GUICtrlCreateLabel("gold =" & $gold, 48, 24, 80, 17) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Button5 = GUICtrlCreateButton("Go fight", 528, 32, 75, 25, $WS_GROUP) $Label5 = GUICtrlCreateLabel("Points= " & $points, 48, 184, 80, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Form1 Case $Label1 Case $Button1 If $points > 0 Then $int = $int + 1 GUICtrlSetData($Label1, "int = " & $int) $points = $points - 1 GUICtrlSetData($Label5, "Points= " & $points) EndIf Case $Button2 If $points > 0 Then $dex = $dex + 1 GUICtrlSetData($Label2, "dex = " & $dex) $points = $points - 1 GUICtrlSetData($Label5, "Points= " & $points) EndIf Case $Button3 If $points > 0 Then $str = $str + 1 GUICtrlSetData($Label3, "str = " & $str) $points = $points - 1 GUICtrlSetData($Label5, "Points= " & $points) EndIf Case $Button5 Call("arena") EndSwitch If $job = 1 Then $extradmg = $dex * 3.5 EndIf If $job = 2 Then $extradmg = $int * 5.7 EndIf If $job = 3 Then $extradmg = $str * 5.8 EndIf $extraMP = $int * 2 $extrahp = $str * 3 $avoide = 1.4 * $dex WEnd Func arena() Global $hGUI, $hImage, $hGraphic, $hImage1 ; Create GUI $hGUI = GUICreate("Show PNG", @DesktopWidth, @DesktopHeight) GUISetState(@SW_SHOW, $hGUI) $char = GUICtrlCreatePic("", $left, $top, 100, 100) $platform1 = GUICtrlCreatePic(@ScriptDir & "\platform.jpg", 0, @DesktopHeight - 20, @DesktopWidth, 10) _setimage($char, $png1) Do Global $myRect = DllStructCreate($tagRECT) DllStructSetData($myRect, 'Left', 0) DllStructSetData($myRect, 'Top', 720) DllStructSetData($myRect, 'Right', @DesktopWidth - 100) DllStructSetData($myRect, 'Bottom', 760) Global $mypoint = DllStructCreate($tagPOINT) DllStructSetData($mypoint, 'X', $left) DllStructSetData($mypoint, 'Y', $top) $nmsg2 = GUIGetMsg() $stand = 1 Sleep(150) If _WinAPI_PtInRect($myRect, $mypoint) = False Then Do Sleep(15) $top = $top + 1 GUICtrlSetPos($char, $left, $top, 100, 100) Until _WinAPI_PtInRect($myRect, $mypoint) = True EndIf Until $nmsg2 = $GUI_EVENT_CLOSE EndFunc ;==>arena Func right() $stand = 0 $left = $left + 5 GUICtrlSetPos($char, $left, $top, 100, 100) EndFunc ;==>right Func left() $stand = 0 $left = $left - 5 GUICtrlSetPos($char, $left, $top, 100, 100) EndFunc ;==>left Func jump() If $jump = False Then $jump = True $stand = 0 $top = $top - 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top - 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top - 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top - 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top + 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top + 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top + 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $top = $top + 10 GUICtrlSetPos($char, $left, $top, 100, 100) Sleep(50) $jump = False EndIf EndFunc ;==>jump Func arrow1() If $shoot = False Then $shoot = True Global $1 = 0 Sleep(10) $_arrow1 = @ScriptDir & "\arrow.gif" $newtop = $top $newleft = $left $arrow1 = GUICtrlCreatePic("", $newleft, $newtop, 48, 6) Sleep(10) _setimage($arrow1, $_arrow1) GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(10) $range = Round($newleft + 200, 3) Do $newleft = $newleft + 5 $newtop = $newtop + 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(3) $newtop = $newtop + 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(2) $newtop = $newtop + 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(2) $newleft = $newleft + 5 $newtop = $newtop - 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(2) $newtop = $newtop - 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Sleep(2) $newtop = $newtop - 1 GUICtrlSetPos($arrow1, $newleft, $newtop, 48, 6) Until $newleft = $range GUICtrlDelete($arrow1) $shoot = False EndIf EndFunc ;==>arrow1 Func mob_check() If $map = 1 Then If $mobcount < 30 Then mob_create() EndIf EndIf EndFunc ;==>mob_check Func mob_create() If $map = 1 Then $kindmob = 3 $howmanymob = $mobcount / $kindmob mob_pig_create() EndIf EndFunc ;==>mob_create Func mob_pig_create() EndFunc ;==>mob_pig_create Func stop() Exit EndFunc ;==>stop it still the same problem like last time the chars go down even when it should stop 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