So Im creating my first 2d java game and im wondering how to have it seem as if the player is standing on a platform if it lands on it. The problem lies in the fact that in my game the "NINJA" is always at the center of the screen and never moves but just the background and platforms do. Any ideas on how to solve the problem?
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);
}