As the final stage of this project we will create a hill for the targets to sit on. The landscape will have a diagonal slope; we have to change the parabola trajectory to shoot at different points on the hill. The finished game will look like the following screenshot:
We could manually draw landscapes as sprites. But if we want to create many different levels, it could take a lot of work. Instead, we will make a drawing tool to create the hill.
drawing tool
.240
after x and 0
after y, so the tool starts at the right edge of the stage.5
using a set pen size to block. Again you might want to create a thinner or thicker line.-100
y: -180
block. Because the pen is down, it will draw a line between its start and end point.To make full use of our newly drawn landscape, we have to set the targets down on them. But how do we do that on such an uneven surface? The solution is to slowly move the targets down and use another collision test to decide when the targets have reached the landscape and should stop moving. We add the following script to the target sprite:
The steps to perform this test are as follows:
I filled in the number -4
for a fairly slow speed. You may take bigger steps, but then the targets could end up being stuck partly through the landscape. Not a big issue, but it might not look as nice.
Computers are very precise about color. Keep this in mind if your color collision doesn't work. Most likely, the actual color of the object will be slightly different from the color that you checked for. You can't see it with the naked eye, but the computer can tell the difference based on the color number. The finished script should look like the following screenshot:
As a final step, change y:
0
to y:
180
in the other target sprite script. This will place the target at the top of the stage and make sure that it doesn't end up inside or underneath the landscape.
Now that we have another object on the stage, that is, the landscape, there is one more thing we have to do to finish the game. When the cannonball hits the ground, it should stop instead of moving straight through the landscape. This is similar to the addition we added after including the targets. Now we only need to add another collision check for the cannonball to respond to.
The following are the steps for this collision check:
The cannonball will now respond to hitting the stage edge, a target, and the landscape.
18.226.98.208