Link to the project or level: [Game Lab - Code.org] What I expect to happen: [everything stays still] What actually happens: [everything on the screen appears to be shaking vertically] What I’ve tried: [I’ve established that the cam() function is causing the shaking. When I remove cam() from the draw loop the shaking stops. I am not familiar with the camera so I’m not sure why this is happening. cam() sets camera.y to the player.y but the watcher shows camera.y is moving between the player.y and player.y + 1.
I couldn’t see it with the watcher but I also noticed that the player.y is moving when the player should be still. Which then causes the camera.y to move. ]
I’m not sure i completely see you issue though i managed to solve a few others like the player not being able to jump, invoking gravity so that the jump doesn’t go on forever and fixing y camera glitching after jump has finished… I’ll mostly just show you what i changed
// rewrote vertically scrolling cam
function cam() {
camera.y = player.y-player.velocityY;
}
// rewrote a portion of the player jump code
function controlPlayer() {
player.collide(mainFloor);
player.collide(platform);
if(keyWentDown("up") && player.velocityY === 0) {
player.velocityY = -17;
player.setAnimation("Jumping");
}
playerFall();
not sure if this is that shaking you were talking about earlier… but if you remove the velocity from the player when using camera movement you shouldn’t get stuff like that
Sorry, I was playing around with the code. I should have made a copy to share in the forum so that I didn’t mix things up. Varrience’s suggestion fixed the problem.