Jump to content

Recommended Posts

Posted (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 by Hallman
Posted (edited)

#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;

post-5777-1184106715_thumb.png

you should expiriment with the jump routine, because he can't jump over the pipes :whistle:

btw; you have to redownload the new prospeed.udf ,loading sprites has changed !

look at this code

kind regards

jpam

Edited by jpam
Posted

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.

Posted

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]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...