Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overview of game controls | Teamwork Game! #8

Open
jellinki opened this issue Nov 2, 2023 · 0 comments
Open

Overview of game controls | Teamwork Game! #8

jellinki opened this issue Nov 2, 2023 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@jellinki
Copy link
Collaborator

jellinki commented Nov 2, 2023

The game controls are very simple; A to move left, D to move right, and W to jump. I guess you could say it's more WAD than WASD because the "S" key is never actually used. Hmm.

C:\Users\katel\OneDrive\kvscode\new blog\linkblog\images\wasd.png

Above, you can see how we used event listeners to implement the WASD movement.

function updateSpriteAnimation() {
    if (frameX < maxFrame) {
        frameX++;
    } else {
        frameX = 0;
    }
}

function jump() {
    if (!isJumping && isOnGround) {
        spriteVelocityY = jumpStrength;
        isJumping = true;
        isOnGround = false;
    }
}

function moveLeft() {
    isMovingLeft = true;
    isIdle = false;
    frameY = 5;
    maxFrame = 9;
}

function moveRight() {
    isMovingRight = true;
    isIdle = false;
    frameY = 7;
    maxFrame = 9;
}

function idle() {
    isIdle = true;
    frameY = 0;
    maxFrame = 2;
}

Above, you can see the code that we used to call the sprite animations according to the player's movement at that point in time. The frames are named according to the spritesheet provided below:

C:\Users\katel\OneDrive\kvscode\new blog\linkblog\images\linksprites.png

@jellinki jellinki added the documentation Improvements or additions to documentation label Nov 2, 2023
@jellinki jellinki self-assigned this Nov 2, 2023
@jellinki jellinki changed the title Overview of game controls Overview of game controls | Teamwork Game! Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant