TheOnlyOne Posted February 26, 2009 Share Posted February 26, 2009 (edited) okay this is my 2d game and i works but when i need to jump up to the $platform1,$platform2 and $platform3 then i cant jump up to it and stand on it? cant see how i can do it. and then my lvl up func dont work ether cant see why :S? and then the monster follow me after i made that func with "monsterattack" why? and how can i do so it dosent moves after me? and then the last problem right now is when the monster should "spawn " agian then it spawn on the same spot where it did died? how to do a random place expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> HotKeySet("{left}","left") HotKeySet("{right}","right") hotkeyset("{up}","jump") hotkeyset ("{space}","attack") #Region ### START Koda GUI section ### Form=C:\Documents and Settings\lo\Skrivebord\my game\my game.kxf $herolvl=1 $heroexp=0 $mob1exp=15 $herolvlup=15 $mob1hp=5 $herodmg=random (1,4,1) $mob1dmg=random (1,3,1) $herolife=3000*$herolvl $Form1 = GUICreate("Form1", 628, 450, 572, 155) GUISetBkColor(0xFFFFFF) $91=488 $92=400 $93=44 $94=44 $5=10 $81=32 $82=410 $83=33 $84=33 $10=0 $11=0 $p11=320 $p12=140 $p13=292 $p14=4 $ispressed=0 $Pic2 = GUICtrlCreatePic(@ScriptDir&"\lodret.jpg", 4, 3, 4, 441, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Pic3 = GUICtrlCreatePic(@ScriptDir&"vanret.jpg", 8, 4, 612, 4, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Pic4 = GUICtrlCreatePic(@ScriptDir&"\vanret.jpg", 8, 440, 612, 4, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $sideH = GUICtrlCreatePic(@ScriptDir&"\lodret.jpg", 620, 3, 4, 441, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $platform1 = GUICtrlCreatePic(@ScriptDir&"\vanret.jpg", 392, 340, 228, 4, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $platform2 = GUICtrlCreatePic(@ScriptDir&"\vanret.jpg", 144, 240, 380, 4, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $platform3 = GUICtrlCreatePic(@ScriptDir&"\vanret.jpg", $p11, $p12, $p13, $p14, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Pic8 = GUICtrlCreatePic(@ScriptDir&"\_monster15.jpg.jpg", $81, $82, $83, $84, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $Pic9 = GUICtrlCreatePic(@ScriptDir&"\00.MyHero.jpg", $91, $92, $93, $94, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch call ("monstermove") if $heroexp =$herolvlup then $herolvl=$herolvl+1 msgbox(0,"you lvl up","you lvl up") endif if $91-$81 <= 120 then call ("monsterattack") endif if $91-$81 >= 120 then call ("monstermove") endif if $92=$p12 then msgbox(0,"","") wend func left () GUICtrlSetPos ($pic9,$91-$5,$92,$93,$94) $91=$91-$5 endfunc func jump() if $ispressed=0 then $ispressed =1 do GUICtrlSetPos ($pic9,$91,$92-1,$93,$94) if $92 =$p12 then msgbox(0,"","") $10=$10+1 $92=$92-1 sleep(10) until $10=100 do GUICtrlSetPos ($pic9,$91,$92+1,$93,$94) $10=$10-1 $92=$92+1 sleep(10) until $10=0 $ispressed =0 endif endfunc func right () if $ispressed=0 then GUICtrlSetPos ($pic9,$91+$5,$92,$93,$94) $91=$91+$5 endif $ispressed=1 sleep(20) $ispressed=0 endfunc func monstermove () do guictrlsetpos ($pic8,$81+$5,$82,$83,$84) $81 =$81+1 sleep(10) if $91-$81 <= 120 then call ("monsterattack") until $81 =320 do guictrlsetpos ($pic8,$81-$5,$82,$83,$84) $81 =$81-1 if $91-$81 >= 120 then call ("monstermove") sleep (10) until $81 =32 endfunc func attack () if $91-$81 <= 240 then $21=$91 $22=$92+20 $attackpic=GUICtrlCreatePic(@ScriptDir&"\lightning.jpg",$21,$22,50,10) do guictrlsetpos($attackpic,$21-1,$22,50,10) $21=$21-1 sleep(5) until $21=$81 GUICtrlDelete ($attackpic) $91=$91+10 guictrlsetpos ($pic8,$81-12,$82,$83,$84) $81=$81-12 $mob1hp=$mob1hp-$herodmg if $mob1hp <0 then GUICtrlDelete ($pic8) $heroexp=$heroexp+$mob1exp sleep (3000) $pic8=GUICtrlCreatePic(@ScriptDir&"\_monster15.jpg.jpg", $81, $82, $83, $84, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS)) $mob1hp=5 endif endif endfunc func monsterattack () do guictrlsetpos ($pic8,$81+1,$82,$83,$84) $11=$11+1 $81 =$81-1 sleep (5) until $11=10 do guictrlsetpos ($pic8,$81-1,$82,$83,$84) $11=$11-1 $81=$81+1 sleep (5) until $11=0 $herolife=$herolife-$mob1dmg if $herolife <0 then msgbox (0,"","you die") endfunc hope you can help me thanks my_game.zip Edited February 26, 2009 by TheOnlyOne Link to comment Share on other sites More sharing options...
jvanegmond Posted February 26, 2009 Share Posted February 26, 2009 Zip everything and post and , maybe , someone is willing to spend some time on it.. github.com/jvanegmond Link to comment Share on other sites More sharing options...
Inverted Posted February 26, 2009 Share Posted February 26, 2009 Where are the jpgs ? Link to comment Share on other sites More sharing options...
TheOnlyOne Posted February 26, 2009 Author Share Posted February 26, 2009 sorry added a zip file with the files in Link to comment Share on other sites More sharing options...
Triblade Posted February 26, 2009 Share Posted February 26, 2009 (edited) BTW, don't use full paths like: "C:\Documents and Settings\lo\Skrivebord\my game\" I don't have that path on my computer Edit: typo. Edited February 26, 2009 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) Link to comment Share on other sites More sharing options...
TheOnlyOne Posted February 26, 2009 Author Share Posted February 26, 2009 edited that too Link to comment Share on other sites More sharing options...
Triblade Posted February 26, 2009 Share Posted February 26, 2009 (edited) Replace your jump function with: Note! - This works for platform1 only! func jump() if $ispressed=0 then $ispressed =1 do GUICtrlSetPos ($pic9,$91,$92-1,$93,$94) if $92 =$p12 then msgbox(0,"","") $10=$10+1 $92=$92-1 sleep(10) until $10=100 ; Go into the do-until if the hight of 340 (platform1) has been reached and ur char isnt too much to the left or right. (so exacly the length of the platform) If $92 > 340 Or $91 < 392 Or $91 > 392+228 Then; platform1 -> left: 392, width: 228 do GUICtrlSetPos ($pic9,$91,$92+1,$93,$94) $10=$10-1 $92=$92+1 sleep(10) until $10=0 EndIf $ispressed =0 endif endfunc Edit: And I don't know about you, but hero leveling works for me. I did however turn off the monstermove call's. Maybe you just loop too much in the monstermove functions. And for random spot look up the Random() function in the helpfile from AutoIt. Then use it on your $81 variable. ($81 is the monster's left-right position) Edited February 26, 2009 by Triblade My active project(s): A-maze-ing generator (generates a maze) My archived project(s): Pong3 (Multi-pinger) 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