Aircrafts Battle (3)

Aircrafts Battle (3)

Purpose

Following with the version of the Aircrafts Battle, I’d like to add more challenges to on the basis of the former version with the bullets updated with a “BOSS” this time.

The first version: https://www.elecfreaks.com/blog/post/aircrafts-battle.html

The second version with the bullet:

https://www.elecfreaks.com/blog/post/aircraft-battle-2.html

You can check the former versions of them to get the basic knowledge of the aircrafts battle.

Materails

Aircrafts Battle

Aircrafts Battle

Program

Go to https://arcade.makecode.com/

Code

Modify the code on the basis of the aircraft battle 2:

https://makecode.com/_5PhT09YCK0Wa

In the previous version, the enemy aircraft always flew straight down, which would be very easy to dodge, here I set the enemy aircraft’s flight path randomly tilts to the left or right, and the player must destroy all enemy aircraft.

Aircrafts Battle

Then, I set a flag variable BOSS_FLAG. When the player score is less than 100 and the flag variable BOSS_FLAG is false, the enemy aircraft will be generated. If the player score is equal to 100, the BOSS unit will be generated and the flag variable BOSS_FLAG will be set to true. And set the BOSS_HP of the BOSS unit to 30, and set the initial position of the BOSS unit.

Aircrafts Battle

Aircrafts Battle

Only the presence of BOSS units does not increase the difficulty, so I want the BOSS to be able to fire bullets. When BOSS_FLAG is true and BOSS_HP is not 0, bullets will be fired from the position of the BOSS, and the bullets can automatically track the player’s aircraft (in fact, I want the bullets fired by the BOSS to target the position of the player’s fighter jet at the moment the bullet is fired, but I haven’t found a way to achieve it. If you know how this is done, you can give me some hints in the comment area. Here I set a separate type for the bullet fired by the BOSS.

Aircrafts Battle

When the bullet fired by the player hits the BOSS, the BOSS_HP is reduced by 1, and the bullet is destroyed; when the BOSS_HP is equal to 0, the BOSS unit is destroyed and the player wins.

Aircrafts Battle

When the bullet fired by the BOSS hits the player, the bullet fired by the BOSS will be destroyed and the player's life data will be deduced by 1.

Aircrafts Battle

Since the bullets fired by the BOSS are automatically tracked, we need to allow the player to have the ability to resist such bullets, when we can let the bullets fired by the player collide with the bullets fired by the BOSS, let’s set they are both destroyed.

Aircrafts Battle

Program

Link: https://makecode.com/_1D6DftbjM6Ph

Way of downloading:

After programming, connect the computer with the Retro via the USB cable.

Aircrafts Battle

Choose hardware "F4".

Aircrafts Battle

Click the reset button on the Retro and go to the downloading page.

Aircrafts Battle

Match the devices and get connected with "Arcade".

Aircrafts Battle

Click downloading to compile the program into the Retro.

Aircrafts Battle

Conclusion

Control the movement of the spirite in the screen, set the life in 3. When it crashes onto the enemy, the life score decreases 1, the game is over when the score is 0; press button A to launch the projectiles, the score adds 1 each time when the enemy gets hit.