Major Clara Digger Style Game Assignment

Download Solution Order New Solution

Assignment Task

The major assignment involves producing a Digger-style game with Clara using the project files that are given to you. The essence of the game – is to make Clara eat all available leaves and collect all the gold, while avoiding collisions with ghosts chasing her. Clara can move around in her world by walking inside tunnels. She can also dig tunnels as she walks through earth patches. Ghosts can only move inside tunnels. You will find the gameplay video of the original Digger game on Our version of the game issimpler. It does not have shooting or collecting bonus items. In our game the player is also required to collect all gold and all leaves before progressing to the next level. Finally, in our game ghosts must return to the ghost healer for regeneration and can walk through walls and gold sacks when dead.

Ghosts’ vocabulary

For this assignment, you will also be required to code new characters, ghosts. The ghosts pose a threat to Clara as she tries to eat all of her leaves and collect the gold. The ghosts try to prevent her from accomplishing this mission. The behaviour of each ghost is controlled by the act() method inside the Ghost class. Each of the ghosts in the game is essentially an instance of the Ghost class (we will learn about classes in Lecture 10 of the course). In order to assist you in programming ghosts there are Ghost commands already made for you. Some of these commands are exactly the same as Clara’s, some are slightly different, and some are completely unique to the Ghosts. Be sure to read the following list of commands carefully:

Moving Clara and keyboard input

To start programming Clara, you must switch to the corresponding “MyClara” tab in your browser.

One of your first tasks is to learn how to process keyboard input of the player by using “Keyboard.isKeyDown(String)” method. Try passing the movement constants defined inside MyClara.java as input for “Keyboard.isKeyDown(String)” and see what happens when you press the arrow keys. Try starting by using “System.out.println()” to print which of the keys was pressed to make yourself familiar with keyboard input. Next thing for you to do – is to make sure that Clara can be controlled with the arrow keys. You may add extra functionality, such as controls for left-handed players, but that is not compulsory. You will need to use Clara’s “setDirection(String)” method, which can be sent one of the following commands; “up”, “down”, left” or “right” (a good idea is to use the same movement constants defined inside MyClara rather than using those String literals inside your code). Passing the aforementioned String values to “setDirection(String)” method will set Clara’s direction to the command you specify. Once you’re able to process keyboard input and make Clara respond to it by turning in the right direction – now it’s time to make Clara move. In order to make Clara move, you will need to use the “move()” method like you did in your practicals.

Clara must move every time the player presses an arrow key. Once you have made Clara move around, you might notice that Clara may occasionally disappear off the edge of the world. It is important that Clara, and the Ghosts, at some point call the method “wrapAroundWorld()” to deal with this issue. This will enable them to reappear on the opposite side of the world that they disappear off. Gold sacks are Clara’s secret weapons against ghosts. Clara is able to push gold sacks around if there is an empty space next to the gold sack in the direction of Clara’s movement. Clara can strategically dig tunnels and drop these on ghosts. Moving gold sacks will happen by itself when Clara moves towards them and the conditions are right (nothing is blocking the gold sack)

Animating Clara’s movement

In order to animate Clara, you will need to call the “animate()” method. You may notice, that if you just call the “animate()” method, that it cycles through Clara’s animation very quickly. This is because every time the method is called, it advances Clara’s animation to the next frame.

You will need to figure out a way of not calling it every time the “act()” method runs, but every so many times that the “act()” method runs. HINT: If you are having trouble, try only calling “animate()” every second time the act method is called. Then try editing that attempt to work only every third time the act method is called. It will ultimately be up to you to determine what looks best.

Digging through earth patches The key game mechanic of the Digger game is digging through earth. You must program Clara to remove earth patches if she happens to step on one.

Eating leaves, collecting gold and winning the game

Clara will need to eat all leaves and all gold in her world in order to win. First, she must be programmed to eat leaves. If you are unsure of how to do this, please review practicals 1 and 2. Once you’ve got Clara eating leaves, you’ll need to play the right sound every time a leaf is eaten. To do so, you’ll need to call the method “playLeafEatenSound()” at an appropriate point in your code. The next step is collecting gold.

