Endless runner, how do I properly set up player's jump and gravity?

I am currently creating an endless runner, it’s my first game so I am exited as hell… hehe. I seem to have hit a bump on the road though.

My code scrolls two floors, one after the other one, moving the first one at the starting position everytime to create an endless runner. I have my player character set up at a spot in the screen, and he is supposed to be able to only jump. 

However, when he jumps, he does so slow, and then when he falls, it is equally slow, I don’t know how to adjust falling speed, etc… Also, if I tap twice, he double, tripple, etc… jumps. I need him to only be able to jump once.

--These are constant values stated before

– _CX = display.contentWidth*0.5 – center of the screen going horizontally

– _CY = display.contentHeight*0.5 – center of the screen going vertically

– _CW = display.contentWidth – width of the screen

– _CH = display.contentHeight – height of the screen

– _T = display.screenOriginY – Top of the screen 

– _L = display.screenOriginX – Left of the screen

– _R = display.viewableContentWidth --_L – Right of the screen

– _B = display.viewableContentHeight --_T – Bottom of the screen

function scene:create( event )

    local sceneGroup = self.view

    local function scrollFloorAndCeiling(self, event) – function to scroll floor, gets ca lled 30 frames/sec

        if self.x < -_CW/1.5 then

            self.x = _CW+(_CW/1.5)

        else

            self.x = self.x - self.speed – move to the left by 3, 30 times per second

        end

    end

    local gameFloor = display.newImageRect(sceneGroup, “images/gamescreen/floor-01.png”, 1425, 150)

        gameFloor.x = _L + 685

        gameFloor.y = _B

        gameFloor.speed = 6 – speed variable

        physics.addBody(gameFloor, “static”, {friction=1,bounce = 0, density = 1})

    gameFloor.enterFrame = scrollFloorAndCeiling – default frame rate in corona is 30 frames/sec

        Runtime:addEventListener(“enterFrame”, gameFloor)

    local gameFloor2 = display.newImageRect(sceneGroup, “images/gamescreen/floor-01.png”, 1425, 150)

        gameFloor2.x = _CW + 840

        gameFloor2.y = _B

        gameFloor2.speed = 6 – speed variable

        physics.addBody(gameFloor2, “static”, {friction=1,bounce = 0, density = 1})

    gameFloor2.enterFrame = scrollFloorAndCeiling – default frame rate in corona is 30 frames/sec

        Runtime:addEventListener(“enterFrame”, gameFloor2)

    local player = display.newImageRect(sceneGroup, “images/gamescreen/player.png”, 100, 100)

        player.x = _CW/4

        player.y = _CH-10

        physics.addBody(player, “dynamic”, {friction=1, density=1, bounce=0, radius=35})

        player.isFixedRotation = true

        local function touchScreen(event)

            if (event.phase == “began”) then

                if(player.y >= _B + 100 and _b + 100) then

                    player:setLinearVelocity (0, 800)      --make player fall down after jumping

                    onGround = true

                else

                    player:setLinearVelocity (0, -500)      --make player jump up

                end

            end

        end

        Runtime:addEventListener(“touch”, touchScreen)

Well, this is embarrassing, I solved the gravity on jumping issue.

I just set gravity scale on the player

I simply added one line of code

player.gravityScale = 2

For anybody else’s future reference, check out the documentation on gravityScale here:

https://docs.coronalabs.com/api/type/Body/gravityScale.html

I’ll get back still if I solve my own double jump problem

Alright, solved the double jumping by going here 

https://forums.coronalabs.com/topic/16042-make-an-object-jump-only-once/

bottom post, by LeivaGame

Well, this is embarrassing, I solved the gravity on jumping issue.

I just set gravity scale on the player

I simply added one line of code

player.gravityScale = 2

For anybody else’s future reference, check out the documentation on gravityScale here:

https://docs.coronalabs.com/api/type/Body/gravityScale.html

I’ll get back still if I solve my own double jump problem

Alright, solved the double jumping by going here 

https://forums.coronalabs.com/topic/16042-make-an-object-jump-only-once/

bottom post, by LeivaGame