CoderDunn Posted July 10, 2007 Posted July 10, 2007 (edited) It works quite well, except moving right after jumping (while your in the air) In real life u can't do that but in mario you can! Same thing if your running then you press jump. If you let go of the sideways btn while mario is in the air he just keeps moving. This would make it quite dificult to land on a small block! Overall it's a good example. EDIT: The problem is the way you are doing the jump. It's in it's own loop. As far as games go, this is very bad! You want to do all the moving in your main loop so that everything else is still processed ... like moving sideways. Then for the sleeps you need to use TimerInit() instead. Hallman Edited July 11, 2007 by Hallman
jpam Posted July 10, 2007 Posted July 10, 2007 (edited) expandcollapse popup#include <GUIConstants.au3> #include <Prospeed.au3> #include <Misc.au3> Opt("MouseCoordMode",0) Opt("GUIOnEventMode", 1) $gui = GUICreate("Mario",500, 488, -1, -1,$WS_POPUPWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") GUISetState() $Sprite1 = @scriptdir & "/img/mariosprite.gif" $Mariosprite = loadsprite($Sprite1) $Sprite2 = @ScriptDir & "/img/mob1.gif" $Monstersprite1 = loadsprite($Sprite2) $speed = 15 $back = BackgroundScroll(@ScriptDir & "\img\test_background.bmp", 0,0 , -1,1) $mask = LoadImage((@ScriptDir & "\img\test_mask.png", 0, 0, 860, 488, 4) $Mario = sprite($Mariosprite,124, 32, 32, 32, 1, 1, 0, 200,405) SetSpriteSpeed($Mario,3,0) $testmonster = sprite($Monstersprite1,1,0,32,32,2,1,20,300,405) SetmovingRectangle($testmonster,180, 405, 550, 405) SetBackAutoCollision($Mario, $mask, 1, 860, 488, 0) Movesprite($testmonster,180,405) $width = GetBmpWidth($back) $Height = GetBmpHeight($back) Scroll_Stop() $posx = 200 $posy = 405 While 1 Backgrounctrl() if _IsPressed(25) Then SetSpriteAnimMode($Mario,0) SetSpriteAnim($Mario, 60, 0, 32, 32, 3 ,1, 9) While _IsPressed(25) Backgrounctrl() $posx = GetSpriteX($Mario) if _IsPressed(26) Then Jump(-5) if HasSpriteArrived($Mario) Then SetSpritePos($Mario,$posx,$posy,$posx-$speed,$posy) $posx -= $speed EndIf WEnd SetSpriteAnimMode($Mario,1) EndIf if _IsPressed(27) Then SetSpriteAnimMode($Mario,0) SetSpriteAnim($Mario, 60, 32, 32, 32, 3 ,1, 9) While _IsPressed(27) Backgrounctrl() $posx = GetSpriteX($Mario) if _IsPressed(26) Then Jump(5) if HasSpriteArrived($Mario) Then SetSpritePos($Mario,$posx,$posy,$posx+$speed,$posy) $posx += $speed EndIf WEnd SetSpriteAnimMode($Mario,1) EndIf if _IsPressed(26) then Jump(0) WEnd Exit Func _exit() Exit EndFunc Func Jump($side) $side = $side *10 SoundPlay(@ScriptDir & "/sound/Jump.wav") SetSpriteSpeed($Mario,3,5) $x = 20 Do Backgrounctrl() Movesprite($Mario,GetSpriteX($Mario)+$side,GetSpriteY($Mario)-$x*10) $x -= 1 SetSpriteSpeed($Mario,3,$x) Sleep(10) Until $x = 0 do Backgrounctrl() Movesprite($Mario,GetSpriteX($Mario)+$side,GetSpriteY($Mario)+$x*10) $x += 1 SetSpriteSpeed($Mario,3,$x) Sleep(10) Until GetSpriteY($Mario) > $posy Movesprite($Mario,GetSpriteX($Mario),$posy) EndFunc Func Backgrounctrl() GetBackgroundInfos() if GetSpriteX($Mario) > 220+$Offset_X And $Offset_X < $width-520 Then Scroll_Right(3) Elseif GetSpriteX($Mario) < 180+$Offset_X and $Offset_X > 10 Then Scroll_Left(-3) Else Scroll_Stop() EndIf EndFunc your mask must look like this; you should expiriment with the jump routine, because he can't jump over the pipes btw; you have to redownload the new prospeed.udf ,loading sprites has changed ! look at this code kind regards jpam Edited July 10, 2007 by jpam
McGod Posted July 11, 2007 Posted July 11, 2007 Looks nice! I can now jump on the tubes but its very buggy. Sometimes i fall through, stay on air etc... Looks like alot of headway though! Keep up the awemazing work. [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u]
keen Posted July 13, 2007 Posted July 13, 2007 NICE! Downloaded the latest version and it rocks! Need to make it so you can do more than walk aroung though. [center]Kesne's Bar & Grill[/center]
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