Gold can only be collected after the corresponding gold sack is broken. Breaking a gold sack involves digging under the gold sack and waiting for it to fall and break. You will be programming the gold sacks in part 5. Collecting gold is very similar to eating leaves. You will require the following methods: “onGold()”, “removeGold()” and “playCollectGold()”. When you have Clara happily eating leaves and collecting gold, you’ll need to check that all leaves have been eaten and all gold has been collected. After this you must progress to the next level. You will need to use the “allLeavesEaten()”, “allGoldEaten()”, “advanceToLevel(char[][])” and “getCurrentLevelNumber()” methods. You will need to somehow check what the current level is, and either advance to the next available level, or, if there are no more available levels, advance back to the first level again.

Programming gold sacks

In order to program the movement and breaking of the gold sacks you must work with the “Gold” class. This class is shown in the corresponding tab in Clara’s World. Your gold sacks must operate in 4 different modes: normal, shaking, falling and broken. You will have to use variables for memorising the current mode and to decide how the gold sack must behave. Depending on its state, a gold sack must call one of the following methods to animate it:

  • animate() for normal animation of a stationary gold sack
  • animateShake() for animating the shaking of the gold sack before it starts to fall
  • animateFlip() for animating the falling gold sack.

In the normal mode the gold sack must remain stationary. This mode is active when there is earth patch underneath the sack. Once the earth patch underneath disappears, the gold sack must switch into the shaking mode and must remain in this mode for about three seconds. When shaking mode is activated, you must play the shaking sound using the “playBombTicking()” method. After spending three seconds in the shaking mode the gold sack must start falling. The process of falling is achieved by calling the “move(int)” method. This method has the input parameter that specifies how fast the sack is falling. Before calling the Major Assignment: Clara Digger Game 14 “move(int)” method you should call “setDirection(String)” to specify the direction of movement. Once the falling mode is activated, you must also play the falling sound with the help of the “playGoldFall()” method. The fall will stop as soon as the gold sack lands on an earth patch. You should consider adding the “wrapAroundWorld()” method inside “act()” to avoid falling of the edges of the screen.

Moving ghosts

To program the ghosts, you must edit the Ghost class. Switch to the “Ghost” tab in Clara’s World and start editing the code. Making ghosts move is very similar to making gold sacks move, but all your corresponding code must now be placed inside the Ghost class. You will need to call the “move(int)” method and determine a suitable speed for ghosts. Note that they should move faster than Clara. Don’t forget to call the “wrapAroundWorld()” method, so that ghosts correctly move after reaching the edge of the world. When moving around Clara’s World, ghosts must not walk through earth patches or gold sacks.

Animating ghosts’ movement Making

the ghosts animated works in the similar way as animating Clara. The methods you call are exactly the same. Similar to Clara, you will need to figure out a way of calling the “animate()” method every so often that the act method is called, and that it is up to you to determine how often they should animate. After a collision with a falling gold sack ghosts mush switch into the dead state. While in the dead state ghosts must call the “animateDead()” method for showing the corresponding animation.

Ghosts and collisions with earth patches and gold sacks

Making ghosts detect that a stationary gold sack is in the way and stop, is achieved with the help of the “goldFront()” method. Detecting an earth patch in front is achieved with the help of “earthFront()”. Although, unlike Clara, there is no human player to tell the ghosts where to go after they encounter an earth patch or a gold sack blocking their way. It is up to you to decide what they should generally do when they hit one.

Ghosts colliding with falling gold sacks and dying

Clara is able to kill ghosts by dropping gold sacks on them. From within the Ghost class it is possible to detect a collision with a moving gold sack via the intersectsWithName(“Gold”) method. It is recommended that ghosts operate in one of the two modes: dead or alive. Intersections with moving gold sacks should result in the corresponding ghost switching in the dead mode. In the dead mode ghosts must play the dead animation via “animateDead()” method. It is important to note that the Ghosts do not stop moving when they are dead, and that the Ghost’s “animateDead()” method will need to be run every so many times that the act method is called, just like the “animate()” method. It is also important that ghosts should not harm Clara when they are dead. When in the dead mode ghosts must return to the ghost healer for regeneration. It is acceptable for the ghosts to walk through all objects such as earth patches, gold sacks, etc. when returning to the healer in the dead mode.

Life is Good

Now tidy up your code, add more levels if you want, but be sure to properly comment what you’ve coded. You’re ready to hand in your assignment. 

This IT and Computer Science has been solved by our PhD Experts at My Uni Paper.

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.