
-----------------------------------
Mayb123
Thu Oct 11, 2007 7:18 pm

Stopping an object from falling through what is supposed to be the ground
-----------------------------------
I am still making the game from earlier posts by me and i'm working on the section of the code to be used for motion and jumping, but before i go any further, i'm just wondering how i would go about stopping an object, in this case a dot, from falling beneath the initial y position of 10, while also being able to jump from the second position after the first jump:

setscreen ("graphics:640;480")
var key : array char of boolean
var ground, vcap, x, y, vx, vy, ax, g, charx, chary, carvx : real
const gravity := -0.5
x := 10
y := 10
vx := 1
ax := .8
vy := 5
% g := -0.5
vcap := 10.1
procedure jump
    % Makes character jump at the press of the up key.
    loop
        cls
        View.Set ("offscreenonly")
        x += vx
        y += vy
        if round (y)>=10 then
        vy += gravity
        end if
        drawfilloval (round (x), round (y), 2, 2, black)
        delay (10)
        View.Update

    end loop
end jump
procedure crouch
% Makes character crouch on the ground.

end crouch
loop
    View.Set ("offscreenonly")
    Input.KeyDown (key)
    if key (KEY_UP_ARROW) then
        jump
    elsif key (KEY_DOWN_ARROW) then
        crouch
    end if
end loop

-----------------------------------
Saad
Thu Oct 11, 2007 7:20 pm

RE:Stopping an object from falling through what is supposed to be the ground
-----------------------------------
Your jump procedure has no exit condition, add exit when y = 10 then
vy +=gravity
end if
if y = 10 then
vy := 0
end if % Ends here

    if round (x) >= 633 and round (x) 