Computer Science Canada

making characters jump

Author:  Blade [ Wed Apr 23, 2003 10:59 am ]
Post subject:  making characters jump

how could you make a character jump? i mean, you import a picture of a lil dude, and you press a button to make it jump... i tried a for loop for jumping up and down and it worked pretty good... but i cant make him jump on an angle, as if you hold the up and right arrow keys...

Author:  Tony [ Wed Apr 23, 2003 11:12 am ]
Post subject: 

The idea is that while jumping, he can still "walk" side to side. So while the jumping process is taking place, you would need to continue to read from input buffer and allow character to walk in the air... Perhas at a different speed

Author:  AsianSensation [ Fri Apr 25, 2003 9:17 pm ]
Post subject: 

here is something that i used in my mario game(that is, before i changed it to Tactics: Mario), hopefully it will help you.

code:
var chars : array char of boolean
var x : int := 0
var y : real := 0

proc jump
    for angle : 0 .. 180 by 5
        Input.KeyDown (chars)
        if chars (KEY_RIGHT_ARROW) then
            x += 2
        end if
        if chars (KEY_LEFT_ARROW) then
            x -= 2
        end if
        y := 0
        y += 90 * sind (angle)
        drawfilloval (x, round (y), 5, 5, red)
        View.Update
        delay (25)
        drawfilloval (x, round (y), 5, 5, colorbg)
    end for
end jump

loop
    Input.KeyDown (chars)
    if chars (KEY_UP_ARROW) then
        jump
    end if
    if chars (KEY_RIGHT_ARROW) then
        x += 2
    end if
    if chars (KEY_LEFT_ARROW) then
        x -= 2
    end if
    drawfilloval (x, round (y), 5, 5, red)
    View.Update
    delay (10)
    drawfilloval (x, round (y), 5, 5, colorbg)
end loop

Author:  Homer_simpson [ Fri Apr 25, 2003 10:46 pm ]
Post subject: 

try my bouncing post topic
http://www.compsci.ca/bbs/viewtopic.php?t=733&highlight=bounce
it might help
if you want it more specific check out my 2d shooter forum at
http://www.compsci.ca/bbs/viewtopic.php?t=525&highlight=2d+shooter
i have actually used the formula in there. i'm gonna put the code in the forum now


: