The major assignment involves producing a Super Mario Brothers style game with Clara using the project files that are given to you. The essence of the game – is to make Clara collect all leaves in her world, while avoiding collisions with ghosts chasing her. Clara can move around in her world by walking and jumping. Clara can jump on top of platforms located in her world. She can also walk and jump on the ground. Ghosts are unable to jump and can only walk left and right. They can’t walk through walls and will move down to the closest platform or to the ground after falling from a platform. Clara moves when the player holds “left” or “right” arrow keys. She can jump as the result of the player pushing the “up” arrow key. Jumping is done in the same way as in the Clara jumping example covered in the lectures (the template code is provided). Clara can shoot and kill ghosts. Pressing the “s” key should result in firing the bullet. Firing the first bullet at the start of a level can be done at any time. Every next bullet can only be fired after the 7 seconds reload time. After collecting all leaves in her world Clara can proceed to the next level. The next level loads after Clara approaches the mushroom and moves into it.

University/Course: WSU

Uploaded: October 25, 2024

Files: 3

✓ Solution:



class MyClara extends Clara {

public static String facingDirection;

private final String MOVE_UP = “up”;
private final String MOVE_DOWN = “down”;
private final String MOVE_LEFT = “left”;
private final String MOVE_RIGHT = “right”;

// Adjusted jump parameters for lower jump height
private static final int HORIZONTAL_JUMP_SPEED = 1;
private static final int VERTICAL_JUMP_SPEED = 2;
private static final int GRAVITY = -1;
private static final int ANIMATION_INTERVAL = 8;
private static final int MAX_JUMP_HEIGHT = 4;

private int posX = 0;
private int posY = 0;
private int verticalVelocity = 0;
private int horizontalVelocity = 0;
private boolean jumpState = false;
private boolean dropState = false;
private int animationTick = 0;
private int jumpHeight = 0;

public void act() {
if (!isClaraDead()) {
gameLoop();
} else {
animateDead();
}
}

private void gameLoop() {

handleBackgroundMusic();
processMovement();
processJumpAndFall();
collectItems();
handleAnimation();
wrapAroundWorld();
checkLevelProgress();
}

private void handleBackgroundMusic() {
if (!isIntroStillPlaying()) {
playIntro();
}
}

🔒 Whatsapp us for the full file.