Anonymous Anonymous - 18 days ago 77 0

No description

Javascript

player movement

// set the velocity
	//this.velocity.x = 0;
	if(input.left) this.velocity.x -= PLAYER_RUN_VELOCITY;
	else if(input.right) this.velocity.x += PLAYER_RUN_VELOCITY;
	else if(this.velocity.x>0) this.velocity.x -=PLAYER_RUN_VELOCITY;
	else if(this.velocity.x<0)this.velocity.x +=PLAYER_RUN_VELOCITY
	//this.velocity.y = 0;
	if(this.velocity.x < -PLAYER_RUN_MAX) this.velocity.x=-PLAYER_RUN_MAX;
	if(this.velocity.x > PLAYER_RUN_MAX) this.velocity.x=PLAYER_RUN_MAX;

	if(input.up && this.jumping==false) {
		this.velocity.y -= PLAYER_JUMP_SPEED;
		this.jumping=true;
	}
	else if(jumping==true) this.velocity.y += PLAYER_FALL_VELOCITY;
	else if(input.down && this.jumping==false) this.crouching == true;//this.velocity.y += PLAYER_RUN_SPEED / 2;



	// move the player
	this.position.x += this.velocity.x;
	this.position.y += this.velocity.y;
Comments