0

So i have asked this question before but it think i got my wording wrong what I'm basically trying to do is to to get the player to land on an object he will remain on the object until he either jumps of or walks of (nothing too spectacular i know). But i have no clue how to do this. I have managed to do the walking off bit but the jumping bit is a complete mess.So i have come here and i need help on what to do and if possible what the code will look like

Note My game is made so the character is always in the middle.Only the background and object(e.g a platform) move

r=background
rectx=backgroundx
recty=backgroundy
block=platform
blockx=platformx
blocky=platformy

my code

if ((jumping == true)) {
    recty = recty + 3;
    r.setY(recty);
    blocky = blocky + 3;
    block.setY(blocky);
    rectx = rectx - 5;
    r.setX(rectx);
    blockx = blockx - 5;
    block.setX(blockx);
    ninjarun1.setImage(imgjumpingninja);

    if (jumpforce == 0) {
        ninjarun1.setImage(imgninjafalling);
        recty = recty - 3;
        r.setY(recty);
        rectx = rectx - 5;
        r.setX(rectx);
        blockx = blockx - 5;
        block.setX(blockx);
        blocky = blocky - 3;
        block.setY(blocky);
    }

}

//rightrunning 
if ((jumping == false)) {
    blocky = 300;
    block.setY(blocky);
    recty = 0;
    r.setY(recty);
 }
zlakad
  • 1,314
  • 1
  • 9
  • 16
rashadbb
  • 31
  • 1
  • 6

0 Answers0