
-----------------------------------
RedRogueXIII
Tue Nov 15, 2005 6:59 pm

Need Help with Gravity...
-----------------------------------
Just for a little side project i decided to start on a side scroller.
Ive got a decent amount of gameplay done but I can't seem to get the gravity right for a platform.

up -> Jump
left/right -> move
down -> dash
shift -> high jump (was supposed to be double jump but had problems with that also...)
ctrl -> Lazy shooting code.

* you have to go right in order to see the scrolling background.
When you jump on a platform it changes the height variable- "groundy" but when you walk off the platform the guy is supposed to fall to the ground "layery". I can't see what I messed up on...


View.Set ("graphics:max,max")
var x, y, groundy, layery, jumpup, jumpheight, shotx, shoty, scrollm : int
var jumpFlag, dblJumpFlag, dashFlag, shootFlag : boolean := false
var direction : boolean := true
shotx := 0
shoty := 0
scrollm := 0
x := 200
y := 54
jumpup := 20
jumpheight := jumpup
groundy := 50
layery := groundy

View.Set ("offscreenonly")
var chars : array char of boolean

proc ground
    %drawfill (1, groundy + 1, blue, black)
    drawline (0, layery, maxx, layery, black)
    Draw.DashedLine (50, 0, 50, maxy, drawDot, red)
    Draw.DashedLine (maxx - 50, 0, maxx - 50, maxy, drawDot, red)
    Draw.DashedLine (100, 0, 100, maxy, drawDot, red)
    Draw.DashedLine (maxx - 100, 0, maxx - 100, maxy, drawDot, red)
end ground


proc scroll
    if x >= maxx - 100 then
        scrollm := scrollm + 10
    elsif
            x = maxx - 50 then
        scrollm := scrollm + 30
    elsif
            x = 500 - scrollm and x  40 + layery then
        groundy := layery + 40
    elsif x = 600 - scrollm +5 and y > layery then %and y-4 < groundy then
        y := layery
        groundy := layery
        % locate (3, 1)
        % put "OMG NOOB PLATFORM"
        % groundy := layery
        % if y  500 - scrollm + 5 and x > 600 - scrollm + 5 then %and y > layery then %and y-4 < groundy then
        groundy := layery
        y := layery
    elsif x < 500 - scrollm + 5 and x < 600 - scrollm + 5 then      %and y > layery then %and y-4 < groundy then
        groundy := layery
        y := layery
    elsif x > 500 - scrollm and x < 600 - scrollm then     %and y > 40 + layery then
        groundy := layery + 40

    end if



I still wouldnt mind any suggestions on how to handle a double jump...

-----------------------------------
MysticVegeta
Thu Nov 17, 2005 8:17 pm


-----------------------------------
Where is constant 9.81m/s^2 pull of gravity here in the code?
