Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!isInAir && oInputSystem.wasJumpPressed) {
- isInAir = true;
- verticalSpeed -= JUMP_INITIAL_VERTICAL_SPEED;
- audio_play_sound(sndJump, 1, false);
- }
- verticalSpeed += MY_GRAVITY;
- var fallDirection = point_direction(x, y, oPlanet.x, oPlanet.y);
- var isWalking = false;
- if (oInputSystem.isLeftPressed) {
- isFacingRight = false;
- isWalking = true;
- x += lengthdir_x(HORIZONTAL_SPEED_MAGNITUDE, fallDirection - 90);
- y += lengthdir_y(HORIZONTAL_SPEED_MAGNITUDE, fallDirection - 90);
- }
- if (oInputSystem.isRightPressed) {
- isFacingRight = true;
- isWalking = true;
- x += lengthdir_x(HORIZONTAL_SPEED_MAGNITUDE, fallDirection + 90);
- y += lengthdir_y(HORIZONTAL_SPEED_MAGNITUDE, fallDirection + 90);
- }
- if (!isInAir && isWalking) {
- sprite_index = sPlayerWalking;
- } else if (isInAir && verticalSpeed <= 0) {
- sprite_index = sPlayerJumping;
- } else if (isInAir && verticalSpeed > 0) {
- sprite_index = sPlayerFalling;
- } else {
- sprite_index = sPlayerStanding;
- }
- image_angle = fallDirection + 90;
- if (isFacingRight) {
- image_xscale = 1;
- } else {
- image_xscale = -1;
- }
- var newDeltaXFromFalling = lengthdir_x(verticalSpeed, fallDirection);
- var newDeltaYFromFalling = lengthdir_y(verticalSpeed, fallDirection);
- var newX = x + newDeltaXFromFalling;
- var newY = y + newDeltaYFromFalling;
- if (place_meeting(newX, newY, oPlanet)) {
- while (!place_meeting(x, y, oPlanet)) {
- x += lengthdir_x(0.5, fallDirection);
- y += lengthdir_y(0.5, fallDirection);
- }
- verticalSpeed = 0;
- isInAir = false;
- } else {
- x = newX;
- y = newY;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement