
-----------------------------------
X2_star
Mon Apr 07, 2008 3:17 pm

Make a animation Jump
-----------------------------------
Hello, I need to know how to make a picture for a small animation video jump.

-----------------------------------
Mackie
Mon Apr 07, 2008 3:47 pm

RE:Make a animation Jump
-----------------------------------
Post some code we can help you with. Otherwise how are we supposed to help?

-----------------------------------
DaveAngus
Tue Apr 08, 2008 8:20 am

RE:Make a animation Jump
-----------------------------------
Is this what your looking for?


% some constants, tweak this to your liking
const GROUND_HEIGHT := 40
const PLATFORM_HIEGHT := 200
const PLATFORM_HIEGHT2 := 350
const RUN_SPEED := 10
const FAST_SPEED := 13
const JUMP_SPEED := 30
const GRAVITY := 2

var win := Window.Open ("graphics:1200;600,offscreenonly")
var chars : array char of boolean

% player position and velocity
var posx, posy, gx, gx2, rx, lx : int
var velx, vely : real

posx := 200
velx := 0
posy := 400
vely := 0
gx := 10
gx2 := 10000
rx := 500
lx := 400

loop
    Input.KeyDown (chars)
    if chars ('q') then
        exit
    end if

    % to make the player move
    if chars (KEY_LEFT_ARROW) and chars (KEY_CTRL) then
        velx := -FAST_SPEED
    elsif chars (KEY_RIGHT_ARROW) and chars (KEY_CTRL) then
        velx := FAST_SPEED
    elsif chars (KEY_LEFT_ARROW) then
        velx := -RUN_SPEED
    elsif chars (KEY_RIGHT_ARROW) then
        velx := RUN_SPEED
    else
        velx := 0
    end if


    % remember, in order to jump you MUST be on the ground when pressing UP
    if (chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT) or (chars (KEY_UP_ARROW) and posy = PLATFORM_HIEGHT and posx >= gx + 300 and posx = gx + 500 and posx = rx and chars (KEY_RIGHT_ARROW) and rx < gx2 - (maxx - rx) then
        gx -= round (velx)
        gx2 -= round (velx)
        posx := rx
        posx := rx
    end if

    if posx  gx + lx - 5 then
        gx -= round (velx)
        gx2 -= round (velx)
        posx := lx
        posx := lx
    end if

    % subtract your "gravity" constant from the velocity EACH frame
    vely := vely - GRAVITY
    posx := posx + round (velx)
    posy := posy + round (vely)

    /*if vely < -25 then
     vely := -25
     end if
     */
    % simple "collision" check. just makes sure the player stays above ground
    if posy < GROUND_HEIGHT and (posx < gx + 800 or posx > gx + 1000) then
        posy := GROUND_HEIGHT
        vely := 0
    end if
  
    if posy = gx + 300 and posx = gx + 500 and posx  gx2 - 10 then
        posx := gx2 - 10
    end if

    % different colours just to illustrate whether or not you may jump

    drawline (gx, GROUND_HEIGHT, gx2, GROUND_HEIGHT, blue)
    drawline (gx + 500, PLATFORM_HIEGHT + 150, gx + 600, PLATFORM_HIEGHT + 150, blue)
    drawline (gx + 300, PLATFORM_HIEGHT, gx + 400, PLATFORM_HIEGHT, blue)
    drawline (gx, GROUND_HEIGHT, gx, maxy - 10, blue)
    drawline (gx, maxy - 10, gx2, maxy - 10, blue)
    drawline (gx2, maxy - 10, gx2, GROUND_HEIGHT, blue)
    drawfill (1, 1, gray, blue)
    drawfill (1, maxy - 1, gray, blue)
    drawfillbox (gx + 800, 0, gx + 1000, GROUND_HEIGHT, 0)

    if posy = GROUND_HEIGHT then
        drawfillbox (posx - 10, posy, posx + 10, posy + 20, green)
    elsif posy = PLATFORM_HIEGHT and posx >= gx + 300 and posx 